Explain why an INKBIRD device could not be found (#172762)

This commit is contained in:
J. Nick Koston
2026-06-01 20:12:49 +01:00
committed by GitHub
parent 1865c16041
commit 063fa8df7e
3 changed files with 25 additions and 5 deletions
@@ -7,9 +7,11 @@ from typing import Any
from inkbird_ble import INKBIRDBluetoothDeviceData, SensorUpdate
from homeassistant.components.bluetooth import (
BluetoothReachabilityIntent,
BluetoothScanningMode,
BluetoothServiceInfo,
BluetoothServiceInfoBleak,
async_address_reachability_diagnostics,
async_ble_device_from_address,
async_last_service_info,
)
@@ -84,7 +86,14 @@ class INKBIRDActiveBluetoothProcessorCoordinator(
raise ConfigEntryNotReady(
translation_domain=DOMAIN,
translation_key="no_advertisement",
translation_placeholders={"address": self.address},
translation_placeholders={
"address": self.address,
"reason": async_address_reachability_diagnostics(
self.hass,
self.address.upper(),
BluetoothReachabilityIntent.ACTIVE_ADVERTISEMENT,
),
},
)
await self._data.async_start(service_info, service_info.device)
self._entry.async_on_unload(self._data.async_stop)
@@ -20,7 +20,7 @@
},
"exceptions": {
"no_advertisement": {
"message": "The device with address {address} is not advertising; Make sure it is in range and powered on."
"message": "The device with address {address} is not advertising: {reason}"
}
}
}
+14 -3
View File
@@ -14,6 +14,7 @@ from inkbird_ble import (
Units,
)
from inkbird_ble.parser import Model
import pytest
from sensor_state_data import SensorDeviceClass
from homeassistant.components.bluetooth import async_last_service_info
@@ -210,7 +211,9 @@ async def test_fallback_poll_queries_latest_service_info(hass: HomeAssistant) ->
await hass.async_block_till_done()
async def test_notify_sensor_no_advertisement(hass: HomeAssistant) -> None:
async def test_notify_sensor_no_advertisement(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
) -> None:
"""Test setting up a notify sensor that has no advertisement."""
entry = MockConfigEntry(
domain=DOMAIN,
@@ -219,10 +222,18 @@ async def test_notify_sensor_no_advertisement(hass: HomeAssistant) -> None:
)
entry.add_to_hass(hass)
assert not await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
with patch(
"homeassistant.components.inkbird.coordinator."
"async_address_reachability_diagnostics",
return_value="mock reachability reason",
):
assert not await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
assert entry.state is ConfigEntryState.SETUP_RETRY
assert (
"62:00:A1:3C:AE:7B is not advertising: mock reachability reason" in caplog.text
)
async def test_notify_sensor(hass: HomeAssistant) -> None: