mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 06:47:09 +00:00
Fix elk attributes not being json serializable (#73096)
* Fix jsonifying. * Only serialize Enums
This commit is contained in:
parent
5fe9e8cb1c
commit
c4763031ab
@ -2,6 +2,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from enum import Enum
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
from types import MappingProxyType
|
from types import MappingProxyType
|
||||||
@ -481,7 +482,10 @@ class ElkEntity(Entity):
|
|||||||
@property
|
@property
|
||||||
def extra_state_attributes(self) -> dict[str, Any]:
|
def extra_state_attributes(self) -> dict[str, Any]:
|
||||||
"""Return the default attributes of the element."""
|
"""Return the default attributes of the element."""
|
||||||
return {**self._element.as_dict(), **self.initial_attrs()}
|
dict_as_str = {}
|
||||||
|
for key, val in self._element.as_dict().items():
|
||||||
|
dict_as_str[key] = val.value if isinstance(val, Enum) else val
|
||||||
|
return {**dict_as_str, **self.initial_attrs()}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user