Skip to content

Commit

Permalink
🐛 Consider empty zones in Tech API
Browse files Browse the repository at this point in the history
Fixes [Bug]: Not using first zone or leaving it unconfigured causes failure during init [L-X WiFi] #130
  • Loading branch information
anarion80 committed Nov 3, 2024
1 parent 39f2610 commit 4586fac
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions custom_components/tech/tech.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ async def get_module_zones(self, module_udid):
_LOGGER.debug("Updating module zones ... %s", module_udid)
result = await self.get_module_data(module_udid)
zones = result["zones"]["elements"]
zones = list(filter(lambda e: e["zone"]["visibility"], zones))
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))

for zone in zones:
self.modules[module_udid]["zones"][zone["zone"]["id"]] = zone
Expand Down Expand Up @@ -268,14 +268,14 @@ async def module_data(self, module_udid):
_LOGGER.debug("Updating module zones & tiles ... %s", module_udid)
result = await self.get_module_data(module_udid)
zones = result["zones"]["elements"]
zones = list(filter(lambda e: e["zone"]["visibility"], zones))
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))

if len(zones) > 0:
_LOGGER.debug("Updating zones for controller: %s", module_udid)
zones = list(
filter(
lambda e: e["zone"]["zoneState"] != "zoneUnregistered",
zones,
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",
zones
)
)
for zone in zones:
Expand Down

0 comments on commit 4586fac

Please sign in to comment.