1 """Support for Envisalink-based alarm control panels (Honeywell/DSC)."""
3 from __future__
import annotations
7 import voluptuous
as vol
10 AlarmControlPanelEntity,
11 AlarmControlPanelEntityFeature,
12 AlarmControlPanelState,
29 SIGNAL_PARTITION_UPDATE,
31 from .entity
import EnvisalinkEntity
33 _LOGGER = logging.getLogger(__name__)
35 SERVICE_ALARM_KEYPRESS =
"alarm_keypress"
36 ATTR_KEYPRESS =
"keypress"
37 ALARM_KEYPRESS_SCHEMA = vol.Schema(
39 vol.Required(ATTR_ENTITY_ID): cv.entity_ids,
40 vol.Required(ATTR_KEYPRESS): cv.string,
48 async_add_entities: AddEntitiesCallback,
49 discovery_info: DiscoveryInfoType |
None =
None,
51 """Perform the setup for Envisalink alarm panels."""
52 if not discovery_info:
54 configured_partitions = discovery_info[
"partitions"]
55 code = discovery_info[CONF_CODE]
56 panic_type = discovery_info[CONF_PANIC]
59 for part_num
in configured_partitions:
64 entity_config_data[CONF_PARTITIONNAME],
67 hass.data[DATA_EVL].alarm_state[
"partition"][part_num],
70 entities.append(entity)
75 def async_alarm_keypress_handler(service: ServiceCall) ->
None:
76 """Map services to methods on Alarm."""
77 entity_ids = service.data[ATTR_ENTITY_ID]
78 keypress = service.data[ATTR_KEYPRESS]
81 entity
for entity
in entities
if entity.entity_id
in entity_ids
84 for entity
in target_entities:
85 entity.async_alarm_keypress(keypress)
87 hass.services.async_register(
89 SERVICE_ALARM_KEYPRESS,
90 async_alarm_keypress_handler,
91 schema=ALARM_KEYPRESS_SCHEMA,
96 """Representation of an Envisalink-based alarm panel."""
98 _attr_supported_features = (
99 AlarmControlPanelEntityFeature.ARM_HOME
100 | AlarmControlPanelEntityFeature.ARM_AWAY
101 | AlarmControlPanelEntityFeature.ARM_NIGHT
102 | AlarmControlPanelEntityFeature.TRIGGER
106 self, hass, partition_number, alarm_name, code, panic_type, info, controller
108 """Initialize the alarm panel."""
114 _LOGGER.debug(
"Setting up alarm: %s", alarm_name)
115 super().
__init__(alarm_name, info, controller)
118 """Register callbacks."""
132 """Update Home Assistant state, if needed."""
138 """Return the state of the device."""
141 if self.
_info_info[
"status"][
"alarm"]:
142 state = AlarmControlPanelState.TRIGGERED
143 elif self.
_info_info[
"status"][
"armed_zero_entry_delay"]:
144 state = AlarmControlPanelState.ARMED_NIGHT
145 elif self.
_info_info[
"status"][
"armed_away"]:
146 state = AlarmControlPanelState.ARMED_AWAY
147 elif self.
_info_info[
"status"][
"armed_stay"]:
148 state = AlarmControlPanelState.ARMED_HOME
149 elif self.
_info_info[
"status"][
"exit_delay"]:
150 state = AlarmControlPanelState.ARMING
151 elif self.
_info_info[
"status"][
"entry_delay"]:
152 state = AlarmControlPanelState.PENDING
153 elif self.
_info_info[
"status"][
"alpha"]:
154 state = AlarmControlPanelState.DISARMED
158 """Send disarm command."""
162 """Send arm home command."""
166 """Send arm away command."""
170 """Alarm trigger command. Will be used to trigger a panic alarm."""
174 """Send arm night command."""
179 """Send custom keypress."""
181 self.
hasshass.data[DATA_EVL].keypresses_to_partition(
_alarm_control_panel_option_default_code
AlarmControlPanelState|None alarm_state(self)
None async_alarm_arm_night(self, str|None code=None)
None async_alarm_arm_away(self, str|None code=None)
_alarm_control_panel_option_default_code
None async_alarm_arm_home(self, str|None code=None)
None async_added_to_hass(self)
None async_alarm_disarm(self, str|None code=None)
None async_alarm_trigger(self, str|None code=None)
def async_alarm_keypress(self, keypress=None)
def async_update_callback(self, partition)
def __init__(self, hass, partition_number, alarm_name, code, panic_type, info, controller)
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)