1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Prevent template loop detection from triggering when all templates are self referencing (#41013)

This commit is contained in:
J. Nick Koston
2020-10-01 15:11:11 -05:00
committed by GitHub
parent 1219c95f63
commit deedd41d62
3 changed files with 53 additions and 10 deletions

View File

@@ -1121,3 +1121,48 @@ async def test_state_gets_lowercased(hass):
hass.states.async_set("binary_sensor.garage_door_sensor", "on")
await hass.async_block_till_done()
assert hass.states.get("cover.garage_door").state == STATE_CLOSED
async def test_self_referencing_icon_with_no_template_is_not_a_loop(hass, caplog):
"""Test a self referencing icon with no value template is not a loop."""
icon_template_str = """{% if is_state('cover.office', 'open') %}
mdi:window-shutter-open
{% else %}
mdi:window-shutter
{% endif %}"""
await setup.async_setup_component(
hass,
"cover",
{
"cover": {
"platform": "template",
"covers": {
"office": {
"icon_template": icon_template_str,
"open_cover": {
"service": "switch.turn_on",
"entity_id": "switch.office_blinds_up",
},
"close_cover": {
"service": "switch.turn_on",
"entity_id": "switch.office_blinds_down",
},
"stop_cover": {
"service": "switch.turn_on",
"entity_id": "switch.office_blinds_up",
},
},
},
}
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
assert len(hass.states.async_all()) == 1
assert "Template loop detected" not in caplog.text