diff --git a/homeassistant/helpers/template.py b/homeassistant/helpers/template.py index 150d049b1b8..916d203782a 100644 --- a/homeassistant/helpers/template.py +++ b/homeassistant/helpers/template.py @@ -1939,6 +1939,7 @@ class TemplateEnvironment(ImmutableSandboxedEnvironment): self.globals["unpack"] = struct_unpack self.globals["slugify"] = slugify self.globals["iif"] = iif + self.tests["is_number"] = is_number self.tests["match"] = regex_match self.tests["search"] = regex_search diff --git a/tests/helpers/test_template.py b/tests/helpers/test_template.py index dd6d29a8c95..42834b3c149 100644 --- a/tests/helpers/test_template.py +++ b/tests/helpers/test_template.py @@ -314,6 +314,12 @@ def test_isnumber(hass, value, expected): ) == expected ) + assert ( + template.Template("{{ value is is_number }}", hass).async_render( + {"value": value} + ) + == expected + ) def test_rounding_value(hass):