Skip to content

Commit

Permalink
Add toggle item code enum
Browse files Browse the repository at this point in the history
  • Loading branch information
natekspencer committed Feb 8, 2025
1 parent 68a5cea commit 2ae6005
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
5 changes: 4 additions & 1 deletion pybalboa/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
MessageType,
SettingsCode,
TemperatureUnit,
ToggleItemCode,
WiFiState,
)
from .exceptions import SpaConnectionError, SpaMessageError
Expand Down Expand Up @@ -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."""
Expand Down
17 changes: 9 additions & 8 deletions pybalboa/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
OffLowHighState,
OffLowMediumHighState,
OffOnState,
ToggleItemCode,
UnknownState,
)

Expand All @@ -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),
Expand Down
26 changes: 26 additions & 0 deletions pybalboa/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down

0 comments on commit 2ae6005

Please sign in to comment.