mirror of
https://github.com/home-assistant/core.git
synced 2026-12-04 04:41:30 -04:00
Dump the event trigger config with plain keys in the composite device warning (#187684)
This commit is contained in:
@@ -121,7 +121,8 @@ def _log_composite_device_id_warning(
|
||||
"%s.\nThe affected trigger is configured as:\n%s",
|
||||
device_id,
|
||||
", ".join(device_summaries),
|
||||
yaml_util.dump(config),
|
||||
# The YAML dumper cannot represent the EventTriggerArgument keys
|
||||
yaml_util.dump({str(key): value for key, value in config.items()}),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ import pytest
|
||||
from pytest_homeassistant.common import MockConfigEntry, mock_component
|
||||
|
||||
from homeassistant.components import automation
|
||||
from homeassistant.components.homeassistant.triggers import event as event_trigger
|
||||
from homeassistant.components.homeassistant.triggers.event import EventTriggerArgument
|
||||
from homeassistant.const import ATTR_ENTITY_ID, ENTITY_MATCH_ALL, SERVICE_TURN_OFF
|
||||
from homeassistant.core import Context, HomeAssistant, ServiceCall
|
||||
from homeassistant.helpers import device_registry as dr, script, trigger
|
||||
@@ -702,6 +704,24 @@ async def test_composite_device_id_logs_warning(
|
||||
assert caplog.messages == [_expected_composite_warning(*split_devices)]
|
||||
|
||||
|
||||
async def test_composite_device_id_logs_warning_enum_keys(
|
||||
hass: HomeAssistant,
|
||||
split_devices: tuple[dr.DeviceEntry, dr.DeviceEntry],
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test the warning for a config keyed with the trigger argument enum."""
|
||||
with caplog.at_level(logging.WARNING):
|
||||
await event_trigger.async_validate_trigger_config(
|
||||
hass,
|
||||
{
|
||||
EventTriggerArgument.PLATFORM: "event",
|
||||
EventTriggerArgument.EVENT_TYPE: "my_event",
|
||||
EventTriggerArgument.EVENT_DATA: {"device_id": COMPOSITE_ID},
|
||||
},
|
||||
)
|
||||
assert caplog.messages == [_expected_composite_warning(*split_devices)]
|
||||
|
||||
|
||||
async def test_live_device_id_no_warning(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
|
||||
Reference in New Issue
Block a user