Skip to content

Commit 020ed02

Browse files
committed
Add support for MQTT
This is currently untested.
1 parent 0a9509e commit 020ed02

18 files changed

+7332
-1826
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ What it can do:
2626
- **Even more**
2727
There are some more goodies in to docs below. Enjoy!
2828

29-
_Note: currently this is limited to Blue switches using ZHA, but ideally Z2M and other Inovelli switches will be added in the future._
29+
_Note: currently this is limited to Blue switches using ZHA or Zigbee2MQTT, but other Inovelli switches will be added in the future._
3030

3131
**Configure notifications** for multiple switches easily:
3232

custom_components/lampie/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: LampieConfigEntry) -> bo
4747
_LOGGER.debug("setup %s with config:%s", entry.title, entry.data)
4848

4949
if DOMAIN not in hass.data:
50-
hass.data[DOMAIN] = LampieOrchestrator(hass)
50+
orchestrator = LampieOrchestrator(hass)
51+
hass.data[DOMAIN] = orchestrator
52+
53+
await orchestrator.setup()
5154

5255
coordinator = LampieUpdateCoordinator(hass, entry)
53-
orchestrator: LampieOrchestrator = hass.data[DOMAIN]
54-
orchestrator.add_coordinator(coordinator)
56+
orchestrator = hass.data[DOMAIN]
57+
await orchestrator.add_coordinator(coordinator)
5558
entry.runtime_data = LampieConfigEntryRuntimeData(
5659
orchestrator=orchestrator,
5760
coordinator=coordinator,
@@ -81,7 +84,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: LampieConfigEntry) -> b
8184
unload_ok: bool = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
8285

8386
if orchestrator := entry.runtime_data.orchestrator:
84-
orchestrator.remove_coordinator(coordinator)
87+
await orchestrator.remove_coordinator(coordinator)
8588

8689
if orchestrator.teardown() and orchestrator == hass.data.get(DOMAIN):
8790
hass.data.pop(DOMAIN)

custom_components/lampie/config_flow.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -620,19 +620,19 @@ def _is_inovelli_switch(
620620
entity_registry: er.EntityRegistry,
621621
entity_id: str,
622622
) -> bool:
623-
"""Check if entity_id should be included for dependent entities.
623+
"""Check if entity_id should be included for the list of switches.
624624
625-
Determine if an entity_id represents an entity with a `state_class` of
626-
`total_increasing` and a `unit_of_measurement` of `km`.
625+
Determine if an entity_id represents an Inovelli switch.
627626
628627
Returns:
629628
A flag indicating if the entity should be included.
630629
"""
630+
631631
return bool(
632632
(entity := entity_registry.async_get(entity_id))
633633
and (device := device_registry.async_get(entity.device_id))
634-
and (model := device.model)
635-
and (model in INOVELLI_MODELS)
634+
and ((model := device.model), (model_id := device.model_id))
635+
and ((model in INOVELLI_MODELS) or (model_id in INOVELLI_MODELS))
636636
)
637637

638638

custom_components/lampie/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"@wbyoung"
66
],
77
"config_flow": true,
8-
"dependencies": [],
8+
"dependencies": ["mqtt"],
99
"documentation": "https://github.com/wbyoung/lampie",
1010
"homekit": {},
1111
"iot_class": "calculated",

0 commit comments

Comments
 (0)