1 """Support for Envisalink zone bypass switches."""
3 from __future__
import annotations
14 from .
import CONF_ZONENAME, DATA_EVL, SIGNAL_ZONE_BYPASS_UPDATE, ZONE_SCHEMA
15 from .entity
import EnvisalinkEntity
17 _LOGGER = logging.getLogger(__name__)
23 async_add_entities: AddEntitiesCallback,
24 discovery_info: DiscoveryInfoType |
None =
None,
26 """Set up the Envisalink switch entities."""
27 if not discovery_info:
29 configured_zones = discovery_info[
"zones"]
32 for zone_num
in configured_zones:
33 entity_config_data =
ZONE_SCHEMA(configured_zones[zone_num])
34 zone_name = f
"{entity_config_data[CONF_ZONENAME]}_bypass"
35 _LOGGER.debug(
"Setting up zone_bypass switch: %s", zone_name)
41 hass.data[DATA_EVL].alarm_state[
"zone"][zone_num],
44 entities.append(entity)
50 """Representation of an Envisalink switch."""
52 def __init__(self, hass, zone_number, zone_name, info, controller):
53 """Initialize the switch."""
56 super().
__init__(zone_name, info, controller)
59 """Register callbacks."""
68 """Return the boolean response if the zone is bypassed."""
69 return self.
_info_info[
"bypassed"]
72 """Send the bypass keypress sequence to toggle the zone bypass."""
76 """Send the bypass keypress sequence to toggle the zone bypass."""
81 """Update the zone bypass state in HA, if needed."""
82 if bypass_map
is None or self.
_zone_number_zone_number
in bypass_map:
83 _LOGGER.debug(
"Bypass state changed for zone %d", self.
_zone_number_zone_number)
None async_turn_off(self, **Any kwargs)
None async_turn_on(self, **Any kwargs)
None async_added_to_hass(self)
def __init__(self, hass, zone_number, zone_name, info, controller)
def async_update_callback(self, bypass_map)
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)