Skip to content

Commit

Permalink
Adds support for requesting defrost (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjaliaga authored Dec 30, 2023
1 parent 3f71ae0 commit a9c65b1
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
2 changes: 2 additions & 0 deletions aioaquarea/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
DeviceAction,
DeviceInfo,
DeviceStatus,
DeviceModeStatus,
ExtendedOperationMode,
OperationStatus,
QuietMode,
Expand Down Expand Up @@ -47,4 +48,5 @@
"Consumption",
"ConsumptionType",
"DataNotAvailableError",
"DeviceModeStatus",
)
23 changes: 21 additions & 2 deletions aioaquarea/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from .data import (
Device,
DeviceInfo,
DeviceModeStatus,
DeviceStatus,
DeviceZoneInfo,
DeviceZoneStatus,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}",
Expand Down Expand Up @@ -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)
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)
19 changes: 17 additions & 2 deletions aioaquarea/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.
"""
"""

@abstractmethod
async def request_defrost(self) -> None:
"""Request defrost"""

0 comments on commit a9c65b1

Please sign in to comment.