mirror of
https://github.com/home-assistant/core.git
synced 2026-08-24 10:13:52 -05:00
Widen the INKBIRD IBS-TH2 active scan window to 30s (#174565)
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user