mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Avoid linear search in ibeacon to find devices (#114809)
This commit is contained in:
parent
e909242bc5
commit
d7153d525f
@ -493,14 +493,12 @@ class IBeaconCoordinator:
|
||||
@callback
|
||||
def _async_restore_from_registry(self) -> None:
|
||||
"""Restore the state of the Coordinator from the device registry."""
|
||||
for device in self._dev_reg.devices.values():
|
||||
unique_id = None
|
||||
for identifier in device.identifiers:
|
||||
if identifier[0] == DOMAIN:
|
||||
unique_id = identifier[1]
|
||||
break
|
||||
if not unique_id:
|
||||
for device in self._dev_reg.devices.get_devices_for_config_entry_id(
|
||||
self._entry.entry_id
|
||||
):
|
||||
if not (identifier := next(iter(device.identifiers), None)):
|
||||
continue
|
||||
unique_id = identifier[1]
|
||||
# iBeacons with a fixed MAC address
|
||||
if unique_id.count("_") == 3:
|
||||
uuid, major, minor, address = unique_id.split("_")
|
||||
|
Loading…
x
Reference in New Issue
Block a user