Ensure doorbird events can be filtered by entity_id (#37116)

This commit is contained in:
J. Nick Koston authored and GitHub committed 2020-06-25 23:29:22 -07:00
1 parent 40573bf393
commit 0eaa6045c1
2 files changed
+15 -2

No files matched your search

+13 -1
View File
@@ -11,6 +11,7 @@ import voluptuous as vol
from homeassistant.components.http import HomeAssistantView
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const import (
ATTR_ENTITY_ID,
CONF_DEVICES,
CONF_HOST,
CONF_NAME,
@@ -25,7 +26,14 @@ import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.network import get_url
from homeassistant.util import dt as dt_util, slugify
from .const import CONF_EVENTS, DOMAIN, DOOR_STATION, DOOR_STATION_INFO, PLATFORMS
from .const import (
CONF_EVENTS,
DOMAIN,
DOOR_STATION,
DOOR_STATION_EVENT_ENTITY_IDS,
DOOR_STATION_INFO,
PLATFORMS,
)
from .util import get_doorstation_by_token
_LOGGER = logging.getLogger(__name__)
@@ -362,6 +370,10 @@ class DoorBirdRequestView(HomeAssistantView):
message = f"HTTP Favorites cleared for {device.slug}"
return web.Response(status=HTTP_OK, text=message)
event_data[ATTR_ENTITY_ID] = hass.data[DOMAIN][
DOOR_STATION_EVENT_ENTITY_IDS
].get(event)
hass.bus.async_fire(f"{DOMAIN}_{event}", event_data)
return web.Response(status=HTTP_OK, text="OK")
+2 -1
View File
@@ -1,5 +1,6 @@
"""Describe logbook events."""
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import callback
from .const import DOMAIN, DOOR_STATION, DOOR_STATION_EVENT_ENTITY_IDS
@@ -18,7 +19,7 @@ def async_describe_events(hass, async_describe_event):
"name": "Doorbird",
"message": f"Event {event.event_type} was fired.",
"entity_id": hass.data[DOMAIN][DOOR_STATION_EVENT_ENTITY_IDS].get(
doorbird_event
doorbird_event, event.data.get(ATTR_ENTITY_ID)
),
}