Skip to content

Commit

Permalink
cloudapi: support updating device_config data
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 Jul 25, 2024
1 parent 3ebb65b commit d8b5cea
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
21 changes: 18 additions & 3 deletions aioairzone_cloud/cloudapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,13 @@ def set_system_zones_data(self, system: System) -> None:
async def update_aidoo(self, aidoo: Aidoo) -> None:
"""Update Airzone Cloud Zone from API."""
device_data = await self.api_get_device_status(aidoo)
if self.options.device_config:
device_config = await self.api_get_device_config(aidoo)
print(device_config)
else:
device_config: dict[str, Any] = {}

update = EntityUpdate(UpdateType.API_FULL, device_data)
update = EntityUpdate(UpdateType.API_FULL, device_config | device_data)

await aidoo.update(update)

Expand Down Expand Up @@ -773,8 +778,13 @@ def get_ws_device_data(self, device: Device) -> dict[str, Any] | None:
async def update_system(self, system: System) -> None:
"""Update Airzone Cloud System from API."""
device_data = await self.api_get_device_status(system)
if self.options.device_config:
device_config = await self.api_get_device_config(system)
print(device_config)
else:
device_config: dict[str, Any] = {}

update = EntityUpdate(UpdateType.API_FULL, device_data)
update = EntityUpdate(UpdateType.API_FULL, device_config | device_data)

await system.update(update)

Expand Down Expand Up @@ -858,8 +868,13 @@ async def update_webservers(self, devices: bool) -> None:
async def update_zone(self, zone: Zone) -> None:
"""Update Airzone Cloud Zone from API."""
device_data = await self.api_get_device_status(zone)
if self.options.device_config:
device_config = await self.api_get_device_config(zone)
print(device_config)
else:
device_config: dict[str, Any] = {}

update = EntityUpdate(UpdateType.API_FULL, device_data)
update = EntityUpdate(UpdateType.API_FULL, device_config | device_data)

await zone.update(update)

Expand Down
1 change: 1 addition & 0 deletions aioairzone_cloud/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ConnectionOptions:

username: str
password: str
device_config: bool = False
websockets: bool = True


Expand Down

0 comments on commit d8b5cea

Please sign in to comment.