Skip to content

Commit

Permalink
cloudapi: add connect_installation_websockets function
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 Mar 4, 2024
1 parent 0eb155c commit 2d8eb99
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions aioairzone_cloud/cloudapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,15 @@ async def update_aidoos(self) -> None:

await asyncio.gather(*tasks)

def connect_installation_websockets(self, inst_id: str) -> None:
"""Connect installation WebSockets."""
if not self.options.websockets:
return

inst_ws = self.websockets.get(inst_id)
if inst_ws is not None:
inst_ws.connect()

async def update_installation(self, inst: Installation) -> None:
"""Update Airzone Cloud installation from API."""
inst_id = inst.get_id()
Expand Down Expand Up @@ -666,9 +675,7 @@ async def update_installation(self, inst: Installation) -> None:
group.add_aidoo(aidoo)
inst.add_aidoo(aidoo)

inst_ws = self.websockets.get(inst_id)
if inst_ws is not None:
inst_ws.connect()
self.connect_installation_websockets(inst_id)

async def update_installations(self) -> None:
"""Update Airzone Cloud installations from API."""
Expand Down

0 comments on commit 2d8eb99

Please sign in to comment.