Skip to content

Commit

Permalink
Add support for Powerful time (#38)
Browse files Browse the repository at this point in the history
Co-authored-by: swolix<[email protected]>
  • Loading branch information
cjaliaga authored Jan 4, 2024
1 parent 84442aa commit 4f7fa2e
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
2 changes: 2 additions & 0 deletions aioaquarea/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
Tank,
UpdateOperationMode,
HolidayTimer,
PowerfulTime,
)
from .errors import (
ApiError,
Expand Down Expand Up @@ -53,4 +54,5 @@
"DeviceModeStatus",
"ForceHeater",
"HolidayTimer",
"PowerfulTime",
)
36 changes: 35 additions & 1 deletion aioaquarea/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
HolidayTimer,
OperationMode,
OperationStatus,
PowerfulTime,
QuietMode,
SensorMode,
Tank,
Expand Down Expand Up @@ -346,6 +347,7 @@ async def get_device_status(self, long_id: str) -> DeviceStatus:
force_dhw=ForceDHW(device.get("forceDHW", 0)),
force_heater=ForceHeater(device.get("forceHeater", 0)),
holiday_timer=HolidayTimer(device.get("holidayTimer", 0)),
powerful_time=PowerfulTime(device.get("powerful", 0)),
)

return device_status
Expand Down Expand Up @@ -604,6 +606,28 @@ async def post_device_request_defrost(self, long_id: str) -> None:
json=data,
)

@auth_required
async def post_device_set_powerful_time(
self, long_id: str, powerful_time: PowerfulTime
) -> None:
"""Post powerful time."""
data = {
"status": [
{
"deviceGuid": long_id,
"powerfulRequest": powerful_time.value,
}
]
}

response = await self.request(
"POST",
f"{AQUAREA_SERVICE_DEVICES}/{long_id}",
referer=AQUAREA_SERVICE_A2W_STATUS_DISPLAY,
content_type="application/json",
json=data,
)

async def get_device_consumption(
self, long_id: str, aggregation: DateType, date_input: str
) -> Consumption:
Expand Down Expand Up @@ -819,9 +843,19 @@ async def request_defrost(self) -> None:
await self._client.post_device_request_defrost(self.long_id)

async def set_holiday_timer(self, holiday_timer: HolidayTimer) -> None:
"""Enables or disables the holiday timer mode.
"""Enable or disable the holiday timer mode.
:param holiday_timer: The holiday timer option
"""
if self.holiday_timer is not holiday_timer:
await self._client.post_device_holiday_timer(self.long_id, holiday_timer)

async def set_powerful_time(self, powerful_time: PowerfulTime) -> None:
"""Set the powerful time.
:param powerful_time: Time to enable powerful mode
"""
if self.powerful_time is not powerful_time:
await self._client.post_device_set_powerful_time(
self.long_id, powerful_time
)
22 changes: 22 additions & 0 deletions aioaquarea/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ class DeviceModeStatus(IntEnum):
DEFROST = 1


class PowerfulTime(IntEnum):
"""Powerful time"""

OFF = 0
ON_30MIN = 1
ON_60MIN = 2
ON_90MIN = 3


@dataclass
class TankStatus:
"""Tank status"""
Expand Down Expand Up @@ -197,6 +206,7 @@ class DeviceStatus:
force_dhw: ForceDHW
force_heater: ForceHeater
holiday_timer: HolidayTimer
powerful_time: PowerfulTime


@dataclass
Expand Down Expand Up @@ -531,6 +541,11 @@ def holiday_timer(self) -> HolidayTimer:
"""Specifies if the holiday timer is enabled"""
return self._status.holiday_timer

@property
def powerful_time(self) -> PowerfulTime:
"""Specifies if the powerful time is enabled and for how long"""
return self._status.powerful_time

def support_cooling(self, zone_id: int = 1) -> bool:
"""True if the device supports cooling in the given zone"""
zone = self.zones.get(zone_id, None)
Expand Down Expand Up @@ -620,3 +635,10 @@ async def set_holiday_timer(self, holiday_timer: HolidayTimer) -> None:
:param holiday_timer: The holiday timer option
"""

@abstractmethod
async def set_powerful_time(self, powerful_time: PowerfulTime) -> None:
"""Set the powerful time.
:param powerful_time: Time to enable powerful mode
"""

0 comments on commit 4f7fa2e

Please sign in to comment.