Avoid linear search of entity registry in guardian ()

This commit is contained in:
J. Nick Koston 2024-02-04 14:11:56 -06:00 committed by GitHub
parent b24b4fc237
commit c988d3d427
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -48,9 +48,10 @@ def async_finish_entity_domain_replacements(
try:
[registry_entry] = [
registry_entry
for registry_entry in ent_reg.entities.values()
if registry_entry.config_entry_id == entry.entry_id
and registry_entry.domain == strategy.old_domain
for registry_entry in er.async_entries_for_config_entry(
ent_reg, entry.entry_id
)
if registry_entry.domain == strategy.old_domain
and registry_entry.unique_id == strategy.old_unique_id
]
except ValueError: