Add id to automation triggers (#48464)

This commit is contained in:
Erik Montnemery 2021-03-31 14:56:04 +02:00 committed by GitHub
parent 450f3740cd
commit b26779a27a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 168 additions and 56 deletions

View file

@ -16,7 +16,10 @@ async def test_if_fires_on_hass_start(hass):
automation.DOMAIN: {
"alias": "hello",
"trigger": {"platform": "homeassistant", "event": "start"},
"action": {"service": "test.automation"},
"action": {
"service": "test.automation",
"data_template": {"id": "{{ trigger.id}}"},
},
}
}
@ -39,6 +42,7 @@ async def test_if_fires_on_hass_start(hass):
assert automation.is_on(hass, "automation.hello")
assert len(calls) == 1
assert calls[0].data["id"] == 0
async def test_if_fires_on_hass_shutdown(hass):
@ -53,7 +57,10 @@ async def test_if_fires_on_hass_shutdown(hass):
automation.DOMAIN: {
"alias": "hello",
"trigger": {"platform": "homeassistant", "event": "shutdown"},
"action": {"service": "test.automation"},
"action": {
"service": "test.automation",
"data_template": {"id": "{{ trigger.id}}"},
},
}
},
)
@ -68,3 +75,4 @@ async def test_if_fires_on_hass_shutdown(hass):
with patch.object(hass.loop, "stop"):
await hass.async_stop()
assert len(calls) == 1
assert calls[0].data["id"] == 0