mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Fix wrong ble device being logged (#83091)
This code can be simplified a bit now that we have the fast bleak lookup. We do connect via the correct path, but we logged the wrong one
This commit is contained in:
parent
3e71436267
commit
56c0eacb08
@ -162,7 +162,6 @@ class HaBleakClientWrapper(BleakClient):
|
||||
self.__address = address_or_ble_device
|
||||
self.__disconnected_callback = disconnected_callback
|
||||
self.__timeout = timeout
|
||||
self.__ble_device: BLEDevice | None = None
|
||||
self._backend: BaseBleakClient | None = None # type: ignore[assignment]
|
||||
|
||||
@property
|
||||
@ -183,12 +182,9 @@ class HaBleakClientWrapper(BleakClient):
|
||||
async def connect(self, **kwargs: Any) -> bool:
|
||||
"""Connect to the specified GATT server."""
|
||||
assert models.MANAGER is not None
|
||||
(
|
||||
wrapped_backend,
|
||||
self.__ble_device,
|
||||
) = self._async_get_best_available_backend_and_device()
|
||||
wrapped_backend = self._async_get_best_available_backend_and_device()
|
||||
self._backend = wrapped_backend.client(
|
||||
self.__ble_device,
|
||||
wrapped_backend.device,
|
||||
disconnected_callback=self.__disconnected_callback,
|
||||
timeout=self.__timeout,
|
||||
hass=models.MANAGER.hass,
|
||||
@ -218,7 +214,7 @@ class HaBleakClientWrapper(BleakClient):
|
||||
@hass_callback
|
||||
def _async_get_best_available_backend_and_device(
|
||||
self,
|
||||
) -> tuple[_HaWrappedBleakBackend, BLEDevice]:
|
||||
) -> _HaWrappedBleakBackend:
|
||||
"""Get a best available backend and device for the given address.
|
||||
|
||||
This method will return the backend with the best rssi
|
||||
@ -235,9 +231,10 @@ class HaBleakClientWrapper(BleakClient):
|
||||
or NO_RSSI_VALUE,
|
||||
reverse=True,
|
||||
):
|
||||
ble_device = device_advertisement_data[0]
|
||||
if backend := self._async_get_backend_for_ble_device(ble_device):
|
||||
return backend, ble_device
|
||||
if backend := self._async_get_backend_for_ble_device(
|
||||
device_advertisement_data[0]
|
||||
):
|
||||
return backend
|
||||
|
||||
raise BleakError(
|
||||
f"No backend with an available connection slot that can reach address {address} was found"
|
||||
|
Loading…
x
Reference in New Issue
Block a user