Skip to content

Commit

Permalink
Fixes an issue where device direct was not honored on status refresh (#…
Browse files Browse the repository at this point in the history
…43)

This commit refactors the `Client` class and `DeviceImpl` class in the `core.py` file. The changes include:
- Replacing `data=urllib.parse.urlencode(params)` with `params=params` in the `Client` class.
- Adding type hints for the `zones` parameter in the `__set_special_status__` method of the `Client` class.
- Formatting the code for better readability
  • Loading branch information
cjaliaga authored Jan 23, 2024
1 parent 4fad5c2 commit ca986a9
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions aioaquarea/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ async def get_device_status(self, long_id: str) -> DeviceStatus:
"GET",
f"{AQUAREA_SERVICE_DEVICES}/{long_id}",
referer=self._base_url,
data=urllib.parse.urlencode(params),
params=params,
)
data = await response.json()

Expand Down Expand Up @@ -569,7 +569,7 @@ async def post_device_set_special_status(
self,
long_id: str,
special_status: SpecialStatus | None,
zones: list[ZoneTemperatureSetUpdate]
zones: list[ZoneTemperatureSetUpdate],
) -> None:
"""Post device operation update."""
data = {
Expand All @@ -581,7 +581,11 @@ async def post_device_set_special_status(
{
"zoneId": zone.zone_id,
"heatSet": zone.heat_set,
**({"coolSet": zone.cool_set} if zone.cool_set is not None else {})
**(
{"coolSet": zone.cool_set}
if zone.cool_set is not None
else {}
),
}
for zone in zones
],
Expand Down Expand Up @@ -964,10 +968,16 @@ async def set_powerful_time(self, powerful_time: PowerfulTime) -> None:
await self._client.post_device_set_powerful_time(
self.long_id, powerful_time
)

async def __set_special_status__(self, special_status: SpecialStatus | None, zones: list[ZoneTemperatureSetUpdate]) -> None:

async def __set_special_status__(
self,
special_status: SpecialStatus | None,
zones: list[ZoneTemperatureSetUpdate],
) -> None:
"""Set the special status.
:param special_status: Special status to set
:param zones: Zones to set the special status for
"""
await self._client.post_device_set_special_status(self.long_id, special_status, zones)
await self._client.post_device_set_special_status(
self.long_id, special_status, zones
)

0 comments on commit ca986a9

Please sign in to comment.