Add Abode home security component (#9030)
* Add Abode home security component * Remove protected member * Remove debug messages * Remove unwanted debug messages * Updated based on script/gen_requirements_all * Commit to restart the build process * Remove unwanted return * Removed unused listener * Address Pascal's comments * Updated alarm control panel based on Pascal's comments * Removed debug messages * Removed unused hass object
This commit is contained in:
parent
c059dfdb67
commit
b3d16e8f89
5 changed files with 243 additions and 0 deletions
81
homeassistant/components/alarm_control_panel/abode.py
Normal file
81
homeassistant/components/alarm_control_panel/abode.py
Normal file
|
@ -0,0 +1,81 @@
|
|||
"""
|
||||
This component provides HA alarm_control_panel support for Abode System.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/alarm_control_panel.abode/
|
||||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.components.abode import (DATA_ABODE, DEFAULT_NAME)
|
||||
from homeassistant.const import (STATE_UNKNOWN)
|
||||
import homeassistant.components.alarm_control_panel as alarm
|
||||
|
||||
DEPENDENCIES = ['abode']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
ALARM_STATE_HOME = 'home'
|
||||
ALARM_STATE_STANDBY = 'standby'
|
||||
ALARM_STATE_AWAY = 'away'
|
||||
ICON = 'mdi:security'
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Set up a sensor for an Abode device."""
|
||||
data = hass.data.get(DATA_ABODE)
|
||||
|
||||
add_devices([AbodeAlarm(hass, data, data.abode.get_alarm())])
|
||||
|
||||
|
||||
class AbodeAlarm(alarm.AlarmControlPanel):
|
||||
"""An alarm_control_panel implementation for Abode."""
|
||||
|
||||
def __init__(self, hass, data, device):
|
||||
"""Initialize the alarm control panel."""
|
||||
super(AbodeAlarm, self).__init__()
|
||||
self._device = device
|
||||
self._name = "{0}".format(DEFAULT_NAME)
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""Return the polling state."""
|
||||
return True
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the sensor."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
"""Return icon."""
|
||||
return ICON
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
"""Return the state of the device."""
|
||||
status = self._device.mode
|
||||
|
||||
if status in [ALARM_STATE_STANDBY, ALARM_STATE_HOME, ALARM_STATE_AWAY]:
|
||||
return status
|
||||
|
||||
return STATE_UNKNOWN
|
||||
|
||||
def alarm_disarm(self, code=None):
|
||||
"""Send disarm command."""
|
||||
self._device.set_mode(mode=ALARM_STATE_STANDBY)
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def alarm_arm_home(self, code=None):
|
||||
"""Send arm home command."""
|
||||
self._device.set_mode(mode=ALARM_STATE_HOME)
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def alarm_arm_away(self, code=None):
|
||||
"""Send arm away command."""
|
||||
self._device.set_mode(mode=ALARM_STATE_AWAY)
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def update(self):
|
||||
"""Update the device state."""
|
||||
self._device.refresh()
|
Loading…
Add table
Add a link
Reference in a new issue