Use get_entries_for_config_entry_id helper in async_migrate_entries (#109629)
This commit is contained in:
parent
7e3001f843
commit
b24b4fc237
1 changed files with 6 additions and 10 deletions
|
@ -1379,16 +1379,12 @@ async def async_migrate_entries(
|
||||||
Can also be used to remove duplicated entity registry entries.
|
Can also be used to remove duplicated entity registry entries.
|
||||||
"""
|
"""
|
||||||
ent_reg = async_get(hass)
|
ent_reg = async_get(hass)
|
||||||
|
entities = ent_reg.entities
|
||||||
for entry in list(ent_reg.entities.values()):
|
for entry in entities.get_entries_for_config_entry_id(config_entry_id):
|
||||||
if entry.config_entry_id != config_entry_id:
|
if (
|
||||||
continue
|
entities.get_entry(entry.id)
|
||||||
if not ent_reg.entities.get_entry(entry.id):
|
and (updates := entry_callback(entry)) is not None
|
||||||
continue
|
):
|
||||||
|
|
||||||
updates = entry_callback(entry)
|
|
||||||
|
|
||||||
if updates is not None:
|
|
||||||
ent_reg.async_update_entity(entry.entity_id, **updates)
|
ent_reg.async_update_entity(entry.entity_id, **updates)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue