mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add debug logging for which adapter is used to connect bluetooth devices (#103264)
Log which adapter is used to connect bluetooth devices This is a debug logging improvement to help users find problems with their setup
This commit is contained in:
parent
a63c420890
commit
c81ada16ba
@ -270,6 +270,8 @@ class HaBleakClientWrapper(BleakClient):
|
|||||||
"""Connect to the specified GATT server."""
|
"""Connect to the specified GATT server."""
|
||||||
assert models.MANAGER is not None
|
assert models.MANAGER is not None
|
||||||
manager = models.MANAGER
|
manager = models.MANAGER
|
||||||
|
if debug_logging := _LOGGER.isEnabledFor(logging.DEBUG):
|
||||||
|
_LOGGER.debug("%s: Looking for backend to connect", self.__address)
|
||||||
wrapped_backend = self._async_get_best_available_backend_and_device(manager)
|
wrapped_backend = self._async_get_best_available_backend_and_device(manager)
|
||||||
device = wrapped_backend.device
|
device = wrapped_backend.device
|
||||||
scanner = wrapped_backend.scanner
|
scanner = wrapped_backend.scanner
|
||||||
@ -281,12 +283,14 @@ class HaBleakClientWrapper(BleakClient):
|
|||||||
timeout=self.__timeout,
|
timeout=self.__timeout,
|
||||||
hass=manager.hass,
|
hass=manager.hass,
|
||||||
)
|
)
|
||||||
if debug_logging := _LOGGER.isEnabledFor(logging.DEBUG):
|
if debug_logging:
|
||||||
# Only lookup the description if we are going to log it
|
# Only lookup the description if we are going to log it
|
||||||
description = ble_device_description(device)
|
description = ble_device_description(device)
|
||||||
_, adv = scanner.discovered_devices_and_advertisement_data[device.address]
|
_, adv = scanner.discovered_devices_and_advertisement_data[device.address]
|
||||||
rssi = adv.rssi
|
rssi = adv.rssi
|
||||||
_LOGGER.debug("%s: Connecting (last rssi: %s)", description, rssi)
|
_LOGGER.debug(
|
||||||
|
"%s: Connecting via %s (last rssi: %s)", description, scanner.name, rssi
|
||||||
|
)
|
||||||
connected = None
|
connected = None
|
||||||
try:
|
try:
|
||||||
connected = await super().connect(**kwargs)
|
connected = await super().connect(**kwargs)
|
||||||
@ -301,7 +305,9 @@ class HaBleakClientWrapper(BleakClient):
|
|||||||
manager.async_release_connection_slot(device)
|
manager.async_release_connection_slot(device)
|
||||||
|
|
||||||
if debug_logging:
|
if debug_logging:
|
||||||
_LOGGER.debug("%s: Connected (last rssi: %s)", description, rssi)
|
_LOGGER.debug(
|
||||||
|
"%s: Connected via %s (last rssi: %s)", description, scanner.name, rssi
|
||||||
|
)
|
||||||
return connected
|
return connected
|
||||||
|
|
||||||
@hass_callback
|
@hass_callback
|
||||||
|
Loading…
x
Reference in New Issue
Block a user