1 """Support for HomematicIP Cloud alarm control panel."""
3 from __future__
import annotations
7 from homematicip.functionalHomes
import SecurityAndAlarmHome
10 AlarmControlPanelEntity,
11 AlarmControlPanelEntityFeature,
12 AlarmControlPanelState,
19 from .const
import DOMAIN
20 from .hap
import AsyncHome, HomematicipHAP
22 _LOGGER = logging.getLogger(__name__)
24 CONST_ALARM_CONTROL_PANEL_NAME =
"HmIP Alarm Control Panel"
29 config_entry: ConfigEntry,
30 async_add_entities: AddEntitiesCallback,
32 """Set up the HomematicIP alrm control panel from a config entry."""
33 hap = hass.data[DOMAIN][config_entry.unique_id]
38 """Representation of the HomematicIP alarm control panel."""
40 _attr_should_poll =
False
41 _attr_supported_features = (
42 AlarmControlPanelEntityFeature.ARM_HOME
43 | AlarmControlPanelEntityFeature.ARM_AWAY
45 _attr_code_arm_required =
False
47 def __init__(self, hap: HomematicipHAP) ->
None:
48 """Initialize the alarm control panel."""
49 self._home: AsyncHome = hap.home
53 """Return device specific attributes."""
55 identifiers={(DOMAIN, f
"ACP {self._home.id}")},
57 model=CONST_ALARM_CONTROL_PANEL_NAME,
59 via_device=(DOMAIN, self._home.id),
64 """Return the state of the alarm control panel."""
67 return AlarmControlPanelState.TRIGGERED
69 activation_state = self._home.get_security_zones_activation()
71 if activation_state == (
True,
True):
72 return AlarmControlPanelState.ARMED_AWAY
74 if activation_state == (
False,
True):
75 return AlarmControlPanelState.ARMED_HOME
77 return AlarmControlPanelState.DISARMED
81 return self._home.get_functionalHome(SecurityAndAlarmHome)
84 """Send disarm command."""
85 await self._home.set_security_zones_activation(
False,
False)
88 """Send arm home command."""
89 await self._home.set_security_zones_activation(
False,
True)
92 """Send arm away command."""
93 await self._home.set_security_zones_activation(
True,
True)
96 """Register callbacks."""
101 """Handle entity state changes."""
104 _LOGGER.debug(
"Event %s (%s)", self.
namenamename, CONST_ALARM_CONTROL_PANEL_NAME)
109 "Device Changed Event for %s (Alarm Control Panel) not fired."
110 " Entity is disabled"
117 """Return the name of the generic entity."""
118 name = CONST_ALARM_CONTROL_PANEL_NAME
120 name = f
"{self._home.name} {name}"
125 """Return if alarm control panel is available."""
126 return self._home.connected
130 """Return a unique ID."""
131 return f
"{self.__class__.__name__}_{self._home.id}"
SecurityAndAlarmHome _security_and_alarm(self)
None async_alarm_disarm(self, str|None code=None)
None async_added_to_hass(self)
AlarmControlPanelState alarm_state(self)
DeviceInfo device_info(self)
None __init__(self, HomematicipHAP hap)
None async_alarm_arm_away(self, str|None code=None)
None async_alarm_arm_home(self, str|None code=None)
None _async_device_changed(self, *args, **kwargs)
None async_write_ha_state(self)
str|UndefinedType|None name(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)