Home Assistant Unofficial Reference 2024.12.1
alarm_control_panel.py
Go to the documentation of this file.
1 """Support for Abode Security System alarm control panels."""
2 
3 from __future__ import annotations
4 
5 from jaraco.abode.devices.alarm import Alarm
6 
8  AlarmControlPanelEntity,
9  AlarmControlPanelEntityFeature,
10  AlarmControlPanelState,
11 )
12 from homeassistant.config_entries import ConfigEntry
13 from homeassistant.core import HomeAssistant
14 from homeassistant.helpers.entity_platform import AddEntitiesCallback
15 
16 from . import AbodeSystem
17 from .const import DOMAIN
18 from .entity import AbodeDevice
19 
20 
22  hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
23 ) -> None:
24  """Set up Abode alarm control panel device."""
25  data: AbodeSystem = hass.data[DOMAIN]
27  [AbodeAlarm(data, await hass.async_add_executor_job(data.abode.get_alarm))]
28  )
29 
30 
32  """An alarm_control_panel implementation for Abode."""
33 
34  _attr_name = None
35  _attr_code_arm_required = False
36  _attr_supported_features = (
37  AlarmControlPanelEntityFeature.ARM_HOME
38  | AlarmControlPanelEntityFeature.ARM_AWAY
39  )
40  _device: Alarm
41 
42  @property
43  def alarm_state(self) -> AlarmControlPanelState | None:
44  """Return the state of the device."""
45  if self._device_device.is_standby:
46  return AlarmControlPanelState.DISARMED
47  if self._device_device.is_away:
48  return AlarmControlPanelState.ARMED_AWAY
49  if self._device_device.is_home:
50  return AlarmControlPanelState.ARMED_HOME
51  return None
52 
53  def alarm_disarm(self, code: str | None = None) -> None:
54  """Send disarm command."""
55  self._device_device.set_standby()
56 
57  def alarm_arm_home(self, code: str | None = None) -> None:
58  """Send arm home command."""
59  self._device_device.set_home()
60 
61  def alarm_arm_away(self, code: str | None = None) -> None:
62  """Send arm away command."""
63  self._device_device.set_away()
64 
65  @property
66  def extra_state_attributes(self) -> dict[str, str]:
67  """Return the state attributes."""
68  return {
69  "device_id": self._device_device.id,
70  "battery_backup": self._device_device.battery,
71  "cellular_backup": self._device_device.is_cellular,
72  }
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)