Use entity_sources to determine integration in recorder platforms (#88382)
This commit is contained in:
parent
728f0d5b3b
commit
83e5bf7ae8
7 changed files with 33 additions and 19 deletions
|
@ -57,11 +57,18 @@ SOURCE_PLATFORM_CONFIG = "platform_config"
|
|||
FLOAT_PRECISION = abs(int(math.floor(math.log10(abs(sys.float_info.epsilon))))) - 1
|
||||
|
||||
|
||||
@callback
|
||||
def async_setup(hass: HomeAssistant) -> None:
|
||||
"""Set up entity sources."""
|
||||
hass.data[DATA_ENTITY_SOURCE] = {}
|
||||
|
||||
|
||||
@callback
|
||||
@bind_hass
|
||||
def entity_sources(hass: HomeAssistant) -> dict[str, dict[str, str]]:
|
||||
"""Get the entity sources."""
|
||||
return hass.data.get(DATA_ENTITY_SOURCE, {})
|
||||
_entity_sources: dict[str, dict[str, str]] = hass.data[DATA_ENTITY_SOURCE]
|
||||
return _entity_sources
|
||||
|
||||
|
||||
def generate_entity_id(
|
||||
|
@ -868,7 +875,7 @@ class Entity(ABC):
|
|||
else:
|
||||
info["source"] = SOURCE_PLATFORM_CONFIG
|
||||
|
||||
self.hass.data.setdefault(DATA_ENTITY_SOURCE, {})[self.entity_id] = info
|
||||
self.hass.data[DATA_ENTITY_SOURCE][self.entity_id] = info
|
||||
|
||||
if self.registry_entry is not None:
|
||||
# This is an assert as it should never happen, but helps in tests
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue