diff --git a/aioaquarea/__init__.py b/aioaquarea/__init__.py index f8a7460..df2d4ad 100644 --- a/aioaquarea/__init__.py +++ b/aioaquarea/__init__.py @@ -9,6 +9,7 @@ DeviceAction, DeviceInfo, DeviceStatus, + DeviceModeStatus, ExtendedOperationMode, OperationStatus, QuietMode, @@ -47,4 +48,5 @@ "Consumption", "ConsumptionType", "DataNotAvailableError", + "DeviceModeStatus", ) \ No newline at end of file diff --git a/aioaquarea/core.py b/aioaquarea/core.py index 2fc6379..c054d25 100644 --- a/aioaquarea/core.py +++ b/aioaquarea/core.py @@ -21,6 +21,7 @@ from .data import ( Device, DeviceInfo, + DeviceModeStatus, DeviceStatus, DeviceZoneInfo, DeviceZoneStatus, @@ -304,7 +305,7 @@ async def get_device_status(self, long_id: str) -> DeviceStatus: device_status = DeviceStatus( long_id, OperationStatus(device.get("operationStatus")), - OperationStatus(device.get("deiceStatus")), + DeviceModeStatus(device.get("deiceStatus")), device.get("outdoorNow"), ExtendedOperationMode.OFF if operation_mode_value == 99 @@ -546,6 +547,19 @@ async def post_force_dhw(self, long_id: str, force_dhw: ForceDHW) -> None: """Post quiet mode""" data = {"status": [{"deviceGuid": long_id, "forceDHW": force_dhw.value}]} + response = await self.request( + "POST", + f"{AQUAREA_SERVICE_DEVICES}/{long_id}", + referer=AQUAREA_SERVICE_A2W_STATUS_DISPLAY, + content_type="application/json", + json=data, + ) + + @auth_required + async def post_request_defrost(self, long_id: str) -> None: + """Post quiet mode""" + data = {"status": [{"deviceGuid": long_id, "forcedefrost": 1}]} + response = await self.request( "POST", f"{AQUAREA_SERVICE_DEVICES}/{long_id}", @@ -748,4 +762,9 @@ async def set_force_dhw(self, force_dhw: ForceDHW) -> None: if not self.has_tank: return - await self._client.post_force_dhw(self.long_id, force_dhw) \ No newline at end of file + await self._client.post_force_dhw(self.long_id, force_dhw) + + async def request_defrost(self) -> None: + """Request defrost""" + if self.device_mode_status is not DeviceModeStatus.DEFROST: + await self._client.post_request_defrost(self.long_id) diff --git a/aioaquarea/data.py b/aioaquarea/data.py index 1a28cb8..a6e735f 100644 --- a/aioaquarea/data.py +++ b/aioaquarea/data.py @@ -97,6 +97,12 @@ class ForceDHW(IntEnum): OFF = 0 ON = 1 +class DeviceModeStatus(IntEnum): + """Device mode status""" + + NORMAL = 0 + DEFROST = 1 + @dataclass class TankStatus: """Tank status""" @@ -161,7 +167,7 @@ class DeviceStatus: long_id: str operation_status: OperationStatus - device_status: OperationStatus + device_status: DeviceModeStatus temperature_outdoor: int operation_mode: ExtendedOperationMode fault_status: list[FaultError] @@ -490,6 +496,11 @@ def force_dhw(self) -> ForceDHW: """The force DHW of the device""" return self._status.force_dhw + @property + def device_mode_status(self) -> DeviceModeStatus: + """The mode of the device""" + return self._status.device_status + 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) @@ -561,4 +572,8 @@ def get_or_schedule_consumption( async def set_force_dhw(self, force_dhw: ForceDHW) -> None: """Set the force dhw. :param force_dhw: Set the Force DHW mode if the device has a tank. - """ \ No newline at end of file + """ + + @abstractmethod + async def request_defrost(self) -> None: + """Request defrost""" \ No newline at end of file