mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 14:27:07 +00:00
Ensure doorbird events can be filtered by entity_id (#37116)
This commit is contained in:
parent
40573bf393
commit
0eaa6045c1
@ -11,6 +11,7 @@ import voluptuous as vol
|
|||||||
from homeassistant.components.http import HomeAssistantView
|
from homeassistant.components.http import HomeAssistantView
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
|
ATTR_ENTITY_ID,
|
||||||
CONF_DEVICES,
|
CONF_DEVICES,
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
@ -25,7 +26,14 @@ import homeassistant.helpers.config_validation as cv
|
|||||||
from homeassistant.helpers.network import get_url
|
from homeassistant.helpers.network import get_url
|
||||||
from homeassistant.util import dt as dt_util, slugify
|
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
|
from .util import get_doorstation_by_token
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -362,6 +370,10 @@ class DoorBirdRequestView(HomeAssistantView):
|
|||||||
message = f"HTTP Favorites cleared for {device.slug}"
|
message = f"HTTP Favorites cleared for {device.slug}"
|
||||||
return web.Response(status=HTTP_OK, text=message)
|
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)
|
hass.bus.async_fire(f"{DOMAIN}_{event}", event_data)
|
||||||
|
|
||||||
return web.Response(status=HTTP_OK, text="OK")
|
return web.Response(status=HTTP_OK, text="OK")
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
"""Describe logbook events."""
|
"""Describe logbook events."""
|
||||||
|
|
||||||
|
from homeassistant.const import ATTR_ENTITY_ID
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
|
|
||||||
from .const import DOMAIN, DOOR_STATION, DOOR_STATION_EVENT_ENTITY_IDS
|
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",
|
"name": "Doorbird",
|
||||||
"message": f"Event {event.event_type} was fired.",
|
"message": f"Event {event.event_type} was fired.",
|
||||||
"entity_id": hass.data[DOMAIN][DOOR_STATION_EVENT_ENTITY_IDS].get(
|
"entity_id": hass.data[DOMAIN][DOOR_STATION_EVENT_ENTITY_IDS].get(
|
||||||
doorbird_event
|
doorbird_event, event.data.get(ATTR_ENTITY_ID)
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user