mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Update doorbird events to include URLs on event_data (#19262)
* Update doorbird events to include URLs on event_data as shown in documentation. (cherry picked from commit 2405bc96fe1b3a93ea8466e48db6b7df8df02235) * Format timestamp * Update timestamp * Lint
This commit is contained in:
parent
3bdee57066
commit
b3580f46b9
@ -12,7 +12,7 @@ from homeassistant.components.http import HomeAssistantView
|
||||
from homeassistant.const import CONF_HOST, CONF_USERNAME, \
|
||||
CONF_PASSWORD, CONF_NAME, CONF_DEVICES, CONF_MONITORED_CONDITIONS
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.util import slugify
|
||||
from homeassistant.util import slugify, dt as dt_util
|
||||
|
||||
REQUIREMENTS = ['doorbirdpy==2.0.4']
|
||||
|
||||
@ -319,6 +319,16 @@ class ConfiguredDoorBird():
|
||||
|
||||
return None
|
||||
|
||||
def get_event_data(self):
|
||||
"""Get data to pass along with HA event."""
|
||||
return {
|
||||
'timestamp': dt_util.utcnow().isoformat(),
|
||||
'live_video_url': self._device.live_video_url,
|
||||
'live_image_url': self._device.live_image_url,
|
||||
'rtsp_live_video_url': self._device.rtsp_live_video_url,
|
||||
'html5_viewer_url': self._device.html5_viewer_url
|
||||
}
|
||||
|
||||
|
||||
class DoorBirdRequestView(HomeAssistantView):
|
||||
"""Provide a page for the device to call."""
|
||||
@ -346,7 +356,14 @@ class DoorBirdRequestView(HomeAssistantView):
|
||||
if request_token == '' or not authenticated:
|
||||
return web.Response(status=401, text='Unauthorized')
|
||||
|
||||
hass.bus.async_fire('{}_{}'.format(DOMAIN, sensor))
|
||||
doorstation = get_doorstation_by_slug(hass, sensor)
|
||||
|
||||
if doorstation:
|
||||
event_data = doorstation.get_event_data()
|
||||
else:
|
||||
event_data = {}
|
||||
|
||||
hass.bus.async_fire('{}_{}'.format(DOMAIN, sensor), event_data)
|
||||
|
||||
return web.Response(status=200, text='OK')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user