Skip to content

Commit

Permalink
feat: add restore idle state API call, ref #2 (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptk committed Jun 22, 2023
1 parent 8c8ca6d commit 0a46fa2
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
12 changes: 12 additions & 0 deletions pyomnilogic_local/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,3 +489,15 @@ async def async_set_chlorinator_superchlorinate(self, pool_id: int, equipment_id
req_body = ET.tostring(body_element, xml_declaration=True, encoding="unicode")

return await self.async_send_message(MessageType.SET_SUPERCHLORINATE, req_body, False)

async def async_restore_idle_state(self) -> None:
body_element = ET.Element("Request", {"xmlns": "http://nextgen.hayward.com/api"})

name_element = ET.SubElement(body_element, "Name")
name_element.text = "RestoreIdleState"

ET.SubElement(body_element, "Parameters")

req_body = ET.tostring(body_element, xml_declaration=True, encoding="unicode")

return await self.async_send_message(MessageType.SET_SUPERCHLORINATE, req_body, False)
9 changes: 7 additions & 2 deletions pyomnilogic_local/models/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,22 @@ class TelemetryBoW(BaseModel):
class TelemetryChlorinator(BaseModel):
omni_type: OmniType = OmniType.CHLORINATOR
system_id: int = Field(alias="@systemId")
status: int = Field(alias="@status")
status_raw: int = Field(alias="@status")
instant_salt_level: int = Field(alias="@instantSaltLevel")
avg_salt_level: int = Field(alias="@avgSaltLevel")
chlr_alert: int = Field(alias="@chlrAlert")
chlr_error: int = Field(alias="@chlrError")
sc_mode: int = Field(alias="@scMode")
operating_state: int = Field(alias="@operatingState")
timed_percent: int = Field(alias="@Timed-Percent")
timed_percent: int | None = Field(alias="@Timed-Percent")
operating_mode: ChlorinatorOperatingMode | int = Field(alias="@operatingMode")
enable: bool = Field(alias="@enable")

# Still need to do a bit more work to determine if a chlorinator is actively chlorinating
# @property
# def active(self) -> bool:
# return self.status_raw & 4 == 4 # Check if bit 4 is set, which means the chlorinator is currently chlorinating


class TelemetryColorLogicLight(BaseModel):
omni_type: OmniType = OmniType.CL_LIGHT
Expand Down
26 changes: 24 additions & 2 deletions pyomnilogic_local/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class OmniType(str, Enum):
VIRT_HEATER = "VirtualHeater"


# Backyard/BoW
class BackyardState(PrettyEnum):
OFF = 0
ON = 1
Expand All @@ -79,6 +80,7 @@ class BodyOfWaterType(str, PrettyEnum):
SPA = "BOW_SPA"


# Chlorinators
# Chlorinator status is a bitmask that we still need to figure out
# class ChlorinatorStatus(str,Enum):
# pass
Expand All @@ -91,6 +93,7 @@ class ChlorinatorDispenserType(str, PrettyEnum):
SALT = "SALT_DISPENSING"


# Lights
class ColorLogicSpeed(PrettyEnum):
ONE_SIXTEENTH = 0
ONE_EIGHTH = 1
Expand Down Expand Up @@ -157,6 +160,7 @@ class ColorLogicLightType(str, PrettyEnum):
TWO_FIVE = "COLOR_LOGIC_2_5"


# Chemistry Sense and Dispense
class CSADStatus(PrettyEnum):
NOT_DISPENSING = 0
DISPENSING = 1
Expand All @@ -170,6 +174,7 @@ class CSADMode(PrettyEnum):
DISPENSING_OFF = 4


# Filters
class FilterState(PrettyEnum):
OFF = 0
ON = 1
Expand Down Expand Up @@ -218,6 +223,7 @@ class FilterWhyOn(PrettyEnum):
FREEZE_PROTECT = 15


# Heaters
class HeaterState(PrettyEnum):
OFF = 0
ON = 1
Expand All @@ -239,23 +245,36 @@ class HeaterMode(PrettyEnum):
AUTO = 2


# Pumps
class PumpState(PrettyEnum):
OFF = 0
ON = 1


class PumpType(str, PrettyEnum):
SINGLE_SPEED = "PMP_SINGLE_SPEED"
DUAL_SPEED = "PMP_DUAL_SPEED"
VARIABLE_SPEED = "PMP_VARIABLE_SPEED_PUMP"


class PumpFunction(str, PrettyEnum):
PUMP = "PMP_PUMP"
WATER_FEATURE = "PMP_WATER_FEATURE"
CLEANER = "PMP_CLEANER"
WATER_SLIDE = "PMP_WATER_SLIDE"
WATERFALL = "PMP_WATERFALL"
BLOWER = "PMP_BLOWER"
LAMINARS = "PMP_LAMINARS"
FOUNTAIN = "PMP_FOUNTAIN"
JETS = "PMP_JETS"
CLEANER = "PMP_CLEANER"
BLOWER = "PMP_BLOWER"
ACCESSORY = "PMP_ACCESSORY"
CLEANER_PRESSURE = "PMP_CLEANER_PRESSURE"
CLEANER_SUCTION = "PMP_CLEANER_SUCTION"
CLEANER_ROBOTIC = "PMP_CLEANER_ROBOTIC"
CLEANER_IN_FLOOR = "PMP_CLEANER_IN_FLOOR"


# Relays
class RelayFunction(str, PrettyEnum):
WATER_FEATURE = "RLY_WATER_FEATURE"
LIGHT = "RLY_LIGHT"
Expand Down Expand Up @@ -287,11 +306,13 @@ class RelayType(str, PrettyEnum):
LOW_VOLTAGE = "RLY_LOW_VOLTAGE_RELAY"


# Sensors
class SensorType(str, PrettyEnum):
AIR_TEMP = "SENSOR_AIR_TEMP"
SOLAR_TEMP = "SENSOR_SOLAR_TEMP"
WATER_TEMP = "SENSOR_WATER_TEMP"
FLOW = "SENSOR_FLOW"
ORP = "SENSOR_ORP"
EXT_INPUT = "SENSOR_EXT_INPUT"


Expand All @@ -305,6 +326,7 @@ class SensorUnits(str, PrettyEnum):
ACTIVE_INACTIVE = "UNITS_ACTIVE_INACTIVE"


# Valve Actuators
class ValveActuatorState(PrettyEnum):
OFF = 0
ON = 1

0 comments on commit 0a46fa2

Please sign in to comment.