From 2ae600530c5f1e2cd53e9adabc085958ffb4b499 Mon Sep 17 00:00:00 2001 From: Nathan Spencer Date: Sat, 8 Feb 2025 15:25:47 -0700 Subject: [PATCH] Add toggle item code enum --- pybalboa/client.py | 5 ++++- pybalboa/control.py | 17 +++++++++-------- pybalboa/enums.py | 26 ++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/pybalboa/client.py b/pybalboa/client.py index e201efa..30ad3db 100644 --- a/pybalboa/client.py +++ b/pybalboa/client.py @@ -18,6 +18,7 @@ MessageType, SettingsCode, TemperatureUnit, + ToggleItemCode, WiFiState, ) from .exceptions import SpaConnectionError, SpaMessageError @@ -1011,7 +1012,9 @@ async def set_temperature_range(self, temperature_range: LowHighRange) -> None: """Set the temperature range.""" if self._temperature_range == temperature_range: return - await self.send_message(MessageType.TOGGLE_STATE, 0x50) + await self.send_message( + MessageType.TOGGLE_STATE, ToggleItemCode.TEMPERATURE_RANGE + ) async def set_temperature_unit(self, unit: TemperatureUnit) -> None: """Set the temperature unit.""" diff --git a/pybalboa/control.py b/pybalboa/control.py index 1037eea..a1c13c9 100644 --- a/pybalboa/control.py +++ b/pybalboa/control.py @@ -16,6 +16,7 @@ OffLowHighState, OffLowMediumHighState, OffOnState, + ToggleItemCode, UnknownState, ) @@ -26,14 +27,14 @@ CONTROL_TYPE_MAP = { - ControlType.PUMP: 0x04, - ControlType.BLOWER: 0x0C, - ControlType.MISTER: 0x0E, - ControlType.LIGHT: 0x11, - ControlType.AUX: 0x16, - ControlType.CIRCULATION_PUMP: 0x3D, - ControlType.TEMPERATURE_RANGE: 0x50, - ControlType.HEAT_MODE: 0x51, + ControlType.PUMP: ToggleItemCode.PUMP_1, + ControlType.BLOWER: ToggleItemCode.BLOWER, + ControlType.MISTER: ToggleItemCode.MISTER, + ControlType.LIGHT: ToggleItemCode.LIGHT_1, + ControlType.AUX: ToggleItemCode.AUX_1, + ControlType.CIRCULATION_PUMP: ToggleItemCode.CIRCULATION_PUMP, + ControlType.TEMPERATURE_RANGE: ToggleItemCode.TEMPERATURE_RANGE, + ControlType.HEAT_MODE: ToggleItemCode.HEAT_MODE, } STATE_OPTIONS_MAP: dict[int, list[IntEnum]] = { 2: list(OffOnState), diff --git a/pybalboa/enums.py b/pybalboa/enums.py index e4e4843..8c9f355 100644 --- a/pybalboa/enums.py +++ b/pybalboa/enums.py @@ -85,6 +85,32 @@ class TemperatureUnit(IntEnum): CELSIUS = 1 +class ToggleItemCode(IntEnum): + """Toggle item code.""" + + NORMAL_OPERATION = 0x01 + CLEAR_NOTIFICATION = 0x03 + PUMP_1 = 0x04 + PUMP_2 = 0x05 + PUMP_3 = 0x06 + PUMP_4 = 0x07 + PUMP_5 = 0x08 + PUMP_6 = 0x09 + BLOWER = 0x0C + MISTER = 0x0E + LIGHT_1 = 0x11 + LIGHT_2 = 0x12 + LIGHT_3 = 0x13 + LIGHT_4 = 0x14 + AUX_1 = 0x16 + AUX_2 = 0x17 + SOAK_MODE = 0x1D + HOLD_MODE = 0x3C + CIRCULATION_PUMP = 0x3D + TEMPERATURE_RANGE = 0x50 + HEAT_MODE = 0x51 + + class WiFiState(IntEnum): """Wi-Fi state."""