1 """Support for DoorBird devices."""
3 from __future__
import annotations
5 from http
import HTTPStatus
7 from aiohttp
import web
12 from .const
import API_URL, DOMAIN
13 from .util
import get_door_station_by_token
17 """Provide a page for the device to call."""
21 name = API_URL[1:].replace(
"/",
":")
22 extra_urls = [API_URL +
"/{event}"]
24 async
def get(self, request: web.Request, event: str) -> web.Response:
25 """Respond to requests from the device."""
26 hass = request.app[KEY_HASS]
27 token: str |
None = request.query.get(
"token")
30 status=HTTPStatus.UNAUTHORIZED, text=
"Invalid token provided."
33 event_data = door_station.get_event_data(event)
42 event_type = f
"{DOMAIN}_{event}"
43 hass.bus.async_fire(event_type, event_data)
45 return web.Response(text=
"OK")
web.Response get(self, web.Request request, str event)
ConfiguredDoorBird|None get_door_station_by_token(HomeAssistant hass, str token)
None async_dispatcher_send(HomeAssistant hass, str signal, *Any args)