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
Stable entity registry id when a deleted entity is restored #77710
Conversation
Set to draft until restoring of area_id, which is not wanted, is removed |
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
cc9eb60
to
b660a6e
Compare
self.deleted_entities.pop((domain, platform, unique_id)) | ||
# Restore id | ||
entity_registry_id = deleted_entity.id | ||
|
||
entity_id = self.async_generate_entity_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.
How is the entity_id restored when using an entity entry id of a deleted entity?
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.
The entity_id
is not restored. We could add that in a follow-up if it's wanted. We can't guarantee restoring an entity_id
though, or it would mean an entity_id
can only be reused 30 days after it is no longer used.
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.
Ok.
…istant#77710) * Stable entity_id and registry id when a deleted entity is restored * Don't restore area_id * Don't restore entity_id * Address review comments
Proposed change
Ensure entity registry id when a deleted entity is restored.
A deleted entity will be stored in the device registry in a
deleted_entities
list.When adding a new entity, a lookup will be done in the
deleted_entities
before issuing a new entity registry id.entity_id
is not guaranteed to be stabledeleted_entities
will be marked for permanent purge.Background
We're currently migrating to use the entity registry id to reference entities in device automations instead of the
entity_id
.It's a fairly common pattern that users delete and then re-add a config entry when things don't work. Without the changes in this PR, any device automation referencing entities belonging to the re-added config entry will break.
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: