Files
homeassistant-core/homeassistant/components/script/logbook.py
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
894 B
Python
Raw Normal View History

2020-06-24 18:14:50 -07:00
"""Describe logbook events."""
2022-09-12 17:53:06 +02:00
from homeassistant.components.logbook import (
LOGBOOK_ENTRY_CONTEXT_ID,
LOGBOOK_ENTRY_ENTITY_ID,
LOGBOOK_ENTRY_MESSAGE,
LOGBOOK_ENTRY_NAME,
)
2020-06-24 18:14:50 -07:00
from homeassistant.const import ATTR_ENTITY_ID, ATTR_NAME
from homeassistant.core import callback
from . import DOMAIN, EVENT_SCRIPT_STARTED
@callback
def async_describe_events(hass, async_describe_event):
"""Describe logbook events."""
@callback
def async_describe_logbook_event(event):
"""Describe the logbook event."""
data = event.data
2020-06-24 18:14:50 -07:00
return {
LOGBOOK_ENTRY_NAME: data.get(ATTR_NAME),
LOGBOOK_ENTRY_MESSAGE: "started",
LOGBOOK_ENTRY_ENTITY_ID: data.get(ATTR_ENTITY_ID),
LOGBOOK_ENTRY_CONTEXT_ID: event.context_id,
2020-06-24 18:14:50 -07:00
}
async_describe_event(DOMAIN, EVENT_SCRIPT_STARTED, async_describe_logbook_event)