Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Commit

Permalink
feat: support smartmode params (#11)
Browse files Browse the repository at this point in the history
Co-authored-by: J. Nick Koston <[email protected]>
  • Loading branch information
barlock and bdraco authored Jan 13, 2022
1 parent 417a0a9 commit a0576f3
Showing 1 changed file with 39 additions and 5 deletions.
44 changes: 39 additions & 5 deletions aiosenseme/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@
SUPPRESS_CALLBACK_PARAMS = {"SLEEP;EVENT"}


def forceToRange(minv, maxv, val):
return min(maxv, max(minv, val))


class SensemeEndpoint:
"""High-level endpoint for SenseME protocol."""

Expand Down Expand Up @@ -1005,11 +1009,7 @@ def fan_speed(self) -> int | None:
@fan_speed.setter
def fan_speed(self, speed: int) -> None:
"""Set the fan speed."""
if speed < 0:
speed = 0
elif self.fan_speed_max is not None and speed > self.fan_speed_max:
speed = self.fan_speed_max
self._send_command(f"FAN;SPD;SET;{speed}")
self._send_command(f"FAN;SPD;SET;{forceToRange(0, self.fan_speed_max, speed)}")

@property
def fan_speed_min(self) -> int | None:
Expand Down Expand Up @@ -1122,6 +1122,20 @@ def fan_smartmode(self) -> str | None:
"""
return self._data.get("SMARTMODE;ACTUAL", None)

@fan_smartmode.setter
def fan_smartmode(self, mode: str):
"""Set the fan auto comfort mode.
'OFF' no automatic adjustment.
'COOLING' increases fan speed as temp increases.
'HEATING' means slow mixing of air while room is occupied and faster mix speeds
while room is not occupied.
'FOLLOWTSTAT' means change between 'COOLING' and 'HEATING based on thermostat.
"""
if mode not in AUTOCOMFORTS:
raise ValueError(f"Mode '{mode}' not supported")
self._send_command(f"SMARTMODE;STATE;SET;{mode}")

@property
def fan_cooltemp(self) -> float | None:
"""Return the auto shutoff temperature for 'COOLING' smart mode in Celsius."""
Expand All @@ -1141,6 +1155,26 @@ def fan_cooltemp(self, temp: float) -> None:
temp = int(round(temp * 100))
self._send_command(f"LEARN;ZEROTEMP;SET;{temp}")

@property
def fan_coolminspeed(self) -> int | None:
"""Return the min speed of smart cooling mode"""
return int(self._data.get("LEARN;MINSPEED", None))

@fan_coolminspeed.setter
def fan_coolminspeed(self, speed: int) -> None:
"""Set the min fan speed for 'COOLING' smart mode."""
self._send_command(f"LEARN;MINSPEED;SET;{forceToRange(0, 6, speed)}")

@property
def fan_coolmaxspeed(self) -> int | None:
"""Return the max speed of smart cooling mode"""
return int(self._data.get("LEARN;MAXSPEED", None))

@fan_coolmaxspeed.setter
def fan_coolmaxspeed(self, speed: int) -> None:
"""Set the max fan speed for 'COOLING' smart mode."""
self._send_command(f"LEARN;MAXSPEED;SET;{forceToRange(1, 7, speed)}")

@property
def motion_fan_auto(self) -> bool | None:
"""Return True when fan is in automatic on with motion mode."""
Expand Down

0 comments on commit a0576f3

Please sign in to comment.