From a9d43db3151be9688b3ed10eb5927e3a4771cd52 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 4 Apr 2024 08:35:07 -1000 Subject: [PATCH] Avoid linear search to clear a config entry in the device registry (#114802) --- homeassistant/helpers/device_registry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/helpers/device_registry.py b/homeassistant/helpers/device_registry.py index 8d5fe3f2f94..2c160262c50 100644 --- a/homeassistant/helpers/device_registry.py +++ b/homeassistant/helpers/device_registry.py @@ -1007,7 +1007,7 @@ class DeviceRegistry(BaseRegistry): def async_clear_config_entry(self, config_entry_id: str) -> None: """Clear config entry from registry entries.""" now_time = time.time() - for device in list(self.devices.values()): + for device in self.devices.get_devices_for_config_entry_id(config_entry_id): self.async_update_device(device.id, remove_config_entry_id=config_entry_id) for deleted_device in list(self.deleted_devices.values()): config_entries = deleted_device.config_entries