diff --git a/switchbot/enums.py b/switchbot/enums.py new file mode 100644 index 0000000..f258794 --- /dev/null +++ b/switchbot/enums.py @@ -0,0 +1,18 @@ +from enum import Enum + +class AirConditionerMode(Enum): + AUTO = 1 + COOL = 2 + DRY = 3 + FAN = 4 + HEAT = 5 + +class AirConditionerFanSpeed(Enum): + AUTO = 1 + LOW = 2 + MEDIUM = 3 + HIGH = 4 + +class AirConditionerPowerState(Enum): + ON = "on" + OFF = "off" \ No newline at end of file diff --git a/switchbot/remotes.py b/switchbot/remotes.py index 5ac1145..05f0033 100644 --- a/switchbot/remotes.py +++ b/switchbot/remotes.py @@ -5,6 +5,7 @@ import humps from switchbot.client import SwitchBotClient +from switchbot.enums import AirConditionerMode, AirConditionerFanSpeed, AirConditionerPowerState class Remote: @@ -62,6 +63,13 @@ def turn(self, state: str): assert state in ("on", "off") self.command(f"turn_{state}") +class AirConditioner(SupportedRemote): + remote_type_for = "Air Conditioner" + + def set_all(self, temperature: int, mode: AirConditionerMode, fan_speed: AirConditionerFanSpeed, power_state: AirConditionerPowerState): + assert type(temperature) is int + self.command(action="setAll", parameter=f"{temperature},{mode.value},{fan_speed.value},{power_state.value}") + class OtherRemote(Remote): remote_type_for = "Others"