Skip to content

Commit

Permalink
localapi: handle more invalid API responses
Browse files Browse the repository at this point in the history
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
  • Loading branch information
Noltari committed Feb 21, 2024
1 parent 4e28aad commit a6742e2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion aioairzone/localapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,10 @@ def update_dhw(self, data: dict[str, Any]) -> None:
else:
self.hotwater = HotWater(dhw)

def update_systems(self, data: dict[str, Any]) -> None:
def update_systems(self, data: dict[str, Any] | None) -> None:
"""Gather Systems data."""
if data is None:
raise APIError(f"update_systems: empty Systems API response")
api_systems = data.get(API_SYSTEMS)
if api_systems is None:
raise APIError(f"update_systems: {API_SYSTEMS} not in API response")
Expand Down Expand Up @@ -299,6 +301,8 @@ async def update(self) -> None:
zone.set_available(False)

hvac = await self.get_hvac()
if hvac is None:
raise APIError(f"update: empty HVAC API response")
if self.options.system_id == DEFAULT_SYSTEM_ID:
hvac_systems = hvac.get(API_SYSTEMS)
if hvac_systems is None:
Expand Down

0 comments on commit a6742e2

Please sign in to comment.