1- # pylint: disable=too-many-positional-arguments
21from __future__ import annotations
32
43import asyncio
54import logging
65import xml .etree .ElementTree as ET
7- from typing import Literal , overload
6+ from typing import TYPE_CHECKING , Literal , overload
87
98from pyomnilogic_local .models .filter_diagnostics import FilterDiagnostics
109from pyomnilogic_local .models .mspconfig import MSPConfig
1110from pyomnilogic_local .models .telemetry import Telemetry
12-
13- from ..omnitypes import (
11+ from pyomnilogic_local .omnitypes import (
1412 ColorLogicBrightness ,
1513 ColorLogicSpeed ,
16- HeaterMode ,
17- LightShows ,
1814 MessageType ,
1915)
16+
2017from .constants import (
2118 DEFAULT_CONTROLLER_PORT ,
2219 DEFAULT_RESPONSE_TIMEOUT ,
2724 XML_ENCODING ,
2825 XML_NAMESPACE ,
2926)
30- from .exceptions import OmniValidationException
27+ from .exceptions import OmniValidationError
3128from .protocol import OmniLogicProtocol
3229
30+ if TYPE_CHECKING :
31+ from pyomnilogic_local .omnitypes import HeaterMode , LightShows
32+
3333_LOGGER = logging .getLogger (__name__ )
3434
3535
@@ -44,9 +44,11 @@ def _validate_temperature(temperature: int, param_name: str = "temperature") ->
4444 OmniValidationException: If temperature is out of range.
4545 """
4646 if not isinstance (temperature , int ):
47- raise OmniValidationException (f"{ param_name } must be an integer, got { type (temperature ).__name__ } " )
47+ msg = f"{ param_name } must be an integer, got { type (temperature ).__name__ } "
48+ raise OmniValidationError (msg )
4849 if not MIN_TEMPERATURE_F <= temperature <= MAX_TEMPERATURE_F :
49- raise OmniValidationException (f"{ param_name } must be between { MIN_TEMPERATURE_F } °F and { MAX_TEMPERATURE_F } °F, got { temperature } °F" )
50+ msg = f"{ param_name } must be between { MIN_TEMPERATURE_F } °F and { MAX_TEMPERATURE_F } °F, got { temperature } °F"
51+ raise OmniValidationError (msg )
5052
5153
5254def _validate_speed (speed : int , param_name : str = "speed" ) -> None :
@@ -60,9 +62,11 @@ def _validate_speed(speed: int, param_name: str = "speed") -> None:
6062 OmniValidationException: If speed is out of range.
6163 """
6264 if not isinstance (speed , int ):
63- raise OmniValidationException (f"{ param_name } must be an integer, got { type (speed ).__name__ } " )
65+ msg = f"{ param_name } must be an integer, got { type (speed ).__name__ } "
66+ raise OmniValidationError (msg )
6467 if not MIN_SPEED_PERCENT <= speed <= MAX_SPEED_PERCENT :
65- raise OmniValidationException (f"{ param_name } must be between { MIN_SPEED_PERCENT } and { MAX_SPEED_PERCENT } , got { speed } " )
68+ msg = f"{ param_name } must be between { MIN_SPEED_PERCENT } and { MAX_SPEED_PERCENT } , got { speed } "
69+ raise OmniValidationError (msg )
6670
6771
6872def _validate_id (id_value : int , param_name : str ) -> None :
@@ -76,9 +80,11 @@ def _validate_id(id_value: int, param_name: str) -> None:
7680 OmniValidationException: If ID is invalid.
7781 """
7882 if not isinstance (id_value , int ):
79- raise OmniValidationException (f"{ param_name } must be an integer, got { type (id_value ).__name__ } " )
83+ msg = f"{ param_name } must be an integer, got { type (id_value ).__name__ } "
84+ raise OmniValidationError (msg )
8085 if id_value < 0 :
81- raise OmniValidationException (f"{ param_name } must be non-negative, got { id_value } " )
86+ msg = f"{ param_name } must be non-negative, got { id_value } "
87+ raise OmniValidationError (msg )
8288
8389
8490class OmniLogicAPI :
@@ -96,11 +102,14 @@ def __init__(
96102 OmniValidationException: If parameters are invalid.
97103 """
98104 if not controller_ip :
99- raise OmniValidationException ("controller_ip cannot be empty" )
105+ msg = "controller_ip cannot be empty"
106+ raise OmniValidationError (msg )
100107 if not isinstance (controller_port , int ) or controller_port <= 0 or controller_port > 65535 :
101- raise OmniValidationException (f"controller_port must be between 1 and 65535, got { controller_port } " )
108+ msg = f"controller_port must be between 1 and 65535, got { controller_port } "
109+ raise OmniValidationError (msg )
102110 if not isinstance (response_timeout , (int , float )) or response_timeout <= 0 :
103- raise OmniValidationException (f"response_timeout must be positive, got { response_timeout } " )
111+ msg = f"response_timeout must be positive, got { response_timeout } "
112+ raise OmniValidationError (msg )
104113
105114 self .controller_ip = controller_ip
106115 self .controller_port = controller_port
@@ -179,6 +188,7 @@ async def async_get_filter_diagnostics(self, pool_id: int, equipment_id: int, ra
179188 Args:
180189 pool_id (int): The Pool/BodyOfWater ID that you want to address
181190 equipment_id (int): Which equipment_id within that Pool to address
191+ raw (bool): Do not parse the response into a Pydantic model, just return the raw XML. Defaults to False.
182192
183193 Returns:
184194 FilterDiagnostics|str: Either a parsed .models.mspconfig.FilterDiagnostics object or a str depending on arg raw
@@ -233,7 +243,7 @@ async def async_set_heater(
233243 equipment_id : int ,
234244 temperature : int ,
235245 ) -> None :
236- """Set the temperature for a heater on the Omni
246+ """Set the temperature for a heater on the Omni.
237247
238248 Args:
239249 pool_id (int): The Pool/BodyOfWater ID that you want to address
@@ -332,7 +342,7 @@ async def async_set_heater_enable(
332342 equipment_id : int ,
333343 enabled : int | bool ,
334344 ) -> None :
335- """async_set_heater_enable handles sending a SetHeaterEnable XML API call to the Hayward Omni pool controller
345+ """Send a SetHeaterEnable XML API call to the Hayward Omni pool controller.
336346
337347 Args:
338348 pool_id (int): The Pool/BodyOfWater ID that you want to address
@@ -381,11 +391,11 @@ async def async_set_equipment(
381391 For Variable Speed Pumps, you can optionally provide an int from 0-100 to set the speed percentage with 0 being Off.
382392 The interpretation of value depends on the piece of equipment being targeted.
383393 is_countdown_timer (bool, optional): For potential future use, included to be "API complete". Defaults to False.
384- startTimeHours (int, optional): For potential future use, included to be "API complete". Defaults to 0.
385- startTimeMinutes (int, optional): For potential future use, included to be "API complete". Defaults to 0.
386- endTimeHours (int, optional): For potential future use, included to be "API complete". Defaults to 0.
387- endTimeMinutes (int, optional): For potential future use, included to be "API complete". Defaults to 0.
388- daysActive (int, optional): For potential future use, included to be "API complete". Defaults to 0.
394+ start_time_hours (int, optional): For potential future use, included to be "API complete". Defaults to 0.
395+ start_time_minutes (int, optional): For potential future use, included to be "API complete". Defaults to 0.
396+ end_time_hours (int, optional): For potential future use, included to be "API complete". Defaults to 0.
397+ end_time_minutes (int, optional): For potential future use, included to be "API complete". Defaults to 0.
398+ days_active (int, optional): For potential future use, included to be "API complete". Defaults to 0.
389399 recurring (bool, optional): For potential future use, included to be "API complete". Defaults to False.
390400 """
391401 body_element = ET .Element ("Request" , {"xmlns" : XML_NAMESPACE })
0 commit comments