diff --git a/homeassistant/helpers/template.py b/homeassistant/helpers/template.py index 8d284f042c2..73e1400cedf 100644 --- a/homeassistant/helpers/template.py +++ b/homeassistant/helpers/template.py @@ -1368,10 +1368,12 @@ def distance(hass, *args): ) -def is_state(hass: HomeAssistant, entity_id: str, state: State) -> bool: +def is_state(hass: HomeAssistant, entity_id: str, state: str | list[str]) -> bool: """Test if a state is a specific value.""" state_obj = _get_state(hass, entity_id) - return state_obj is not None and state_obj.state == state + return state_obj is not None and ( + state_obj.state == state or isinstance(state, list) and state_obj.state in state + ) def is_state_attr(hass: HomeAssistant, entity_id: str, name: str, value: Any) -> bool: diff --git a/tests/helpers/test_template.py b/tests/helpers/test_template.py index 07463787a8b..e19daf00627 100644 --- a/tests/helpers/test_template.py +++ b/tests/helpers/test_template.py @@ -1389,6 +1389,14 @@ def test_is_state(hass: HomeAssistant) -> None: ) assert tpl.async_render() == "test.object" + tpl = template.Template( + """ +{{ is_state("test.object", ["on", "off", "available"]) }} + """, + hass, + ) + assert tpl.async_render() is True + def test_is_state_attr(hass: HomeAssistant) -> None: """Test is_state_attr method."""