Abode push events and lock, cover, and switch components (#9095)
* Updated abodepy version to 0.7.1 * Refactored to use AbodeDevice. Added Abode Lock device. * Added push updates to abode devices. * Upgraded to 0.7.2 after finding issue with callbacks. * Refactored to use AbodeDevice. Added Abode Lock device. * Added push updates to abode devices. * Upgraded to 0.7.2 after finding issue with callbacks. * Bumped version to 0.8.2. Modified code to work with new constants and properties. Added cover and switch. * Fixed hound violations. * Updated to 0.8.3 to fix small bug with standby mode. Fixed comment in cover/abode.py. * Fix lint issues * Removed excessive logging. Moved device callback registration to async_added_to_hass. Moved abode controller from global into hass data. * Removed explicit None from dict.get() * Move device class into the constructor. * Changed constant name to platforms. * Changes as requested. * Removing stray blank line. * Added blank line of which I'm not sure how it was removed. * Updated version to 0.9.0. Fixed motion sensor. Added power_switch_meter device type. * Update abode.py * fix lint
This commit is contained in:
parent
81a00bf3f1
commit
33c906c20a
7 changed files with 270 additions and 95 deletions
|
@ -6,10 +6,12 @@ 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_ALARM_ARMED_AWAY,
|
||||
from homeassistant.components.abode import (
|
||||
AbodeDevice, DATA_ABODE, DEFAULT_NAME, CONF_ATTRIBUTION)
|
||||
from homeassistant.components.alarm_control_panel import (AlarmControlPanel)
|
||||
from homeassistant.const import (ATTR_ATTRIBUTION, STATE_ALARM_ARMED_AWAY,
|
||||
STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED)
|
||||
import homeassistant.components.alarm_control_panel as alarm
|
||||
|
||||
|
||||
DEPENDENCIES = ['abode']
|
||||
|
||||
|
@ -20,30 +22,19 @@ 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)
|
||||
abode = hass.data[DATA_ABODE]
|
||||
|
||||
add_devices([AbodeAlarm(hass, data, data.abode.get_alarm())])
|
||||
add_devices([AbodeAlarm(abode, abode.get_alarm())])
|
||||
|
||||
|
||||
class AbodeAlarm(alarm.AlarmControlPanel):
|
||||
class AbodeAlarm(AbodeDevice, AlarmControlPanel):
|
||||
"""An alarm_control_panel implementation for Abode."""
|
||||
|
||||
def __init__(self, hass, data, device):
|
||||
def __init__(self, controller, device):
|
||||
"""Initialize the alarm control panel."""
|
||||
super(AbodeAlarm, self).__init__()
|
||||
self._device = device
|
||||
AbodeDevice.__init__(self, controller, 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."""
|
||||
|
@ -52,11 +43,11 @@ class AbodeAlarm(alarm.AlarmControlPanel):
|
|||
@property
|
||||
def state(self):
|
||||
"""Return the state of the device."""
|
||||
if self._device.mode == "standby":
|
||||
if self._device.is_standby:
|
||||
state = STATE_ALARM_DISARMED
|
||||
elif self._device.mode == "away":
|
||||
elif self._device.is_away:
|
||||
state = STATE_ALARM_ARMED_AWAY
|
||||
elif self._device.mode == "home":
|
||||
elif self._device.is_home:
|
||||
state = STATE_ALARM_ARMED_HOME
|
||||
else:
|
||||
state = None
|
||||
|
@ -65,18 +56,21 @@ class AbodeAlarm(alarm.AlarmControlPanel):
|
|||
def alarm_disarm(self, code=None):
|
||||
"""Send disarm command."""
|
||||
self._device.set_standby()
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def alarm_arm_home(self, code=None):
|
||||
"""Send arm home command."""
|
||||
self._device.set_home()
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def alarm_arm_away(self, code=None):
|
||||
"""Send arm away command."""
|
||||
self._device.set_away()
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def update(self):
|
||||
"""Update the device state."""
|
||||
self._device.refresh()
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
return {
|
||||
ATTR_ATTRIBUTION: CONF_ATTRIBUTION,
|
||||
'device_id': self._device.device_id,
|
||||
'battery_backup': self._device.battery,
|
||||
'cellular_backup': self._device.is_cellular
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue