-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Add restored entities to entity_sources #146549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
4c09d0e
to
cfb4161
Compare
This is now covered by the test |
@@ -1423,6 +1423,10 @@ async def __async_remove_impl(self, force_remove: bool) -> None: | |||
# Set the entity's state will to unavailable + ATTR_RESTORED: True | |||
self.registry_entry.write_unavailable_state(self.hass) | |||
else: | |||
# The check for self.platform guards against integrations not using an | |||
# EntityComponent and can be removed in HA Core 2024.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to the comment, the check can be removed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, maybe, but not in this PR.
if entry.config_entry_id: | ||
entity_info["config_entry"] = entry.config_entry_id | ||
|
||
entity_sources[entry.entity_id] = entity_info |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since entity.async_internal_added_to_hass
already adds the entity to entity_sources
why is this needed here too?
assuming it is, couldn't we somehow move it to the Entity class, and avoid a circular dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function (_write_unavailable_states
) is called to create unavailable
states for all entities known to the entity registry. There are no backing entity objects.
The point of this PR is to ensure we create entries in entity_sources
for these unavailable
states.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I missed that it does not create Entity objects.
So, it would still be cool to avoid a circular dependency here. Could we move entity_sources
up (to core.py
for maybe)? Or move it to entity_registry.py
, but that doesn't seem right.
Alternatively, could entity_sources be stored in hass.data
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is stored in hass.data
; homeassistant.helpers.entity.entity_sources
returns hass.data["entity_info]"
Proposed change
Add restored entities to
entity_sources
, this makes it possible to pick restored entities filtered by integration in the entity selector, and to improve display of failing helpers.Needs frontend changes for the helper panel
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: