mirror of
https://github.com/home-assistant/core.git
synced 2026-08-28 02:24:46 -05:00
Return enum values as strings in config_entry_attr template function
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user