Abode services, events, lights, cameras, automations, quick actions. (#9310)
* Updated to latest AbodePy version. Added services and events. Added new device types. Added exclude, light, and polling config options. * Disable the event service if polling is enabled. * Addressed all CR's * Removed duplicated super call. * Name config option now used. Removed deprecated DEFAULT_NAME. * Modified partial to move event to first param.
This commit is contained in:
1 parent
5851944f80
commit
c44397e257
10 files changed
+588
-96
No files matched your search
@@ -6,7 +6,8 @@ https://home-assistant.io/components/switch.abode/
|
||||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.components.abode import AbodeDevice, DATA_ABODE
|
||||
from homeassistant.components.abode import (AbodeDevice, AbodeAutomation,
|
||||
DOMAIN as ABODE_DOMAIN)
|
||||
from homeassistant.components.switch import SwitchDevice
|
||||
|
||||
|
||||
@@ -18,27 +19,36 @@ _LOGGER = logging.getLogger(__name__)
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Set up Abode switch devices."""
|
||||
import abodepy.helpers.constants as CONST
|
||||
import abodepy.helpers.timeline as TIMELINE
|
||||
|
||||
abode = hass.data[DATA_ABODE]
|
||||
data = hass.data[ABODE_DOMAIN]
|
||||
|
||||
device_types = [
|
||||
CONST.DEVICE_POWER_SWITCH_SENSOR,
|
||||
CONST.DEVICE_POWER_SWITCH_METER]
|
||||
devices = []
|
||||
|
||||
sensors = []
|
||||
for sensor in abode.get_devices(type_filter=device_types):
|
||||
sensors.append(AbodeSwitch(abode, sensor))
|
||||
# Get all regular switches that are not excluded or marked as lights
|
||||
for device in data.abode.get_devices(generic_type=CONST.TYPE_SWITCH):
|
||||
if data.is_excluded(device) or not data.is_light(device):
|
||||
continue
|
||||
|
||||
add_devices(sensors)
|
||||
devices.append(AbodeSwitch(data, device))
|
||||
|
||||
# Get all Abode automations that can be enabled/disabled
|
||||
for automation in data.abode.get_automations(
|
||||
generic_type=CONST.TYPE_AUTOMATION):
|
||||
if data.is_automation_excluded(automation):
|
||||
continue
|
||||
|
||||
devices.append(AbodeAutomationSwitch(
|
||||
data, automation, TIMELINE.AUTOMATION_EDIT_GROUP))
|
||||
|
||||
data.devices.extend(devices)
|
||||
|
||||
add_devices(devices)
|
||||
|
||||
|
||||
class AbodeSwitch(AbodeDevice, SwitchDevice):
|
||||
"""Representation of an Abode switch."""
|
||||
|
||||
def __init__(self, controller, device):
|
||||
"""Initialize the Abode device."""
|
||||
AbodeDevice.__init__(self, controller, device)
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
"""Turn on the device."""
|
||||
self._device.switch_on()
|
||||
@@ -51,3 +61,20 @@ class AbodeSwitch(AbodeDevice, SwitchDevice):
|
||||
def is_on(self):
|
||||
"""Return true if device is on."""
|
||||
return self._device.is_on
|
||||
|
||||
|
||||
class AbodeAutomationSwitch(AbodeAutomation, SwitchDevice):
|
||||
"""A switch implementation for Abode automations."""
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
"""Turn on the device."""
|
||||
self._automation.set_active(True)
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
"""Turn off the device."""
|
||||
self._automation.set_active(False)
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return True if the binary sensor is on."""
|
||||
return self._automation.is_active
|
||||
Reference in new issue
Block a user