diff --git a/homeassistant/components/bluetooth/manifest.json b/homeassistant/components/bluetooth/manifest.json index f31a6e0afef5..e525e5ae9255 100644 --- a/homeassistant/components/bluetooth/manifest.json +++ b/homeassistant/components/bluetooth/manifest.json @@ -21,6 +21,6 @@ "bluetooth-auto-recovery==1.6.4", "bluetooth-data-tools==1.29.18", "dbus-fast==5.0.22", - "habluetooth==6.26.2" + "habluetooth==6.26.5" ] } diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index 37e9c989b35b..1673fadae40c 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -35,7 +35,7 @@ file-read-backwards==2.0.0 fnv-hash-fast==2.0.3 go2rtc-client==0.4.0 ha-ffmpeg==3.2.2 -habluetooth==6.26.2 +habluetooth==6.26.5 hass-nabucasa==2.2.0 hassil==3.8.0 home-assistant-bluetooth==2.0.0 diff --git a/requirements_all.txt b/requirements_all.txt index 828728189e44..7606f47553b3 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1213,7 +1213,7 @@ ha-xthings-cloud==1.0.5 habiticalib==0.4.7 # homeassistant.components.bluetooth -habluetooth==6.26.2 +habluetooth==6.26.5 # homeassistant.components.hanna hanna-cloud==0.0.7 diff --git a/tests/components/bluetooth/test_manager.py b/tests/components/bluetooth/test_manager.py index b6f4b1f8ce1e..c8aa6610df5f 100644 --- a/tests/components/bluetooth/test_manager.py +++ b/tests/components/bluetooth/test_manager.py @@ -12,6 +12,9 @@ from habluetooth import BluetoothScanningMode, HaScanner # pylint: disable-next=no-name-in-module from habluetooth.advertisement_tracker import TRACKER_BUFFERING_WOBBLE_SECONDS + +# pylint: disable-next=no-name-in-module +from habluetooth.const import STALE_ROAM_FACTOR import pytest from homeassistant import config_entries @@ -402,9 +405,26 @@ async def test_switching_adapters_based_on_stale_with_discovered_interval( start_time_monotonic + 10 + TRACKER_BUFFERING_WOBBLE_SECONDS + 1, HCI1_SOURCE_ADDRESS, ) - # Should switch to hci1 since the previous advertisement is stale - # even though the signal is poor because the device is now - # likely unreachable via hci0 + # Should not roam yet: a single missed reception interval must not hand a + # stationary device to a comparable scanner before the roam gate + # (STALE_ROAM_FACTOR stale windows) + assert ( + bluetooth.async_ble_device_from_address(hass, address) + is switchbot_device_poor_signal_hci0 + ) + + inject_advertisement_with_time_and_source( + hass, + switchbot_device_poor_signal_hci1, + switchbot_adv_poor_signal_hci1, + start_time_monotonic + + (10 + TRACKER_BUFFERING_WOBBLE_SECONDS) * STALE_ROAM_FACTOR + + 1, + HCI1_SOURCE_ADDRESS, + ) + # Past the roam gate (STALE_ROAM_FACTOR stale windows): switch to hci1 + # since the previous advertisement is stale even though the signal is poor + # because the device is now likely unreachable via hci0 assert ( bluetooth.async_ble_device_from_address(hass, address) is switchbot_device_poor_signal_hci1