diff --git a/homeassistant/components/doorbird/event.py b/homeassistant/components/doorbird/event.py index 39da279a3e0..4c20098fc80 100644 --- a/homeassistant/components/doorbird/event.py +++ b/homeassistant/components/doorbird/event.py @@ -7,7 +7,8 @@ from homeassistant.components.event import ( EventEntity, EventEntityDescription, ) -from homeassistant.core import Event, HomeAssistant, callback +from homeassistant.core import HomeAssistant, callback +from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback from .const import DOMAIN @@ -70,14 +71,15 @@ class DoorBirdEventEntity(DoorBirdEntity, EventEntity): async def async_added_to_hass(self) -> None: """Subscribe to device events.""" self.async_on_remove( - self.hass.bus.async_listen( + async_dispatcher_connect( + self.hass, f"{DOMAIN}_{self._doorbird_event.event}", self._async_handle_event, ) ) @callback - def _async_handle_event(self, event: Event) -> None: + def _async_handle_event(self) -> None: """Handle a device event.""" event_types = self.entity_description.event_types if TYPE_CHECKING: diff --git a/homeassistant/components/doorbird/view.py b/homeassistant/components/doorbird/view.py index 80454288d48..77b84bf4f3b 100644 --- a/homeassistant/components/doorbird/view.py +++ b/homeassistant/components/doorbird/view.py @@ -7,6 +7,7 @@ from http import HTTPStatus from aiohttp import web from homeassistant.components.http import KEY_HASS, HomeAssistantView +from homeassistant.helpers.dispatcher import async_dispatcher_send from .const import API_URL, DOMAIN from .util import get_door_station_by_token @@ -45,5 +46,7 @@ class DoorBirdRequestView(HomeAssistantView): # Do not copy this pattern in the future # for any new integrations. # - hass.bus.async_fire(f"{DOMAIN}_{event}", event_data) + event_type = f"{DOMAIN}_{event}" + hass.bus.async_fire(event_type, event_data) + async_dispatcher_send(hass, event_type) return web.Response(text="OK")