From 13a5038c1720996b1dd9282852629aa5c340a3f3 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 4 Feb 2024 14:12:43 -0600 Subject: [PATCH] Avoid linear search of entity registry in lcn (#109638) --- homeassistant/components/lcn/helpers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/lcn/helpers.py b/homeassistant/components/lcn/helpers.py index 64a789f3a34..8cb0201033e 100644 --- a/homeassistant/components/lcn/helpers.py +++ b/homeassistant/components/lcn/helpers.py @@ -286,7 +286,8 @@ def purge_device_registry( # Find all devices that are referenced in the entity registry. references_entities = { - entry.device_id for entry in entity_registry.entities.values() + entry.device_id + for entry in entity_registry.entities.get_entries_for_config_entry_id(entry_id) } # Find device that references the host.