2019-02-13 20:21:14 +00:00
|
|
|
"""Support for Abode Security System alarm control panels."""
|
2019-01-30 21:02:23 +00:00
|
|
|
import homeassistant.components.alarm_control_panel as alarm
|
2019-11-25 23:42:53 +00:00
|
|
|
from homeassistant.components.alarm_control_panel.const import (
|
|
|
|
SUPPORT_ALARM_ARM_AWAY,
|
|
|
|
SUPPORT_ALARM_ARM_HOME,
|
|
|
|
)
|
2018-01-21 06:35:38 +00:00
|
|
|
from homeassistant.const import (
|
2019-07-31 19:25:30 +00:00
|
|
|
ATTR_ATTRIBUTION,
|
|
|
|
STATE_ALARM_ARMED_AWAY,
|
|
|
|
STATE_ALARM_ARMED_HOME,
|
|
|
|
STATE_ALARM_DISARMED,
|
|
|
|
)
|
2017-08-20 14:55:48 +00:00
|
|
|
|
2019-10-13 18:01:04 +00:00
|
|
|
from . import AbodeDevice
|
|
|
|
from .const import ATTRIBUTION, DOMAIN
|
2019-03-21 05:56:46 +00:00
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
ICON = "mdi:security"
|
2017-08-20 14:55:48 +00:00
|
|
|
|
|
|
|
|
2019-10-13 18:01:04 +00:00
|
|
|
async def async_setup_entry(hass, config_entry, async_add_entities):
|
2019-11-09 06:35:45 +00:00
|
|
|
"""Set up Abode alarm control panel device."""
|
2019-10-13 18:01:04 +00:00
|
|
|
data = hass.data[DOMAIN]
|
|
|
|
async_add_entities(
|
|
|
|
[AbodeAlarm(data, await hass.async_add_executor_job(data.abode.get_alarm))]
|
|
|
|
)
|
2017-08-20 14:55:48 +00:00
|
|
|
|
|
|
|
|
2020-04-25 16:05:28 +00:00
|
|
|
class AbodeAlarm(AbodeDevice, alarm.AlarmControlPanelEntity):
|
2017-08-20 14:55:48 +00:00
|
|
|
"""An alarm_control_panel implementation for Abode."""
|
|
|
|
|
|
|
|
@property
|
|
|
|
def icon(self):
|
2018-01-21 06:35:38 +00:00
|
|
|
"""Return the icon."""
|
2017-08-20 14:55:48 +00:00
|
|
|
return ICON
|
|
|
|
|
|
|
|
@property
|
|
|
|
def state(self):
|
|
|
|
"""Return the state of the device."""
|
2017-08-29 15:34:19 +00:00
|
|
|
if self._device.is_standby:
|
2017-08-21 20:20:38 +00:00
|
|
|
state = STATE_ALARM_DISARMED
|
2017-08-29 15:34:19 +00:00
|
|
|
elif self._device.is_away:
|
2017-08-21 20:20:38 +00:00
|
|
|
state = STATE_ALARM_ARMED_AWAY
|
2017-08-29 15:34:19 +00:00
|
|
|
elif self._device.is_home:
|
2017-08-21 20:20:38 +00:00
|
|
|
state = STATE_ALARM_ARMED_HOME
|
|
|
|
else:
|
|
|
|
state = None
|
|
|
|
return state
|
2017-08-20 14:55:48 +00:00
|
|
|
|
2020-03-04 22:54:28 +00:00
|
|
|
@property
|
|
|
|
def code_arm_required(self):
|
|
|
|
"""Whether the code is required for arm actions."""
|
|
|
|
return False
|
|
|
|
|
2019-11-25 23:42:53 +00:00
|
|
|
@property
|
|
|
|
def supported_features(self) -> int:
|
|
|
|
"""Return the list of supported features."""
|
|
|
|
return SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY
|
|
|
|
|
2017-08-20 14:55:48 +00:00
|
|
|
def alarm_disarm(self, code=None):
|
|
|
|
"""Send disarm command."""
|
2017-08-21 20:20:38 +00:00
|
|
|
self._device.set_standby()
|
2017-08-20 14:55:48 +00:00
|
|
|
|
|
|
|
def alarm_arm_home(self, code=None):
|
|
|
|
"""Send arm home command."""
|
2017-08-21 20:20:38 +00:00
|
|
|
self._device.set_home()
|
2017-08-20 14:55:48 +00:00
|
|
|
|
|
|
|
def alarm_arm_away(self, code=None):
|
|
|
|
"""Send arm away command."""
|
2017-08-21 20:20:38 +00:00
|
|
|
self._device.set_away()
|
2017-08-20 14:55:48 +00:00
|
|
|
|
2017-08-29 15:34:19 +00:00
|
|
|
@property
|
2021-03-11 15:51:03 +00:00
|
|
|
def extra_state_attributes(self):
|
2017-08-29 15:34:19 +00:00
|
|
|
"""Return the state attributes."""
|
|
|
|
return {
|
2019-02-14 21:09:22 +00:00
|
|
|
ATTR_ATTRIBUTION: ATTRIBUTION,
|
2019-07-31 19:25:30 +00:00
|
|
|
"device_id": self._device.device_id,
|
|
|
|
"battery_backup": self._device.battery,
|
|
|
|
"cellular_backup": self._device.is_cellular,
|
2017-08-29 15:34:19 +00:00
|
|
|
}
|