From babfdaac548ffb843822b846e226527a7db0c132 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 4 Feb 2024 14:13:23 -0600 Subject: [PATCH] Avoid linear search of entity registry in mikrotik (#109639) --- homeassistant/components/mikrotik/device_tracker.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/mikrotik/device_tracker.py b/homeassistant/components/mikrotik/device_tracker.py index 14fbb83b61b..8136334514f 100644 --- a/homeassistant/components/mikrotik/device_tracker.py +++ b/homeassistant/components/mikrotik/device_tracker.py @@ -34,11 +34,10 @@ async def async_setup_entry( registry = er.async_get(hass) # Restore clients that is not a part of active clients list. - for entity in registry.entities.values(): - if ( - entity.config_entry_id == config_entry.entry_id - and entity.domain == DEVICE_TRACKER - ): + for entity in registry.entities.get_entries_for_config_entry_id( + config_entry.entry_id + ): + if entity.domain == DEVICE_TRACKER: if ( entity.unique_id in coordinator.api.devices or entity.unique_id not in coordinator.api.all_devices