Skip to content

Commit

Permalink
Correct order: first stop the task, then update the data used by the …
Browse files Browse the repository at this point in the history
…task.
  • Loading branch information
Lurker00 committed Jul 29, 2024
1 parent 1bc069a commit 21af3e1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions custom_components/localtuya/core/pytuya/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,10 +867,10 @@ async def _action():
updated_states["online"] = list(set(cached_on_devs + on_devs))
updated_states["offline"] = list(set(cached_off_devs + off_devs))

self.sub_devices_states = updated_states

if self._sub_devs_query_task is not None:
self._sub_devs_query_task.cancel()

self.sub_devices_states = updated_states
self._sub_devs_query_task = self.loop.create_task(_action())

def _setup_dispatcher(self) -> MessageDispatcher:
Expand Down

0 comments on commit 21af3e1

Please sign in to comment.