Adjust esphome bluetooth client logging for unique id change (#83742)

This commit is contained in:
J. Nick Koston 2022-12-10 17:45:59 -10:00 committed by GitHub
parent d3df4dd3c1
commit 7178cacdc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 15 deletions

View File

@ -78,7 +78,7 @@ def verify_connected(func: _WrapFuncType) -> _WrapFuncType:
with contextlib.suppress(asyncio.CancelledError):
await task
raise BleakError(
f"{self._source}: {self._ble_device.name} - {self._ble_device.address}: " # pylint: disable=protected-access
f"{self._source_name}: {self._ble_device.name} - {self._ble_device.address}: " # pylint: disable=protected-access
"Disconnected during operation"
)
return next(iter(done)).result()
@ -109,7 +109,7 @@ def api_error_as_bleak_error(func: _WrapFuncType) -> _WrapFuncType:
if ex.error.error == -1:
_LOGGER.debug(
"%s: %s - %s: BLE device disconnected during %s operation",
self._source,
self._source_name,
self._ble_device.name,
self._ble_device.address,
func.__name__,
@ -154,6 +154,7 @@ class ESPHomeClient(BaseBleakClient):
assert device_info is not None
self._connection_version = device_info.bluetooth_proxy_version
self._address_type = address_or_ble_device.details["address_type"]
self._source_name = f"{config_entry.title} [{self._source}]"
def __str__(self) -> str:
"""Return the string representation of the client."""
@ -168,7 +169,7 @@ class ESPHomeClient(BaseBleakClient):
except (AssertionError, ValueError) as ex:
_LOGGER.debug(
"%s: %s - %s: Failed to unsubscribe from connection state (likely connection dropped): %s",
self._source,
self._source_name,
self._ble_device.name,
self._ble_device.address,
ex,
@ -194,7 +195,7 @@ class ESPHomeClient(BaseBleakClient):
if was_connected:
_LOGGER.debug(
"%s: %s - %s: BLE device disconnected",
self._source,
self._source_name,
self._ble_device.name,
self._ble_device.address,
)
@ -204,7 +205,7 @@ class ESPHomeClient(BaseBleakClient):
"""Handle the esp32 client disconnecting from hass."""
_LOGGER.debug(
"%s: %s - %s: ESP device disconnected",
self._source,
self._source_name,
self._ble_device.name,
self._ble_device.address,
)
@ -245,7 +246,7 @@ class ESPHomeClient(BaseBleakClient):
"""Handle a connect or disconnect."""
_LOGGER.debug(
"%s: %s - %s: Connection state changed to connected=%s mtu=%s error=%s",
self._source,
self._source_name,
self._ble_device.name,
self._ble_device.address,
connected,
@ -286,7 +287,7 @@ class ESPHomeClient(BaseBleakClient):
_LOGGER.debug(
"%s: %s - %s: connected, registering for disconnected callbacks",
self._source,
self._source_name,
self._ble_device.name,
self._ble_device.address,
)
@ -295,7 +296,7 @@ class ESPHomeClient(BaseBleakClient):
timeout = kwargs.get("timeout", self._timeout)
if not (scanner := async_scanner_by_source(self._hass, self._source)):
raise BleakError("Scanner disappeared for {self._source}")
raise BleakError("Scanner disappeared for {self._source_name}")
with scanner.connecting():
try:
self._cancel_connection_state = (
@ -352,7 +353,7 @@ class ESPHomeClient(BaseBleakClient):
return
_LOGGER.debug(
"%s: %s - %s: Out of connection slots, waiting for a free one",
self._source,
self._source_name,
self._ble_device.name,
self._ble_device.address,
)
@ -401,7 +402,7 @@ class ESPHomeClient(BaseBleakClient):
) and (cached_services := entry_data.get_gatt_services_cache(address_as_int)):
_LOGGER.debug(
"%s: %s - %s: Cached services hit",
self._source,
self._source_name,
self._ble_device.name,
self._ble_device.address,
)
@ -409,7 +410,7 @@ class ESPHomeClient(BaseBleakClient):
return self.services
_LOGGER.debug(
"%s: %s - %s: Cached services miss",
self._source,
self._source_name,
self._ble_device.name,
self._ble_device.address,
)
@ -418,7 +419,7 @@ class ESPHomeClient(BaseBleakClient):
)
_LOGGER.debug(
"%s: %s - %s: Got services: %s",
self._source,
self._source_name,
self._ble_device.name,
self._ble_device.address,
esphome_services,
@ -453,7 +454,7 @@ class ESPHomeClient(BaseBleakClient):
self.services = services
_LOGGER.debug(
"%s: %s - %s: Cached services saved",
self._source,
self._source_name,
self._ble_device.name,
self._ble_device.address,
)
@ -612,7 +613,7 @@ class ESPHomeClient(BaseBleakClient):
_LOGGER.debug(
"%s: %s - %s: Writing to CCD descriptor %s for notifications with properties=%s",
self._source,
self._source_name,
self._ble_device.name,
self._ble_device.address,
cccd_descriptor.handle,
@ -650,7 +651,7 @@ class ESPHomeClient(BaseBleakClient):
if self._cancel_connection_state:
_LOGGER.warning(
"%s: %s - %s: ESPHomeClient bleak client was not properly disconnected before destruction",
self._source,
self._source_name,
self._ble_device.name,
self._ble_device.address,
)