1 """Support for wired switches attached to a Konnected device."""
25 DOMAIN
as KONNECTED_DOMAIN,
30 _LOGGER = logging.getLogger(__name__)
35 config_entry: ConfigEntry,
36 async_add_entities: AddEntitiesCallback,
38 """Set up switches attached to a Konnected device from a config entry."""
39 data = hass.data[KONNECTED_DOMAIN]
40 device_id = config_entry.data[
"id"]
43 for zone_data
in data[CONF_DEVICES][device_id][CONF_SWITCHES]
49 """Representation of a Konnected switch."""
52 """Initialize the Konnected switch."""
63 f
"{device_id}-{self._zone_num}-{self._momentary}-"
64 f
"{self._pause}-{self._repeat}"
70 """Return the Konnected HTTP client."""
71 device_data = self.
hasshass.data[KONNECTED_DOMAIN][CONF_DEVICES][self.
_device_id_device_id]
72 return device_data.get(
"panel")
76 """Return whether the panel is available."""
77 return self.
panelpanel.available
80 """Send a command to turn on the switch."""
81 resp = await self.
panelpanel.update_switch(
89 if resp.get(ATTR_STATE)
is not None:
92 if self.
_momentary_momentary
and resp.get(ATTR_STATE) != -1:
97 """Send a command to turn off the switch."""
98 resp = await self.
panelpanel.update_switch(
102 if resp.get(ATTR_STATE)
is not None:
116 "Setting status of %s actuator zone %s to %s",
124 """Update the switch state."""
128 """Store entity_id and register state change callback."""
None async_added_to_hass(self)
def _set_state(self, state)
None async_turn_off(self, **Any kwargs)
bool|None _boolean_state(self, int|None int_state)
def async_set_state(self, state)
def __init__(self, device_id, zone_num, data)
None async_turn_on(self, **Any kwargs)
None async_write_ha_state(self)
None async_on_remove(self, CALLBACK_TYPE func)
str|UndefinedType|None name(self)
web.Response get(self, web.Request request, str config_key)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)