Support unavailable state in template fan (#38114)

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Thomas DelaetandMartin Hjelmare authored and GitHub committed 2020-07-24 15:48:07 +02:00
1 parent 5d28e109e8
commit 3ff5c17009
2 files changed
+63 -4

No files matched your search

+58
View File
@@ -222,6 +222,64 @@ async def test_templates_with_entities(hass, calls):
_verify(hass, STATE_ON, SPEED_MEDIUM, True, DIRECTION_FORWARD)
async def test_template_with_unavailable_entities(hass, calls):
"""Test unavailability with value_template."""
with assert_setup_component(1, "fan"):
assert await setup.async_setup_component(
hass,
"fan",
{
"fan": {
"platform": "template",
"fans": {
"test_fan": {
"value_template": "{{ 'unavailable' }}",
"turn_on": {"service": "script.fan_on"},
"turn_off": {"service": "script.fan_off"},
}
},
}
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
assert hass.states.get(_TEST_FAN).state == STATE_OFF
async def test_template_with_unavailable_parameters(hass, calls):
"""Test unavailability of speed, direction and oscillating parameters."""
with assert_setup_component(1, "fan"):
assert await setup.async_setup_component(
hass,
"fan",
{
"fan": {
"platform": "template",
"fans": {
"test_fan": {
"value_template": "{{ 'on' }}",
"speed_template": "{{ 'unavailable' }}",
"oscillating_template": "{{ 'unavailable' }}",
"direction_template": "{{ 'unavailable' }}",
"turn_on": {"service": "script.fan_on"},
"turn_off": {"service": "script.fan_off"},
}
},
}
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
_verify(hass, STATE_ON, None, None, None)
async def test_availability_template_with_entities(hass, calls):
"""Test availability tempalates with values from other entities."""