-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Add field "unique_id" to "config/entity_registry/list" websocket response #77476
Add field "unique_id" to "config/entity_registry/list" websocket response #77476
Conversation
…ocket response Signed-off-by: Philipp Waller <[email protected]>
Hi @philippwaller, It seems you haven't yet signed a CLA. Please do so here. Once you do that we will be able to review and accept this pull request. Thanks! |
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( |
@philippwaller please note that the Also, can you give some details on how your changes will be used? |
@@ -240,6 +240,7 @@ def _entry_dict(entry: er.RegistryEntry) -> dict[str, Any]: | |||
"name": entry.name, | |||
"original_name": entry.original_name, | |||
"platform": entry.platform, | |||
"unique_id": entry.unique_id, |
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.
If this is added here, it should be removed from _entry_ext_dict
below
Signed-off-by: Philipp Waller <[email protected]>
Hey @emontnemery, thanks for your feedback! I had picked the "unique_id" field as this is also provided as part of the update response. If we would introduce the RegistryEntry.id (which make sense), other responses need to be adapted as well. The main use case is to identify entities after the entity_id has been changed. I am developing a HA Addon UI that will allow power users to edit registry entries faster (advanced filtering, inline editing, possibly mass updates, etc). For these use cases I needed a constant/reliable UID to keep my EntityCache in sync with the EntityRegistry. |
@philippwaller OK, thanks for explaining the use case. I think it would be better to use the |
You can already get the unique ID by querying specifically for the entity in The best way to keep it up to date is to listen to |
Breaking change
none
Proposed change
Problem Statement
In the current implementation, no unique_id is returned in the config/entity_registry/list websocket response. The client must use the entity_id as the primary key. However, since the entity_id can change during the lifecycle, it is very complex to build a local application cache. When a change is made, it is very tricky to perform an incremental update due to the lack of a constant ID.
Proposed solution
Similar to the "config/entity_registry/update" response, the "config/entity_registry/list" response should also provide a unique_id. This change increases the payload footprint but allows a unique identification over the entire entity lifecycle.
Type of change
Additional information
Checklist
black --fast 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
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: