1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Allow deleting entity entries from entity_registry.async_migrate_entries (#101094)

* Allow deleting entity entries from entity_registry.async_migrate_entries

* Explicitly return None in tests
This commit is contained in:
Erik Montnemery
2023-09-30 10:23:10 +02:00
committed by GitHub
parent d40a08958d
commit 47ecce4873
2 changed files with 74 additions and 2 deletions

View File

@@ -1323,12 +1323,18 @@ async def async_migrate_entries(
config_entry_id: str,
entry_callback: Callable[[RegistryEntry], dict[str, Any] | None],
) -> None:
"""Migrator of unique IDs."""
"""Migrate entity registry entries which belong to a config entry.
Can be used as a migrator of unique_ids or to update other entity registry data.
Can also be used to remove duplicated entity registry entries.
"""
ent_reg = async_get(hass)
for entry in ent_reg.entities.values():
for entry in list(ent_reg.entities.values()):
if entry.config_entry_id != config_entry_id:
continue
if not ent_reg.entities.get_entry(entry.id):
continue
updates = entry_callback(entry)