Improve performance of Bluetooth device fallback (#79078)

This commit is contained in:
J. Nick Koston 2022-09-26 03:12:08 -10:00 committed by GitHub
parent a8b8b245d1
commit 75f6f9b5e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 155 additions and 24 deletions

View file

@ -1,4 +1,5 @@
"""Bluetooth scanner for esphome."""
from __future__ import annotations
from collections.abc import Callable
import datetime
@ -77,6 +78,10 @@ class ESPHomeScannner(BaseHaScanner):
"""Return a list of discovered devices."""
return list(self._discovered_devices.values())
async def async_get_device_by_address(self, address: str) -> BLEDevice | None:
"""Get a device by address."""
return self._discovered_devices.get(address)
@callback
def async_on_advertisement(self, adv: BluetoothLEAdvertisement) -> None:
"""Call the registered callback."""