1 """State attributes models."""
3 from __future__
import annotations
10 EMPTY_JSON_OBJECT =
"{}"
11 _LOGGER = logging.getLogger(__name__)
15 source: Any, attr_cache: dict[str, dict[str, Any]]
17 """Decode attributes from a row source."""
18 if not source
or source == EMPTY_JSON_OBJECT:
20 if (attributes := attr_cache.get(source))
is not None:
25 _LOGGER.exception(
"Error converting row to state attributes: %s", source)
26 attr_cache[source] = attributes = {}
dict[str, Any] decode_attributes_from_source(Any source, dict[str, dict[str, Any]] attr_cache)
JsonObjectType json_loads_object(bytes|bytearray|memoryview|str obj)