mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +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
|
@callback
|
||||||
def _async_restore_from_registry(self) -> None:
|
def _async_restore_from_registry(self) -> None:
|
||||||
"""Restore the state of the Coordinator from the device registry."""
|
"""Restore the state of the Coordinator from the device registry."""
|
||||||
for device in self._dev_reg.devices.values():
|
for device in self._dev_reg.devices.get_devices_for_config_entry_id(
|
||||||
unique_id = None
|
self._entry.entry_id
|
||||||
for identifier in device.identifiers:
|
):
|
||||||
if identifier[0] == DOMAIN:
|
if not (identifier := next(iter(device.identifiers), None)):
|
||||||
unique_id = identifier[1]
|
|
||||||
break
|
|
||||||
if not unique_id:
|
|
||||||
continue
|
continue
|
||||||
|
unique_id = identifier[1]
|
||||||
# iBeacons with a fixed MAC address
|
# iBeacons with a fixed MAC address
|
||||||
if unique_id.count("_") == 3:
|
if unique_id.count("_") == 3:
|
||||||
uuid, major, minor, address = unique_id.split("_")
|
uuid, major, minor, address = unique_id.split("_")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user