Avoid linear search of entity registry in ruckus_unleashed (#109643)
parent
74812261d4
commit
6003ae149a
|
@ -18,6 +18,7 @@ from .const import (
|
||||||
KEY_SYS_CLIENTS,
|
KEY_SYS_CLIENTS,
|
||||||
UNDO_UPDATE_LISTENERS,
|
UNDO_UPDATE_LISTENERS,
|
||||||
)
|
)
|
||||||
|
from .coordinator import RuckusUnleashedDataUpdateCoordinator
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__package__)
|
_LOGGER = logging.getLogger(__package__)
|
||||||
|
|
||||||
|
@ -65,14 +66,19 @@ def add_new_entities(coordinator, async_add_entities, tracked):
|
||||||
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def restore_entities(registry, coordinator, entry, async_add_entities, tracked):
|
def restore_entities(
|
||||||
|
registry: er.EntityRegistry,
|
||||||
|
coordinator: RuckusUnleashedDataUpdateCoordinator,
|
||||||
|
entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
tracked: set[str],
|
||||||
|
) -> None:
|
||||||
"""Restore clients that are not a part of active clients list."""
|
"""Restore clients that are not a part of active clients list."""
|
||||||
missing = []
|
missing: list[RuckusUnleashedDevice] = []
|
||||||
|
|
||||||
for entity in registry.entities.values():
|
for entity in registry.entities.get_entries_for_config_entry_id(entry.entry_id):
|
||||||
if (
|
if (
|
||||||
entity.config_entry_id == entry.entry_id
|
entity.platform == DOMAIN
|
||||||
and entity.platform == DOMAIN
|
|
||||||
and entity.unique_id not in coordinator.data[KEY_SYS_CLIENTS]
|
and entity.unique_id not in coordinator.data[KEY_SYS_CLIENTS]
|
||||||
):
|
):
|
||||||
missing.append(
|
missing.append(
|
||||||
|
|
Loading…
Reference in New Issue