mirror of
https://github.com/home-assistant/core.git
synced 2026-08-24 10:13:52 -05:00
Explain why an INKBIRD device could not be found (#172762)
This commit is contained in:
@@ -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,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:
|
||||
|
||||
Reference in New Issue
Block a user