diff --git a/homeassistant/components/alexa/logbook.py b/homeassistant/components/alexa/logbook.py index 65fb410c601..b72b884ec29 100644 --- a/homeassistant/components/alexa/logbook.py +++ b/homeassistant/components/alexa/logbook.py @@ -1,4 +1,9 @@ """Describe logbook events.""" +from homeassistant.components.logbook.const import ( + LOGBOOK_ENTRY_ENTITY_ID, + LOGBOOK_ENTRY_MESSAGE, + LOGBOOK_ENTRY_NAME, +) from homeassistant.core import callback from .const import DOMAIN, EVENT_ALEXA_SMART_HOME @@ -22,6 +27,10 @@ def async_describe_events(hass, async_describe_event): f"sent command {data['request']['namespace']}/{data['request']['name']}" ) - return {"name": "Amazon Alexa", "message": message, "entity_id": entity_id} + return { + LOGBOOK_ENTRY_NAME: "Amazon Alexa", + LOGBOOK_ENTRY_MESSAGE: message, + LOGBOOK_ENTRY_ENTITY_ID: entity_id, + } async_describe_event(DOMAIN, EVENT_ALEXA_SMART_HOME, async_describe_logbook_event) diff --git a/homeassistant/components/automation/logbook.py b/homeassistant/components/automation/logbook.py index 97a859d25b0..529fed80d26 100644 --- a/homeassistant/components/automation/logbook.py +++ b/homeassistant/components/automation/logbook.py @@ -1,5 +1,12 @@ """Describe logbook events.""" from homeassistant.components.logbook import LazyEventPartialState +from homeassistant.components.logbook.const import ( + LOGBOOK_ENTRY_CONTEXT_ID, + LOGBOOK_ENTRY_ENTITY_ID, + LOGBOOK_ENTRY_MESSAGE, + LOGBOOK_ENTRY_NAME, + LOGBOOK_ENTRY_SOURCE, +) from homeassistant.const import ATTR_ENTITY_ID, ATTR_NAME from homeassistant.core import HomeAssistant, callback @@ -20,11 +27,11 @@ def async_describe_events(hass: HomeAssistant, async_describe_event): # type: i message = f"{message} by {data[ATTR_SOURCE]}" return { - "name": data.get(ATTR_NAME), - "message": message, - "source": data.get(ATTR_SOURCE), - "entity_id": data.get(ATTR_ENTITY_ID), - "context_id": event.context_id, + LOGBOOK_ENTRY_NAME: data.get(ATTR_NAME), + LOGBOOK_ENTRY_MESSAGE: message, + LOGBOOK_ENTRY_SOURCE: data.get(ATTR_SOURCE), + LOGBOOK_ENTRY_ENTITY_ID: data.get(ATTR_ENTITY_ID), + LOGBOOK_ENTRY_CONTEXT_ID: event.context_id, } async_describe_event( diff --git a/homeassistant/components/deconz/logbook.py b/homeassistant/components/deconz/logbook.py index e67e07d2222..07dc7cb0124 100644 --- a/homeassistant/components/deconz/logbook.py +++ b/homeassistant/components/deconz/logbook.py @@ -3,6 +3,10 @@ from __future__ import annotations from collections.abc import Callable +from homeassistant.components.logbook.const import ( + LOGBOOK_ENTRY_MESSAGE, + LOGBOOK_ENTRY_NAME, +) from homeassistant.const import ATTR_DEVICE_ID, CONF_EVENT from homeassistant.core import Event, HomeAssistant, callback import homeassistant.helpers.device_registry as dr @@ -135,8 +139,8 @@ def async_describe_events( data = event.data[CONF_EVENT] return { - "name": f"{deconz_alarm_event.device.name}", - "message": f"fired event '{data}'", + LOGBOOK_ENTRY_NAME: f"{deconz_alarm_event.device.name}", + LOGBOOK_ENTRY_MESSAGE: f"fired event '{data}'", } @callback @@ -157,27 +161,27 @@ def async_describe_events( # Unknown event if not data: return { - "name": f"{deconz_event.device.name}", - "message": "fired an unknown event", + LOGBOOK_ENTRY_NAME: f"{deconz_event.device.name}", + LOGBOOK_ENTRY_MESSAGE: "fired an unknown event", } # No device event match if not action: return { - "name": f"{deconz_event.device.name}", - "message": f"fired event '{data}'", + LOGBOOK_ENTRY_NAME: f"{deconz_event.device.name}", + LOGBOOK_ENTRY_MESSAGE: f"fired event '{data}'", } # Gesture event if not interface: return { - "name": f"{deconz_event.device.name}", - "message": f"fired event '{ACTIONS[action]}'", + LOGBOOK_ENTRY_NAME: f"{deconz_event.device.name}", + LOGBOOK_ENTRY_MESSAGE: f"fired event '{ACTIONS[action]}'", } return { - "name": f"{deconz_event.device.name}", - "message": f"'{ACTIONS[action]}' event for '{INTERFACES[interface]}' was fired", + LOGBOOK_ENTRY_NAME: f"{deconz_event.device.name}", + LOGBOOK_ENTRY_MESSAGE: f"'{ACTIONS[action]}' event for '{INTERFACES[interface]}' was fired", } async_describe_event( diff --git a/homeassistant/components/doorbird/logbook.py b/homeassistant/components/doorbird/logbook.py index fbd6c670a8d..110d3f22fbf 100644 --- a/homeassistant/components/doorbird/logbook.py +++ b/homeassistant/components/doorbird/logbook.py @@ -1,5 +1,10 @@ """Describe logbook events.""" +from homeassistant.components.logbook.const import ( + LOGBOOK_ENTRY_ENTITY_ID, + LOGBOOK_ENTRY_MESSAGE, + LOGBOOK_ENTRY_NAME, +) from homeassistant.const import ATTR_ENTITY_ID from homeassistant.core import callback @@ -16,11 +21,11 @@ def async_describe_events(hass, async_describe_event): doorbird_event = event.event_type.split("_", 1)[1] return { - "name": "Doorbird", - "message": f"Event {event.event_type} was fired", - "entity_id": hass.data[DOMAIN][DOOR_STATION_EVENT_ENTITY_IDS].get( - doorbird_event, event.data.get(ATTR_ENTITY_ID) - ), + LOGBOOK_ENTRY_NAME: "Doorbird", + LOGBOOK_ENTRY_MESSAGE: f"Event {event.event_type} was fired", + LOGBOOK_ENTRY_ENTITY_ID: hass.data[DOMAIN][ + DOOR_STATION_EVENT_ENTITY_IDS + ].get(doorbird_event, event.data.get(ATTR_ENTITY_ID)), } domain_data = hass.data[DOMAIN] diff --git a/homeassistant/components/elkm1/logbook.py b/homeassistant/components/elkm1/logbook.py index 01019ce77e0..9aa85b599e0 100644 --- a/homeassistant/components/elkm1/logbook.py +++ b/homeassistant/components/elkm1/logbook.py @@ -3,6 +3,10 @@ from __future__ import annotations from collections.abc import Callable +from homeassistant.components.logbook.const import ( + LOGBOOK_ENTRY_MESSAGE, + LOGBOOK_ENTRY_NAME, +) from homeassistant.core import Event, HomeAssistant, callback from .const import ( @@ -30,8 +34,8 @@ def async_describe_events( ATTR_KEYPAD_NAME, data[ATTR_KEYPAD_ID] ) # added in 2022.6 return { - "name": f"Elk Keypad {keypad_name}", - "message": f"pressed {data[ATTR_KEY_NAME]} ({data[ATTR_KEY]})", + LOGBOOK_ENTRY_NAME: f"Elk Keypad {keypad_name}", + LOGBOOK_ENTRY_MESSAGE: f"pressed {data[ATTR_KEY_NAME]} ({data[ATTR_KEY]})", } async_describe_event( diff --git a/homeassistant/components/google_assistant/logbook.py b/homeassistant/components/google_assistant/logbook.py index 86caa8a9e6c..0ed5745004d 100644 --- a/homeassistant/components/google_assistant/logbook.py +++ b/homeassistant/components/google_assistant/logbook.py @@ -1,4 +1,8 @@ """Describe logbook events.""" +from homeassistant.components.logbook.const import ( + LOGBOOK_ENTRY_MESSAGE, + LOGBOOK_ENTRY_NAME, +) from homeassistant.core import callback from .const import DOMAIN, EVENT_COMMAND_RECEIVED, SOURCE_CLOUD @@ -25,6 +29,6 @@ def async_describe_events(hass, async_describe_event): if event.data["source"] != SOURCE_CLOUD: message += f" (via {event.data['source']})" - return {"name": "Google Assistant", "message": message} + return {LOGBOOK_ENTRY_NAME: "Google Assistant", LOGBOOK_ENTRY_MESSAGE: message} async_describe_event(DOMAIN, EVENT_COMMAND_RECEIVED, async_describe_logbook_event) diff --git a/homeassistant/components/homeassistant/logbook.py b/homeassistant/components/homeassistant/logbook.py index 229fb24cb27..548753982a8 100644 --- a/homeassistant/components/homeassistant/logbook.py +++ b/homeassistant/components/homeassistant/logbook.py @@ -3,7 +3,7 @@ from __future__ import annotations from collections.abc import Callable -from homeassistant.components.logbook import ( +from homeassistant.components.logbook.const import ( LOGBOOK_ENTRY_ICON, LOGBOOK_ENTRY_MESSAGE, LOGBOOK_ENTRY_NAME, diff --git a/homeassistant/components/homekit/logbook.py b/homeassistant/components/homekit/logbook.py index b6805f8cf6c..a513b31b232 100644 --- a/homeassistant/components/homekit/logbook.py +++ b/homeassistant/components/homekit/logbook.py @@ -2,6 +2,11 @@ from collections.abc import Callable from typing import Any +from homeassistant.components.logbook.const import ( + LOGBOOK_ENTRY_ENTITY_ID, + LOGBOOK_ENTRY_MESSAGE, + LOGBOOK_ENTRY_NAME, +) from homeassistant.const import ATTR_ENTITY_ID, ATTR_SERVICE from homeassistant.core import Event, HomeAssistant, callback @@ -26,9 +31,9 @@ def async_describe_events( message = f"send command {data[ATTR_SERVICE]}{value_msg} for {data[ATTR_DISPLAY_NAME]}" return { - "name": "HomeKit", - "message": message, - "entity_id": entity_id, + LOGBOOK_ENTRY_NAME: "HomeKit", + LOGBOOK_ENTRY_MESSAGE: message, + LOGBOOK_ENTRY_ENTITY_ID: entity_id, } async_describe_event(DOMAIN, EVENT_HOMEKIT_CHANGED, async_describe_logbook_event) diff --git a/homeassistant/components/hue/logbook.py b/homeassistant/components/hue/logbook.py index 40abce7e2d3..e98a99f1861 100644 --- a/homeassistant/components/hue/logbook.py +++ b/homeassistant/components/hue/logbook.py @@ -3,6 +3,10 @@ from __future__ import annotations from collections.abc import Callable +from homeassistant.components.logbook.const import ( + LOGBOOK_ENTRY_MESSAGE, + LOGBOOK_ENTRY_NAME, +) from homeassistant.const import CONF_DEVICE_ID, CONF_EVENT, CONF_ID, CONF_TYPE from homeassistant.core import Event, HomeAssistant, callback from homeassistant.helpers import device_registry as dr @@ -66,8 +70,8 @@ def async_describe_events( else: message = f"Event {data[CONF_EVENT]}" # v1 return { - "name": name, - "message": str(message), + LOGBOOK_ENTRY_NAME: name, + LOGBOOK_ENTRY_MESSAGE: message, } async_describe_event(DOMAIN, ATTR_HUE_EVENT, async_describe_hue_event) diff --git a/homeassistant/components/logbook/__init__.py b/homeassistant/components/logbook/__init__.py index d9893781748..f66f1d5e920 100644 --- a/homeassistant/components/logbook/__init__.py +++ b/homeassistant/components/logbook/__init__.py @@ -39,7 +39,6 @@ from .const import ( LOGBOOK_ENTRY_NAME, LOGBOOK_FILTERS, ) -from .const import LOGBOOK_ENTRY_ICON # noqa: F401 from .models import LazyEventPartialState # noqa: F401 CONFIG_SCHEMA = vol.Schema( diff --git a/homeassistant/components/logbook/const.py b/homeassistant/components/logbook/const.py index 406406e9dd8..3f0c6599724 100644 --- a/homeassistant/components/logbook/const.py +++ b/homeassistant/components/logbook/const.py @@ -15,13 +15,16 @@ CONTEXT_ENTITY_ID_NAME = "context_entity_id_name" CONTEXT_EVENT_TYPE = "context_event_type" CONTEXT_DOMAIN = "context_domain" CONTEXT_STATE = "context_state" +CONTEXT_SOURCE = "context_source" CONTEXT_SERVICE = "context_service" CONTEXT_NAME = "context_name" CONTEXT_MESSAGE = "context_message" +LOGBOOK_ENTRY_CONTEXT_ID = "context_id" LOGBOOK_ENTRY_DOMAIN = "domain" LOGBOOK_ENTRY_ENTITY_ID = "entity_id" LOGBOOK_ENTRY_ICON = "icon" +LOGBOOK_ENTRY_SOURCE = "source" LOGBOOK_ENTRY_MESSAGE = "message" LOGBOOK_ENTRY_NAME = "name" LOGBOOK_ENTRY_STATE = "state" diff --git a/homeassistant/components/logbook/processor.py b/homeassistant/components/logbook/processor.py index c9f20f27f7c..03506695700 100644 --- a/homeassistant/components/logbook/processor.py +++ b/homeassistant/components/logbook/processor.py @@ -42,6 +42,7 @@ from .const import ( CONTEXT_MESSAGE, CONTEXT_NAME, CONTEXT_SERVICE, + CONTEXT_SOURCE, CONTEXT_STATE, CONTEXT_USER_ID, DOMAIN, @@ -51,6 +52,7 @@ from .const import ( LOGBOOK_ENTRY_ICON, LOGBOOK_ENTRY_MESSAGE, LOGBOOK_ENTRY_NAME, + LOGBOOK_ENTRY_SOURCE, LOGBOOK_ENTRY_STATE, LOGBOOK_ENTRY_WHEN, LOGBOOK_FILTERS, @@ -398,11 +400,14 @@ class ContextAugmenter: data[CONTEXT_DOMAIN] = domain event = self.event_cache.get(context_row) described = describe_event(event) - if name := described.get(ATTR_NAME): + if name := described.get(LOGBOOK_ENTRY_NAME): data[CONTEXT_NAME] = name - if message := described.get(ATTR_MESSAGE): + if message := described.get(LOGBOOK_ENTRY_MESSAGE): data[CONTEXT_MESSAGE] = message - if not (attr_entity_id := described.get(ATTR_ENTITY_ID)): + # In 2022.12 and later drop `CONTEXT_MESSAGE` if `CONTEXT_SOURCE` is available + if source := described.get(LOGBOOK_ENTRY_SOURCE): + data[CONTEXT_SOURCE] = source + if not (attr_entity_id := described.get(LOGBOOK_ENTRY_ENTITY_ID)): return data[CONTEXT_ENTITY_ID] = attr_entity_id if self.include_entity_name: diff --git a/homeassistant/components/lutron_caseta/logbook.py b/homeassistant/components/lutron_caseta/logbook.py index 28342090a21..bcca548f64b 100644 --- a/homeassistant/components/lutron_caseta/logbook.py +++ b/homeassistant/components/lutron_caseta/logbook.py @@ -3,6 +3,10 @@ from __future__ import annotations from collections.abc import Callable +from homeassistant.components.logbook.const import ( + LOGBOOK_ENTRY_MESSAGE, + LOGBOOK_ENTRY_NAME, +) from homeassistant.core import Event, HomeAssistant, callback from .const import ( @@ -33,8 +37,8 @@ def async_describe_events( button_map = LEAP_TO_DEVICE_TYPE_SUBTYPE_MAP[device_type] button_description = button_map[leap_button_number] return { - "name": f"{data[ATTR_AREA_NAME]} {data[ATTR_DEVICE_NAME]}", - "message": f"{data[ATTR_ACTION]} {button_description}", + LOGBOOK_ENTRY_NAME: f"{data[ATTR_AREA_NAME]} {data[ATTR_DEVICE_NAME]}", + LOGBOOK_ENTRY_MESSAGE: f"{data[ATTR_ACTION]} {button_description}", } async_describe_event( diff --git a/homeassistant/components/mobile_app/logbook.py b/homeassistant/components/mobile_app/logbook.py index 6dd4d007e3e..6f7c2e4e99c 100644 --- a/homeassistant/components/mobile_app/logbook.py +++ b/homeassistant/components/mobile_app/logbook.py @@ -3,6 +3,12 @@ from __future__ import annotations from collections.abc import Callable +from homeassistant.components.logbook.const import ( + LOGBOOK_ENTRY_ENTITY_ID, + LOGBOOK_ENTRY_ICON, + LOGBOOK_ENTRY_MESSAGE, + LOGBOOK_ENTRY_NAME, +) from homeassistant.const import ATTR_FRIENDLY_NAME, ATTR_ICON from homeassistant.core import Event, HomeAssistant, callback @@ -42,12 +48,12 @@ def async_describe_events( zone_name = zone_state.attributes.get(ATTR_FRIENDLY_NAME) zone_icon = zone_state.attributes.get(ATTR_ICON) description = { - "name": source_device_name, - "message": f"{event_description} {zone_name or zone_entity_id}", - "icon": zone_icon or "mdi:crosshairs-gps", + LOGBOOK_ENTRY_NAME: source_device_name, + LOGBOOK_ENTRY_MESSAGE: f"{event_description} {zone_name or zone_entity_id}", + LOGBOOK_ENTRY_ICON: zone_icon or "mdi:crosshairs-gps", } if zone_entity_id: - description["entity_id"] = zone_entity_id + description[LOGBOOK_ENTRY_ENTITY_ID] = zone_entity_id return description async_describe_event(DOMAIN, IOS_EVENT_ZONE_ENTERED, async_describe_zone_event) diff --git a/homeassistant/components/script/logbook.py b/homeassistant/components/script/logbook.py index 250b7231b32..7fcbad07479 100644 --- a/homeassistant/components/script/logbook.py +++ b/homeassistant/components/script/logbook.py @@ -1,4 +1,10 @@ """Describe logbook events.""" +from homeassistant.components.logbook.const import ( + LOGBOOK_ENTRY_CONTEXT_ID, + LOGBOOK_ENTRY_ENTITY_ID, + LOGBOOK_ENTRY_MESSAGE, + LOGBOOK_ENTRY_NAME, +) from homeassistant.const import ATTR_ENTITY_ID, ATTR_NAME from homeassistant.core import callback @@ -14,10 +20,10 @@ def async_describe_events(hass, async_describe_event): """Describe the logbook event.""" data = event.data return { - "name": data.get(ATTR_NAME), - "message": "started", - "entity_id": data.get(ATTR_ENTITY_ID), - "context_id": event.context_id, + 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, } async_describe_event(DOMAIN, EVENT_SCRIPT_STARTED, async_describe_logbook_event) diff --git a/homeassistant/components/shelly/logbook.py b/homeassistant/components/shelly/logbook.py index 504dfe90791..a91f4e1cf56 100644 --- a/homeassistant/components/shelly/logbook.py +++ b/homeassistant/components/shelly/logbook.py @@ -3,6 +3,10 @@ from __future__ import annotations from collections.abc import Callable +from homeassistant.components.logbook.const import ( + LOGBOOK_ENTRY_MESSAGE, + LOGBOOK_ENTRY_NAME, +) from homeassistant.const import ATTR_DEVICE_ID from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.typing import EventType @@ -48,8 +52,8 @@ def async_describe_events( input_name = f"{device_name} channel {channel}" return { - "name": "Shelly", - "message": f"'{click_type}' click event for {input_name} Input was fired", + LOGBOOK_ENTRY_NAME: "Shelly", + LOGBOOK_ENTRY_MESSAGE: f"'{click_type}' click event for {input_name} Input was fired", } async_describe_event(DOMAIN, EVENT_SHELLY_CLICK, async_describe_shelly_click_event) diff --git a/tests/components/logbook/test_websocket_api.py b/tests/components/logbook/test_websocket_api.py index 585732b66f1..e1fc1defe09 100644 --- a/tests/components/logbook/test_websocket_api.py +++ b/tests/components/logbook/test_websocket_api.py @@ -8,7 +8,7 @@ import pytest from homeassistant import core from homeassistant.components import logbook, recorder -from homeassistant.components.automation import EVENT_AUTOMATION_TRIGGERED +from homeassistant.components.automation import ATTR_SOURCE, EVENT_AUTOMATION_TRIGGERED from homeassistant.components.logbook import websocket_api from homeassistant.components.script import EVENT_SCRIPT_STARTED from homeassistant.components.websocket_api.const import TYPE_RESULT @@ -535,11 +535,19 @@ async def test_subscribe_unsubscribe_logbook_stream( hass.bus.async_fire( EVENT_AUTOMATION_TRIGGERED, - {ATTR_NAME: "Mock automation", ATTR_ENTITY_ID: "automation.mock_automation"}, + { + ATTR_NAME: "Mock automation", + ATTR_ENTITY_ID: "automation.mock_automation", + ATTR_SOURCE: "numeric state of sensor.hungry_dogs", + }, ) hass.bus.async_fire( EVENT_SCRIPT_STARTED, - {ATTR_NAME: "Mock script", ATTR_ENTITY_ID: "script.mock_script"}, + { + ATTR_NAME: "Mock script", + ATTR_ENTITY_ID: "script.mock_script", + ATTR_SOURCE: "numeric state of sensor.hungry_dogs", + }, ) hass.bus.async_fire(EVENT_HOMEASSISTANT_START) await hass.async_block_till_done() @@ -552,9 +560,9 @@ async def test_subscribe_unsubscribe_logbook_stream( "context_id": ANY, "domain": "automation", "entity_id": "automation.mock_automation", - "message": "triggered", + "message": "triggered by numeric state of sensor.hungry_dogs", "name": "Mock automation", - "source": None, + "source": "numeric state of sensor.hungry_dogs", "when": ANY, }, { @@ -581,7 +589,11 @@ async def test_subscribe_unsubscribe_logbook_stream( automation_entity_id_test = "automation.alarm" hass.bus.async_fire( EVENT_AUTOMATION_TRIGGERED, - {ATTR_NAME: "Mock automation", ATTR_ENTITY_ID: automation_entity_id_test}, + { + ATTR_NAME: "Mock automation", + ATTR_ENTITY_ID: automation_entity_id_test, + ATTR_SOURCE: "state of binary_sensor.dog_food_ready", + }, context=context, ) hass.bus.async_fire( @@ -613,9 +625,9 @@ async def test_subscribe_unsubscribe_logbook_stream( "context_user_id": "b400facee45711eaa9308bfd3d19e474", "domain": "automation", "entity_id": "automation.alarm", - "message": "triggered", + "message": "triggered by state of binary_sensor.dog_food_ready", "name": "Mock automation", - "source": None, + "source": "state of binary_sensor.dog_food_ready", "when": ANY, }, { @@ -623,8 +635,9 @@ async def test_subscribe_unsubscribe_logbook_stream( "context_entity_id": "automation.alarm", "context_event_type": "automation_triggered", "context_id": "ac5bd62de45711eaaeb351041eec8dd9", - "context_message": "triggered", + "context_message": "triggered by state of " "binary_sensor.dog_food_ready", "context_name": "Mock automation", + "context_source": "state of binary_sensor.dog_food_ready", "context_user_id": "b400facee45711eaa9308bfd3d19e474", "domain": "script", "entity_id": "script.mock_script", @@ -636,8 +649,9 @@ async def test_subscribe_unsubscribe_logbook_stream( "context_domain": "automation", "context_entity_id": "automation.alarm", "context_event_type": "automation_triggered", - "context_message": "triggered", + "context_message": "triggered by state of " "binary_sensor.dog_food_ready", "context_name": "Mock automation", + "context_source": "state of binary_sensor.dog_food_ready", "context_user_id": "b400facee45711eaa9308bfd3d19e474", "entity_id": "alarm_control_panel.area_001", "state": "on", @@ -647,8 +661,9 @@ async def test_subscribe_unsubscribe_logbook_stream( "context_domain": "automation", "context_entity_id": "automation.alarm", "context_event_type": "automation_triggered", - "context_message": "triggered", + "context_message": "triggered by state of " "binary_sensor.dog_food_ready", "context_name": "Mock automation", + "context_source": "state of binary_sensor.dog_food_ready", "context_user_id": "b400facee45711eaa9308bfd3d19e474", "entity_id": "alarm_control_panel.area_002", "state": "on", @@ -672,8 +687,9 @@ async def test_subscribe_unsubscribe_logbook_stream( "context_entity_id": "automation.alarm", "context_event_type": "automation_triggered", "context_id": "ac5bd62de45711eaaeb351041eec8dd9", - "context_message": "triggered", + "context_message": "triggered by state of binary_sensor.dog_food_ready", "context_name": "Mock automation", + "context_source": "state of binary_sensor.dog_food_ready", "context_user_id": "b400facee45711eaa9308bfd3d19e474", "domain": "automation", "entity_id": "automation.alarm", @@ -701,8 +717,9 @@ async def test_subscribe_unsubscribe_logbook_stream( "context_entity_id": "automation.alarm", "context_event_type": "automation_triggered", "context_id": "ac5bd62de45711eaaeb351041eec8dd9", - "context_message": "triggered", + "context_message": "triggered by state of binary_sensor.dog_food_ready", "context_name": "Mock automation", + "context_source": "state of binary_sensor.dog_food_ready", "context_user_id": "b400facee45711eaa9308bfd3d19e474", "domain": "automation", "entity_id": "automation.alarm",