Skip to content

Commit

Permalink
Add IECO to device
Browse files Browse the repository at this point in the history
  • Loading branch information
mill1000 committed Aug 15, 2024
1 parent 5897a76 commit 9fe4f87
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions msmart/device/AC/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class RateSelect(MideaIntEnum):
(3 if s._breeze_mild else
(2 if s._breeze_away else 0))),
PropertyId.BREEZELESS: lambda s: s._breezeless,
PropertyId.IECO: lambda s: s._ieco_mode,
PropertyId.RATE_SELECT: lambda s: s._rate_select,
PropertyId.SWING_LR_ANGLE: lambda s: s._horizontal_swing_angle,
PropertyId.SWING_UD_ANGLE: lambda s: s._vertical_swing_angle
Expand Down Expand Up @@ -155,6 +156,8 @@ def __init__(self, ip: str, device_id: int, port: int, **kwargs) -> None:
self._breeze_mild = False
self._breezeless = False

self._ieco_mode = False

def _update_state(self, res: Response) -> None:
"""Update the local state from a device state response."""

Expand Down Expand Up @@ -229,6 +232,9 @@ def _update_state(self, res: Response) -> None:
if (value := res.get_property(PropertyId.BREEZELESS)) is not None:
self._breezeless = bool(value)

if (value := res.get_property(PropertyId.IECO)) is not None:
self._ieco_mode = bool(value)

elif isinstance(res, EnergyUsageResponse):
self._total_energy_usage = res.total_energy
self._current_energy_usage = res.current_energy
Expand Down Expand Up @@ -348,6 +354,9 @@ def _update_capabilities(self, res: CapabilitiesResponse) -> None:
if res.breezeless:
self._supported_properties.add(PropertyId.BREEZELESS)

if res.ieco_mode:
self._supported_properties.add(PropertyId.IECO)

async def _send_command_get_responses(self, command) -> List[Response]:
"""Send a command and return all valid responses."""

Expand Down Expand Up @@ -740,6 +749,19 @@ def eco_mode(self) -> Optional[bool]:
def eco_mode(self, enabled: bool) -> None:
self._eco_mode = enabled

@property
def supports_ieco_mode(self) -> bool:
return PropertyId.IECO in self._supported_properties

@property
def ieco_mode(self) -> Optional[bool]:
return self._ieco_mode

@ieco_mode.setter
def ieco_mode(self, enabled: bool) -> None:
self._ieco_mode = enabled
self._updated_properties.add(PropertyId.IECO)

@property
def supports_turbo_mode(self) -> Optional[bool]:
return self._supports_turbo_mode
Expand Down

0 comments on commit 9fe4f87

Please sign in to comment.