Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions pyomnilogic_local/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ async def async_get_filter_diagnostics(self, pool_id: int, equipment_id: int, ra

_LOGGER.debug("Sending GetUIFilterDiagnosticInfo with body: %s", req_body)

resp = await self.async_send_and_receive(MessageType.GET_FILTER_DIAGNOSTIC_INFO, req_body)
resp = await self.async_send_and_receive(MessageType.GET_FILTER_DIAGNOSTIC, req_body)

_LOGGER.debug("Received response for GetUIFilterDiagnosticInfo: %s", resp)

Expand Down Expand Up @@ -285,7 +285,7 @@ async def async_set_heater(

_LOGGER.debug("Sending SetUIHeaterCmd with body: %s", req_body)

return await self.async_send(MessageType.SET_HEATER_COMMAND, req_body)
return await self.async_send(MessageType.SET_HEATER, req_body)

async def async_set_solar_heater(
self,
Expand Down Expand Up @@ -320,7 +320,7 @@ async def async_set_solar_heater(

_LOGGER.debug("Sending SetUISolarSetPointCmd with body: %s", req_body)

return await self.async_send(MessageType.SET_SOLAR_SET_POINT_COMMAND, req_body)
return await self.async_send(MessageType.SET_SOLAR_SETPOINT, req_body)

async def async_set_heater_mode(
self,
Expand Down Expand Up @@ -355,7 +355,7 @@ async def async_set_heater_mode(

_LOGGER.debug("Sending SetUIHeaterModeCmd with body: %s", req_body)

return await self.async_send(MessageType.SET_HEATER_MODE_COMMAND, req_body)
return await self.async_send(MessageType.SET_HEATER_MODE, req_body)

async def async_set_heater_enable(
self,
Expand Down Expand Up @@ -390,7 +390,7 @@ async def async_set_heater_enable(

_LOGGER.debug("Sending SetHeaterEnable with body: %s", req_body)

return await self.async_send(MessageType.SET_HEATER_ENABLED, req_body)
return await self.async_send(MessageType.SET_HEATER_ENABLE, req_body)

async def async_set_equipment(
self,
Expand Down Expand Up @@ -552,7 +552,7 @@ async def async_set_light_show(

_LOGGER.debug("Sending SetStandAloneLightShow with body: %s", req_body)

return await self.async_send(MessageType.SET_STANDALONE_LIGHT_SHOW, req_body)
return await self.async_send(MessageType.SET_LIGHT_SHOW, req_body)

async def async_set_chlorinator_enable(self, pool_id: int, enabled: int | bool) -> None:
body_element = ET.Element("Request", {"xmlns": XML_NAMESPACE})
Expand All @@ -570,7 +570,7 @@ async def async_set_chlorinator_enable(self, pool_id: int, enabled: int | bool)

_LOGGER.debug("Sending SetCHLOREnable with body: %s", req_body)

return await self.async_send(MessageType.SET_CHLOR_ENABLED, req_body)
return await self.async_send(MessageType.SET_CHLOR_ENABLE, req_body)

# This is used to set the ORP target value on a CSAD
async def async_set_csad_orp_target_level(
Expand All @@ -596,7 +596,7 @@ async def async_set_csad_orp_target_level(

_LOGGER.debug("Sending SetUICSADORPTargetLevel with body: %s", req_body)

return await self.async_send(MessageType.SET_CSAD_ORP_TARGET, req_body)
return await self.async_send(MessageType.SET_CSAD_ORP_TARGET_LEVEL, req_body)

# This is used to set the pH target value on a CSAD
async def async_set_csad_ph_target_value(
Expand Down Expand Up @@ -665,7 +665,7 @@ async def async_set_chlorinator_params(

_LOGGER.debug("Sending SetCHLORParams with body: %s", req_body)

return await self.async_send(MessageType.SET_CHLOR_PARAMS, req_body)
return await self.async_send(MessageType.CHLOR_PARAMS_SET, req_body)

async def async_set_chlorinator_superchlorinate(
self,
Expand All @@ -690,7 +690,7 @@ async def async_set_chlorinator_superchlorinate(

_LOGGER.debug("Sending SetUISuperCHLORCmd with body: %s", req_body)

return await self.async_send(MessageType.SET_SUPERCHLORINATE, req_body)
return await self.async_send(MessageType.CHLOR_SUPER_CHLOR_SET, req_body)

async def async_restore_idle_state(self) -> None:
body_element = ET.Element("Request", {"xmlns": XML_NAMESPACE})
Expand Down Expand Up @@ -747,7 +747,7 @@ async def async_set_spillover(

_LOGGER.debug("Sending SetUISpilloverCmd with body: %s", req_body)

return await self.async_send(MessageType.SET_SPILLOVER, req_body)
return await self.async_send(MessageType.SET_SPILLOVER_CMD, req_body)

async def async_set_group_enable(
self,
Expand Down Expand Up @@ -790,7 +790,7 @@ async def async_set_group_enable(

_LOGGER.debug("Sending RunGroupCmd with body: %s", req_body)

return await self.async_send(MessageType.RUN_GROUP_CMD, req_body)
return await self.async_send(MessageType.RUN_GROUP, req_body)

async def async_edit_schedule(
self,
Expand Down Expand Up @@ -863,4 +863,4 @@ async def async_edit_schedule(

_LOGGER.debug("Sending EditUIScheduleCmd with body: %s", req_body)

return await self.async_send(MessageType.EDIT_SCHEDULE, req_body)
return await self.async_send(MessageType.EDIT_SCHEDULE_CMD, req_body)
4 changes: 2 additions & 2 deletions pyomnilogic_local/api/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

_ACK_PAYLOAD = f'<Request xmlns="{XML_NAMESPACE}">\n<Name>Ack</Name>\n</Request>'

_ACK_TYPES = frozenset({MessageType.ACK, MessageType.XML_ACK})
_ACK_TYPES = frozenset({MessageType.ACK, MessageType.MSP_ACK})

# Type alias for items placed on the receive queue: either a parsed message or a parse error.
_QueueItem = OmniLogicMessage | OmniMessageFormatError
Expand Down Expand Up @@ -110,7 +110,7 @@ def _send_xml_ack(self, msg_id: int) -> None:
if self._transport is None:
_LOGGER.warning("cannot send ACK for ID %d, transport unavailable", msg_id)
return
ack = OmniLogicMessage(msg_id=msg_id, msg_type=MessageType.XML_ACK, payload=_ACK_PAYLOAD)
ack = OmniLogicMessage(msg_id=msg_id, msg_type=MessageType.ACK, payload=_ACK_PAYLOAD)
self._transport.sendto(bytes(ack))
_LOGGER.debug("sent XML_ACK for message ID %d", msg_id)

Expand Down
19 changes: 12 additions & 7 deletions pyomnilogic_local/chlorinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@
from pyomnilogic_local.decorators import control_method
from pyomnilogic_local.models.mspconfig import MSPChlorinator
from pyomnilogic_local.models.telemetry import TelemetryChlorinator
from pyomnilogic_local.omnitypes import ChlorinatorMSPConfigMode, ChlorinatorStatus
from pyomnilogic_local.omnitypes import ChlorinatorMode, ChlorinatorStatus
from pyomnilogic_local.util import OmniEquipmentNotInitializedError

if TYPE_CHECKING:
from pyomnilogic_local.models.telemetry import Telemetry
from pyomnilogic_local.omnilogic import OmniLogic
from pyomnilogic_local.omnitypes import ChlorinatorCellType, ChlorinatorDispenserType, ChlorinatorOperatingMode
from pyomnilogic_local.omnitypes import (
ChlorinatorCellType,
ChlorinatorDispenserType,
ChlorinatorOperatingMode,
ChlorinatorOperatingState,
)


class Chlorinator(OmniEquipment[MSPChlorinator, TelemetryChlorinator]):
Expand Down Expand Up @@ -94,12 +99,12 @@ def cell_type(self) -> ChlorinatorCellType:

# Expose Telemetry attributes
@property
def operating_state(self) -> int:
def operating_state(self) -> ChlorinatorOperatingState:
"""Current operational state of the chlorinator (raw value)."""
return self.telemetry.operating_state

@property
def mode(self) -> ChlorinatorMSPConfigMode:
def mode(self) -> ChlorinatorMode:
"""Current operating mode from MSP Config (NOT_CONFIGURED, TIMED, ORP_AUTO).

TThis data appears to have some discrepancies with the mode reported in the Telemetry.
Expand Down Expand Up @@ -421,7 +426,7 @@ async def set_timed_percent(self, percent: int) -> None:
)

@control_method
async def set_op_mode(self, op_mode: ChlorinatorMSPConfigMode) -> None:
async def set_op_mode(self, op_mode: ChlorinatorMode) -> None:
"""Set the operating mode for chlorine generation.

Args:
Expand Down Expand Up @@ -453,9 +458,9 @@ async def set_op_mode(self, op_mode: ChlorinatorMSPConfigMode) -> None:

new_op_mode: int
match op_mode:
case ChlorinatorMSPConfigMode.TIMED:
case ChlorinatorMode.TIMED:
new_op_mode = 1
case ChlorinatorMSPConfigMode.ORP_AUTO:
case ChlorinatorMode.ORP_AUTO:
new_op_mode = 2
case _:
msg = f"Unsupported operating mode: {op_mode}"
Expand Down
12 changes: 6 additions & 6 deletions pyomnilogic_local/colorlogiclight.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
if TYPE_CHECKING:
from pyomnilogic_local.models.telemetry import Telemetry
from pyomnilogic_local.omnilogic import OmniLogic
from pyomnilogic_local.omnitypes import LightShows
from pyomnilogic_local.omnitypes import ColorLogicSpecialEffect, LightShows

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -197,7 +197,7 @@ def brightness(self) -> ColorLogicBrightness:
return ColorLogicBrightness.ONE_HUNDRED_PERCENT

@property
def special_effect(self) -> int:
def special_effect(self) -> ColorLogicSpecialEffect:
"""Returns the current special effect."""
return self.telemetry.special_effect

Expand All @@ -222,10 +222,10 @@ def is_ready(self) -> bool:

# Then check light-specific readiness
return self.state not in [
ColorLogicPowerState.FIFTEEN_SECONDS_WHITE,
ColorLogicPowerState.CHANGING_SHOW,
ColorLogicPowerState.POWERING_OFF,
ColorLogicPowerState.COOLDOWN,
ColorLogicPowerState.STARTING_APP,
ColorLogicPowerState.SHOW_ADVANCE,
ColorLogicPowerState.WAIT_POWER_DOWN,
ColorLogicPowerState.POWER_DOWN,
]

@control_method
Expand Down
6 changes: 3 additions & 3 deletions pyomnilogic_local/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ def is_on(self) -> bool:
FilterState.PRIMING,
FilterState.HEATER_EXTEND,
FilterState.CSAD_EXTEND,
FilterState.FILTER_FORCE_PRIMING,
FilterState.FILTER_SUPERCHLORINATE,
FilterState.FORCE_PRIMING,
FilterState.SUPERCHLORINATE,
)

@property
Expand All @@ -203,7 +203,7 @@ def is_ready(self) -> bool:
# We need to consider the filter as ready in this state, otherwise we cannot control the
# virtual filter to switch the physical filter back BoW
# ref: https://github.com/cryptk/python-omnilogic-local/issues/100
return self.state in (FilterState.OFF, FilterState.ON, FilterState.SUSPEND)
return self.state in (FilterState.OFF, FilterState.ON, FilterState.SUSPENDED)

# Control methods
@control_method
Expand Down
4 changes: 2 additions & 2 deletions pyomnilogic_local/heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
if TYPE_CHECKING:
from pyomnilogic_local.models.telemetry import Telemetry
from pyomnilogic_local.omnilogic import OmniLogic
from pyomnilogic_local.omnitypes import HeaterMode
from pyomnilogic_local.omnitypes import HeaterMode, HeaterWhyOn


class Heater(OmniEquipment[MSPVirtualHeater, TelemetryVirtualHeater]):
Expand Down Expand Up @@ -173,7 +173,7 @@ def silent_mode(self) -> int:
return self.telemetry.silent_mode

@property
def why_on(self) -> int:
def why_on(self) -> HeaterWhyOn:
"""Returns the reason why the heater is on from telemetry.

We don't have a good understanding of what these values mean yet
Expand Down
6 changes: 3 additions & 3 deletions pyomnilogic_local/models/mspconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
BodyOfWaterType,
ChlorinatorCellType,
ChlorinatorDispenserType,
ChlorinatorMSPConfigMode,
ChlorinatorMode,
ChlorinatorType,
ColorLogicLightType,
ColorLogicShow25,
Expand Down Expand Up @@ -218,7 +218,7 @@ class MSPChlorinator(OmniBase):
omni_type: OmniType = OmniType.CHLORINATOR

enabled: bool = Field(alias="Enabled")
mode: ChlorinatorMSPConfigMode = Field(alias="Mode")
mode: ChlorinatorMode = Field(alias="Mode")
timed_percent: int = Field(alias="Timed-Percent")
superchlor_timeout: int = Field(alias="SuperChlor-Timeout")
orp_timeout: int = Field(alias="ORP-Timeout")
Expand Down Expand Up @@ -377,7 +377,7 @@ class MSPSchedule(OmniBase):
bow_id: int = Field(alias="bow-system-id") # pyright: ignore[reportGeneralTypeIssues]
equipment_id: int = Field(alias="equipment-id")
system_id: int = Field(alias="schedule-system-id")
event: MessageType = Field(alias="event")
event: MessageType | int = Field(alias="event")
data: int = Field(alias="data")
enabled: bool = Field()
start_minute: int = Field(alias="start-minute")
Expand Down
12 changes: 8 additions & 4 deletions pyomnilogic_local/models/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
ChlorinatorAlert,
ChlorinatorError,
ChlorinatorOperatingMode,
ChlorinatorOperatingState,
ChlorinatorStatus,
ColorLogicBrightness,
ColorLogicLightType,
Expand All @@ -19,6 +20,7 @@
ColorLogicShow40,
ColorLogicShowUCL,
ColorLogicShowUCLV2,
ColorLogicSpecialEffect,
ColorLogicSpeed,
CSADMode,
CSADStatus,
Expand All @@ -28,10 +30,12 @@
GroupState,
HeaterMode,
HeaterState,
HeaterWhyOn,
LightShows,
OmniType,
PentairShow,
PumpState,
PumpWhyOn,
RelayState,
RelayWhyOn,
ValveActuatorState,
Expand Down Expand Up @@ -127,7 +131,7 @@
chlr_alert_raw: int = Field(alias="@chlrAlert")
chlr_error_raw: int = Field(alias="@chlrError")
sc_mode: int = Field(alias="@scMode")
operating_state: int = Field(alias="@operatingState")
operating_state: ChlorinatorOperatingState = Field(alias="@operatingState")
timed_percent: int | None = Field(alias="@Timed-Percent", default=None)
operating_mode: ChlorinatorOperatingMode = Field(alias="@operatingMode")
enable: bool = Field(alias="@enable")
Expand Down Expand Up @@ -263,7 +267,7 @@
show: LightShows = Field(alias="@currentShow")
speed: ColorLogicSpeed = Field(alias="@speed")
brightness: ColorLogicBrightness = Field(alias="@brightness")
special_effect: int = Field(alias="@specialEffect")
special_effect: ColorLogicSpecialEffect = Field(alias="@specialEffect")

def show_name(
self, model: ColorLogicLightType, v2: bool
Expand Down Expand Up @@ -381,7 +385,7 @@
state: PumpState = Field(alias="@pumpState")
speed: int = Field(alias="@pumpSpeed")
last_speed: int = Field(alias="@lastSpeed")
why_on: int = Field(alias="@whyOn")
why_on: PumpWhyOn = Field(alias="@whyOn")

Check failure on line 388 in pyomnilogic_local/models/telemetry.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "@whyOn" 3 times.

See more on https://sonarcloud.io/project/issues?id=cryptk_python-omnilogic-local&issues=AZ5wFTqeP-QaTlUpUiop&open=AZ5wFTqeP-QaTlUpUiop&pullRequest=148


class TelemetryRelay(BaseModel):
Expand Down Expand Up @@ -447,7 +451,7 @@
solar_set_point: int = Field(alias="@SolarSetPoint")
mode: HeaterMode = Field(alias="@Mode")
silent_mode: int = Field(alias="@SilentMode")
why_on: int = Field(alias="@whyHeaterIsOn")
why_on: HeaterWhyOn = Field(alias="@whyHeaterIsOn")


type TelemetryType = (
Expand Down
Loading
Loading