Add trigger_variables to template trigger 'for' field (#136672)

* Add trigger_variables to template trigger for

* address comments
This commit is contained in:
Petro31
2025-05-19 17:26:42 +02:00
committed by GitHub
parent a8ecdb3bff
commit 752c73a2ed
2 changed files with 40 additions and 5 deletions
+33
View File
@@ -788,6 +788,39 @@ async def test_if_fires_on_change_with_for_template_3(
assert len(calls) == 1
@pytest.mark.parametrize(("count", "domain"), [(1, automation.DOMAIN)])
@pytest.mark.parametrize(
"config",
[
{
automation.DOMAIN: {
"trigger_variables": {
"seconds": 5,
"entity": "test.entity",
},
"trigger": {
"platform": "template",
"value_template": "{{ is_state(entity, 'world') }}",
"for": "{{ seconds }}",
},
"action": {"service": "test.automation"},
}
},
],
)
@pytest.mark.usefixtures("start_ha")
async def test_if_fires_on_change_with_for_template_4(
hass: HomeAssistant, calls: list[ServiceCall]
) -> None:
"""Test for firing on change with for template."""
hass.states.async_set("test.entity", "world")
await hass.async_block_till_done()
assert len(calls) == 0
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=10))
await hass.async_block_till_done()
assert len(calls) == 1
@pytest.mark.parametrize(("count", "domain"), [(1, automation.DOMAIN)])
@pytest.mark.parametrize(
"config",