1 """Describe logbook events."""
3 from collections.abc
import Callable
7 LOGBOOK_ENTRY_ENTITY_ID,
13 from .const
import DOMAIN, EVENT_ALEXA_SMART_HOME
19 async_describe_event: Callable[[str, str, Callable[[Event], dict[str, str]]],
None],
21 """Describe logbook events."""
24 def async_describe_logbook_event(event: Event) -> dict[str, Any]:
25 """Describe a logbook event."""
28 if entity_id := data[
"request"].
get(
"entity_id"):
29 state = hass.states.get(entity_id)
30 name = state.name
if state
else entity_id
33 f
" {data['request']['namespace']}/{data['request']['name']} for {name}"
37 f
"sent command {data['request']['namespace']}/{data['request']['name']}"
41 LOGBOOK_ENTRY_NAME:
"Amazon Alexa",
42 LOGBOOK_ENTRY_MESSAGE: message,
43 LOGBOOK_ENTRY_ENTITY_ID: entity_id,
46 async_describe_event(DOMAIN, EVENT_ALEXA_SMART_HOME, async_describe_logbook_event)
None async_describe_events(HomeAssistant hass, Callable[[str, str, Callable[[Event], dict[str, str]]], None] async_describe_event)
web.Response get(self, web.Request request, str config_key)