Skip to content

Commit 910f035

Browse files
committed
🐛 Consider empty zones in Tech API
Fixes [Bug]: Not using first zone or leaving it unconfigured causes failure during init [L-X WiFi] #130
1 parent de87bff commit 910f035

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

custom_components/tech/tech.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ async def get_module_zones(self, module_udid):
214214
_LOGGER.debug("Updating module zones ... %s", module_udid)
215215
result = await self.get_module_data(module_udid)
216216
zones = result["zones"]["elements"]
217-
zones = list(filter(lambda e: e["zone"]["visibility"], zones))
217+
zones = list(filter(lambda e: e is not None and "zone" in e and e["zone"] is not None and "visibility" in e["zone"], zones))
218218

219219
for zone in zones:
220220
self.modules[module_udid]["zones"][zone["zone"]["id"]] = zone
@@ -268,14 +268,14 @@ async def module_data(self, module_udid):
268268
_LOGGER.debug("Updating module zones & tiles ... %s", module_udid)
269269
result = await self.get_module_data(module_udid)
270270
zones = result["zones"]["elements"]
271-
zones = list(filter(lambda e: e["zone"]["visibility"], zones))
271+
zones = list(filter(lambda e: e is not None and "zone" in e and e["zone"] is not None and "visibility" in e["zone"], zones))
272272

273273
if len(zones) > 0:
274274
_LOGGER.debug("Updating zones for controller: %s", module_udid)
275275
zones = list(
276276
filter(
277-
lambda e: e["zone"]["zoneState"] != "zoneUnregistered",
278-
zones,
277+
lambda e: e is not None and "zone" in e and e["zone"] is not None and "zoneState" in e["zone"] and e["zone"]["zoneState"] != "zoneUnregistered",
278+
zones
279279
)
280280
)
281281
for zone in zones:

0 commit comments

Comments
 (0)