Improve improv via BLE log messages (#135575)

This commit is contained in:
Erik Montnemery 2025-01-14 10:00:21 +01:00 committed by GitHub
parent 09e2168f72
commit 440cd5bee0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 4 deletions

View File

@ -126,15 +126,23 @@ class ImprovBLEConfigFlow(ConfigFlow, domain=DOMAIN):
)
except improv_ble_errors.InvalidCommand as err:
_LOGGER.warning(
"Aborting improv flow, device %s sent invalid improv data: '%s'",
self._discovery_info.address,
(
"Received invalid improv via BLE data '%s' from device with "
"bluetooth address '%s'; if the device is a self-configured "
"ESPHome device, either correct or disable the 'esp32_improv' "
"configuration; if it's a commercial device, contact the vendor"
),
service_data[SERVICE_DATA_UUID].hex(),
self._discovery_info.address,
)
raise AbortFlow("invalid_improv_data") from err
if improv_service_data.state in (State.PROVISIONING, State.PROVISIONED):
_LOGGER.debug(
"Aborting improv flow, device %s is already provisioned: %s",
(
"Aborting improv flow, device with bluetooth address '%s' is "
"already provisioned: %s"
),
self._discovery_info.address,
improv_service_data.state,
)

View File

@ -664,6 +664,6 @@ async def test_provision_fails_invalid_data(
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "invalid_improv_data"
assert (
"Aborting improv flow, device AA:BB:CC:DD:EE:F0 sent invalid improv data: '000000000000'"
"Received invalid improv via BLE data '000000000000' from device with bluetooth address 'AA:BB:CC:DD:EE:F0'"
in caplog.text
)