Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/automation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ async def async_setup(hass, config):
async def trigger_service_handler(entity, service_call):
"""Handle forced automation trigger, e.g. from frontend."""
await entity.async_trigger(
service_call.data[ATTR_VARIABLES],
{**service_call.data[ATTR_VARIABLES], "trigger": {"platform": None}},
skip_condition=service_call.data[CONF_SKIP_CONDITION],
context=service_call.context,
)
Expand Down
30 changes: 30 additions & 0 deletions tests/components/automation/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -1355,3 +1355,33 @@ async def test_blueprint_automation(hass, calls):
assert automation.entities_in_automation(hass, "automation.automation_0") == [
"light.kitchen"
]


async def test_trigger_service(hass, calls):
"""Test the automation trigger service."""
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: {
"alias": "hello",
"trigger": {"platform": "event", "event_type": "test_event"},
"action": {
"service": "test.automation",
"data_template": {"trigger": "{{ trigger }}"},
},
}
},
)
context = Context()
await hass.services.async_call(
"automation",
"trigger",
{"entity_id": "automation.hello"},
blocking=True,
context=context,
)

assert len(calls) == 1
assert calls[0].data.get("trigger") == {"platform": None}
assert calls[0].context.parent_id is context.id