1 """Support for AquaLogic switches."""
3 from __future__
import annotations
7 from aqualogic.core
import States
8 import voluptuous
as vol
11 PLATFORM_SCHEMA
as SWITCH_PLATFORM_SCHEMA,
21 from .
import DOMAIN, UPDATE_TOPIC, AquaLogicProcessor
26 "filter_low_speed":
"Filter Low Speed",
36 PLATFORM_SCHEMA = SWITCH_PLATFORM_SCHEMA.extend(
38 vol.Optional(CONF_MONITORED_CONDITIONS, default=
list(SWITCH_TYPES)): vol.All(
39 cv.ensure_list, [vol.In(SWITCH_TYPES)]
48 async_add_entities: AddEntitiesCallback,
49 discovery_info: DiscoveryInfoType |
None =
None,
51 """Set up the switch platform."""
52 processor: AquaLogicProcessor = hass.data[DOMAIN]
56 for switch_type
in config[CONF_MONITORED_CONDITIONS]
61 """Switch implementation for the AquaLogic component."""
63 _attr_should_poll =
False
65 def __init__(self, processor: AquaLogicProcessor, switch_type: str) ->
None:
66 """Initialize switch."""
69 "lights": States.LIGHTS,
70 "filter": States.FILTER,
71 "filter_low_speed": States.FILTER_LOW_SPEED,
72 "aux_1": States.AUX_1,
73 "aux_2": States.AUX_2,
74 "aux_3": States.AUX_3,
75 "aux_4": States.AUX_4,
76 "aux_5": States.AUX_5,
77 "aux_6": States.AUX_6,
78 "aux_7": States.AUX_7,
80 self.
_attr_name_attr_name = f
"AquaLogic {SWITCH_TYPES[switch_type]}"
84 """Return true if device is on."""
85 if (panel := self.
_processor_processor.panel)
is None:
90 """Turn the device on."""
91 if (panel := self.
_processor_processor.panel)
is None:
96 """Turn the device off."""
97 if (panel := self.
_processor_processor.panel)
is None:
102 """Register callbacks."""
None turn_on(self, **Any kwargs)
None async_added_to_hass(self)
None turn_off(self, **Any kwargs)
None __init__(self, AquaLogicProcessor processor, str switch_type)
None async_write_ha_state(self)
None async_on_remove(self, CALLBACK_TYPE func)
None async_setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback async_add_entities, DiscoveryInfoType|None discovery_info=None)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)