Fix Abode capture_image and trigger_quick_action services (#28546)
* Fix Abode services * Bump abodepy version * Updated using dispatcher helper * Code review fixes * Removed init method from AbodeQuickActionBinary Sensor
This commit is contained in:
parent
45b53c8e82
commit
97224df4fd
13 changed files with 76 additions and 51 deletions
|
@ -7,10 +7,11 @@ import abodepy.helpers.timeline as TIMELINE
|
|||
import requests
|
||||
|
||||
from homeassistant.components.camera import Camera
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.util import Throttle
|
||||
|
||||
from . import AbodeDevice
|
||||
from .const import DOMAIN
|
||||
from .const import DOMAIN, SIGNAL_CAPTURE_IMAGE
|
||||
|
||||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=90)
|
||||
|
||||
|
@ -23,15 +24,15 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up a camera for an Abode device."""
|
||||
|
||||
"""Set up Abode camera devices."""
|
||||
data = hass.data[DOMAIN]
|
||||
|
||||
devices = []
|
||||
for device in data.abode.get_devices(generic_type=CONST.TYPE_CAMERA):
|
||||
devices.append(AbodeCamera(data, device, TIMELINE.CAPTURE_IMAGE))
|
||||
entities = []
|
||||
|
||||
async_add_entities(devices)
|
||||
for device in data.abode.get_devices(generic_type=CONST.TYPE_CAMERA):
|
||||
entities.append(AbodeCamera(data, device, TIMELINE.CAPTURE_IMAGE))
|
||||
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
class AbodeCamera(AbodeDevice, Camera):
|
||||
|
@ -54,6 +55,9 @@ class AbodeCamera(AbodeDevice, Camera):
|
|||
self._capture_callback,
|
||||
)
|
||||
|
||||
signal = SIGNAL_CAPTURE_IMAGE.format(self.entity_id)
|
||||
async_dispatcher_connect(self.hass, signal, self.capture)
|
||||
|
||||
def capture(self):
|
||||
"""Request a new image capture."""
|
||||
return self._device.capture()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue