Revert "Add warning when entity used in template doesn't exist" (#58527)

This commit is contained in:
Franck Nijhof 2021-10-27 13:53:26 +02:00 committed by GitHub
parent ad48d78315
commit bf693e85b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 24 deletions

View File

@ -832,12 +832,7 @@ def _get_state_if_valid(hass: HomeAssistant, entity_id: str) -> TemplateState |
def _get_state(hass: HomeAssistant, entity_id: str) -> TemplateState | None:
state_obj = _get_template_state_from_state(
hass, entity_id, hass.states.get(entity_id)
)
if state_obj is None:
_LOGGER.warning("Template warning: entity '%s' doesn't exist", entity_id)
return state_obj
return _get_template_state_from_state(hass, entity_id, hass.states.get(entity_id))
def _get_template_state_from_state(

View File

@ -3219,21 +3219,3 @@ async def test_undefined_variable(hass, caplog):
"Template variable warning: 'no_such_variable' is undefined when rendering '{{ no_such_variable }}'"
in caplog.text
)
async def test_missing_entity(hass, caplog):
"""Test a warning is logged on missing entity."""
hass.states.async_set("binary_sensor.active", "on")
valid_template = template.Template(
"{{ is_state('binary_sensor.active', 'on') }}", hass
)
invalid_template = template.Template(
"{{ is_state('binary_sensor.abcde', 'on') }}", hass
)
assert valid_template.async_render() is True
assert invalid_template.async_render() is False
assert (
"Template warning: entity 'binary_sensor.active' doesn't exist"
not in caplog.text
)
assert "Template warning: entity 'binary_sensor.abcde' doesn't exist" in caplog.text