Add shorthand notation for Template conditions (#39705)

This commit is contained in:
Franck Nijhof authored and GitHub committed 2020-09-06 16:55:06 +02:00
1 parent da9b077c11
commit a3c45a6f89
6 files changed
+87 -43

No files matched your search

+25
View File
@@ -232,6 +232,31 @@ async def test_two_conditions_with_and(hass, calls):
assert len(calls) == 1
async def test_shorthand_conditions_template(hass, calls):
"""Test shorthand nation form in conditions."""
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: {
"trigger": [{"platform": "event", "event_type": "test_event"}],
"condition": "{{ is_state('test.entity', 'hello') }}",
"action": {"service": "test.automation"},
}
},
)
hass.states.async_set("test.entity", "hello")
hass.bus.async_fire("test_event")
await hass.async_block_till_done()
assert len(calls) == 1
hass.states.async_set("test.entity", "goodbye")
hass.bus.async_fire("test_event")
await hass.async_block_till_done()
assert len(calls) == 1
async def test_automation_list_setting(hass, calls):
"""Event is not a valid condition."""
assert await async_setup_component(