Avoid linear search of entity registry in async_get_device_automations (#109633)
This commit is contained in:
parent
6003ae149a
commit
f37db94f23
1 changed files with 4 additions and 3 deletions
|
@ -247,9 +247,10 @@ async def async_get_device_automations(
|
|||
match_device_ids = set(device_ids or device_registry.devices)
|
||||
combined_results: dict[str, list[dict[str, Any]]] = {}
|
||||
|
||||
for entry in entity_registry.entities.values():
|
||||
if not entry.disabled_by and entry.device_id in match_device_ids:
|
||||
device_entities_domains.setdefault(entry.device_id, set()).add(entry.domain)
|
||||
for device_id in match_device_ids:
|
||||
for entry in entity_registry.entities.get_entries_for_device_id(device_id):
|
||||
if not entry.disabled_by:
|
||||
device_entities_domains.setdefault(device_id, set()).add(entry.domain)
|
||||
|
||||
for device_id in match_device_ids:
|
||||
combined_results[device_id] = []
|
||||
|
|
Loading…
Add table
Reference in a new issue