mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 17:57:55 +00:00
Avoid linear search of entity registry in keenetic_ndms2 (#109635)
This commit is contained in:
parent
c988d3d427
commit
6ccf82d7b1
@ -75,11 +75,10 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
|
||||
for mac, device in router.last_devices.items()
|
||||
if device.interface in new_tracked_interfaces
|
||||
}
|
||||
for entity_entry in list(ent_reg.entities.values()):
|
||||
if (
|
||||
entity_entry.config_entry_id == config_entry.entry_id
|
||||
and entity_entry.domain == Platform.DEVICE_TRACKER
|
||||
):
|
||||
for entity_entry in ent_reg.entities.get_entries_for_config_entry_id(
|
||||
config_entry.entry_id
|
||||
):
|
||||
if entity_entry.domain == Platform.DEVICE_TRACKER:
|
||||
mac = entity_entry.unique_id.partition("_")[0]
|
||||
if mac not in keep_devices:
|
||||
_LOGGER.debug("Removing entity %s", entity_entry.entity_id)
|
||||
|
@ -43,11 +43,10 @@ async def async_setup_entry(
|
||||
registry = er.async_get(hass)
|
||||
# Restore devices that are not a part of active clients list.
|
||||
restored = []
|
||||
for entity_entry in registry.entities.values():
|
||||
if (
|
||||
entity_entry.config_entry_id == config_entry.entry_id
|
||||
and entity_entry.domain == DEVICE_TRACKER_DOMAIN
|
||||
):
|
||||
for entity_entry in registry.entities.get_entries_for_config_entry_id(
|
||||
config_entry.entry_id
|
||||
):
|
||||
if entity_entry.domain == DEVICE_TRACKER_DOMAIN:
|
||||
mac = entity_entry.unique_id.partition("_")[0]
|
||||
if mac not in tracked:
|
||||
tracked.add(mac)
|
||||
|
Loading…
x
Reference in New Issue
Block a user