Widen the INKBIRD IBS-TH2 active scan window to 30s (#174565)

This commit is contained in:
J. Nick Koston
2026-06-23 21:02:55 -04:00
committed by GitHub
parent fb283dfb93
commit 40aa8dd617
2 changed files with 27 additions and 3 deletions
@@ -31,8 +31,9 @@ FALLBACK_POLL_INTERVAL = timedelta(seconds=180)
# IBS-TH2 broadcasts every ~20-30s and only carries sensor data in the scan
# response, so the default 10s active window misses the device most cycles.
# 25s covers one full broadcast interval with margin to absorb jitter.
ACTIVE_SCAN_DURATION = 25.0
# 30s is the longest active window habluetooth allows (AUTO_WINDOW_MAX_DURATION)
# and spans a full broadcast interval even at the 30s end of the range.
ACTIVE_SCAN_DURATION = 30.0
class INKBIRDActiveBluetoothProcessorCoordinator(
+24 -1
View File
@@ -23,7 +23,10 @@ from homeassistant.components.inkbird.const import (
CONF_DEVICE_TYPE,
DOMAIN,
)
from homeassistant.components.inkbird.coordinator import FALLBACK_POLL_INTERVAL
from homeassistant.components.inkbird.coordinator import (
ACTIVE_SCAN_DURATION,
FALLBACK_POLL_INTERVAL,
)
from homeassistant.components.sensor import ATTR_STATE_CLASS
from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import ATTR_FRIENDLY_NAME, ATTR_UNIT_OF_MEASUREMENT
@@ -101,6 +104,26 @@ async def test_sensors(hass: HomeAssistant) -> None:
await hass.async_block_till_done()
async def test_active_scan_duration(hass: HomeAssistant) -> None:
"""Test the scan response only IBS-TH registers a wide active scan window."""
entry = MockConfigEntry(
domain=DOMAIN,
unique_id="61DE521B-F0BF-9F44-64D4-75BBE1738105",
data={CONF_DEVICE_TYPE: "IBS-TH"},
)
entry.add_to_hass(hass)
with patch(
"homeassistant.components.bluetooth.update_coordinator.async_register_callback"
) as mock_register_callback:
assert await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
assert mock_register_callback.call_args.kwargs["scan_duration"] == (
ACTIVE_SCAN_DURATION
)
async def test_device_with_corrupt_name(hass: HomeAssistant) -> None:
"""Test setting up a known device type with a corrupt name."""
entry = MockConfigEntry(