Skip to content

Commit

Permalink
Fix zone data never being refreshed
Browse files Browse the repository at this point in the history
  • Loading branch information
peroo committed Dec 2, 2024
1 parent 70e0211 commit 9a38b68
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions pytouchlinesl/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,12 @@ async def zones(self, *, include_off: bool = False, refresh: bool = False) -> li
include_off: (Optional) Include zones which are switched off in the results.
refresh: (Optional) Force the data to be refreshed using the API.
"""
if not self._zones or refresh:
data = await self._data(refresh=refresh)
data = await self._data(refresh=refresh)

for z in data.zones.elements:
schedule = await self.schedule_by_idx(z.mode.schedule_index)
zone = Zone(module=self, client=self._client, zone_data=z, schedule=schedule)
self._zones.append(zone)
for z in data.zones.elements:
schedule = await self.schedule_by_idx(z.mode.schedule_index)
zone = Zone(module=self, client=self._client, zone_data=z, schedule=schedule)
self._zones.append(zone)

if include_off:
return self._zones
Expand Down Expand Up @@ -136,9 +135,8 @@ async def schedules(self, *, refresh: bool = False) -> list[GlobalScheduleModel]
Args:
refresh: (Optional) Force the data to be refreshed using the API.
"""
if not self._schedules or refresh:
data = await self._data(refresh=refresh)
self._schedules = data.zones.global_schedules.elements
data = await self._data(refresh=refresh)
self._schedules = data.zones.global_schedules.elements

return self._schedules

Expand Down

0 comments on commit 9a38b68

Please sign in to comment.