mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +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()
|
for mac, device in router.last_devices.items()
|
||||||
if device.interface in new_tracked_interfaces
|
if device.interface in new_tracked_interfaces
|
||||||
}
|
}
|
||||||
for entity_entry in list(ent_reg.entities.values()):
|
for entity_entry in ent_reg.entities.get_entries_for_config_entry_id(
|
||||||
if (
|
config_entry.entry_id
|
||||||
entity_entry.config_entry_id == config_entry.entry_id
|
):
|
||||||
and entity_entry.domain == Platform.DEVICE_TRACKER
|
if entity_entry.domain == Platform.DEVICE_TRACKER:
|
||||||
):
|
|
||||||
mac = entity_entry.unique_id.partition("_")[0]
|
mac = entity_entry.unique_id.partition("_")[0]
|
||||||
if mac not in keep_devices:
|
if mac not in keep_devices:
|
||||||
_LOGGER.debug("Removing entity %s", entity_entry.entity_id)
|
_LOGGER.debug("Removing entity %s", entity_entry.entity_id)
|
||||||
|
@ -43,11 +43,10 @@ async def async_setup_entry(
|
|||||||
registry = er.async_get(hass)
|
registry = er.async_get(hass)
|
||||||
# Restore devices that are not a part of active clients list.
|
# Restore devices that are not a part of active clients list.
|
||||||
restored = []
|
restored = []
|
||||||
for entity_entry in registry.entities.values():
|
for entity_entry in registry.entities.get_entries_for_config_entry_id(
|
||||||
if (
|
config_entry.entry_id
|
||||||
entity_entry.config_entry_id == config_entry.entry_id
|
):
|
||||||
and entity_entry.domain == DEVICE_TRACKER_DOMAIN
|
if entity_entry.domain == DEVICE_TRACKER_DOMAIN:
|
||||||
):
|
|
||||||
mac = entity_entry.unique_id.partition("_")[0]
|
mac = entity_entry.unique_id.partition("_")[0]
|
||||||
if mac not in tracked:
|
if mac not in tracked:
|
||||||
tracked.add(mac)
|
tracked.add(mac)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user