Compare commits

...

1 Commits

Author SHA1 Message Date
Franck Nijhof ab01aa4c16 Return enum values as strings in config_entry_attr template function 2026-06-04 17:25:25 +00:00
2 changed files with 6 additions and 2 deletions
@@ -1,6 +1,7 @@
"""Config entry functions for Home Assistant templates."""
from collections.abc import Iterable
from enum import Enum
from typing import TYPE_CHECKING, Any
from homeassistant.exceptions import TemplateError
@@ -104,4 +105,7 @@ class ConfigEntryExtension(BaseTemplateExtension):
if config_entry is None:
return None
return getattr(config_entry, attr_name)
value = getattr(config_entry, attr_name)
if isinstance(value, Enum):
return value.value
return value
@@ -120,7 +120,7 @@ async def test_config_entry_attr(hass: HomeAssistant) -> None:
config_entry = MockConfigEntry(**info)
config_entry.add_to_hass(hass)
info["state"] = config_entries.ConfigEntryState.NOT_LOADED
info["state"] = "not_loaded"
for key, value in info.items():
assert render(