Bump habluetooth to 2.0.1 (#106750)

fixes switching scanners to quickly since the manager failed
to account for jitter in the auto discovered advertising interval

replaces and closes #96531

changelog: https://github.com/Bluetooth-Devices/habluetooth/compare/v2.0.0...v2.0.1
This commit is contained in:
J. Nick Koston 2023-12-31 06:44:55 -10:00 committed by GitHub
parent 70e2ff351d
commit bfda3f1ba8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 89 additions and 5 deletions

View File

@ -20,6 +20,6 @@
"bluetooth-auto-recovery==1.2.3", "bluetooth-auto-recovery==1.2.3",
"bluetooth-data-tools==1.19.0", "bluetooth-data-tools==1.19.0",
"dbus-fast==2.21.0", "dbus-fast==2.21.0",
"habluetooth==2.0.0" "habluetooth==2.0.1"
] ]
} }

View File

@ -24,7 +24,7 @@ dbus-fast==2.21.0
fnv-hash-fast==0.5.0 fnv-hash-fast==0.5.0
ha-av==10.1.1 ha-av==10.1.1
ha-ffmpeg==3.1.0 ha-ffmpeg==3.1.0
habluetooth==2.0.0 habluetooth==2.0.1
hass-nabucasa==0.75.1 hass-nabucasa==0.75.1
hassil==1.5.1 hassil==1.5.1
home-assistant-bluetooth==1.11.0 home-assistant-bluetooth==1.11.0

View File

@ -998,7 +998,7 @@ ha-philipsjs==3.1.1
habitipy==0.2.0 habitipy==0.2.0
# homeassistant.components.bluetooth # homeassistant.components.bluetooth
habluetooth==2.0.0 habluetooth==2.0.1
# homeassistant.components.cloud # homeassistant.components.cloud
hass-nabucasa==0.75.1 hass-nabucasa==0.75.1

View File

@ -800,7 +800,7 @@ ha-philipsjs==3.1.1
habitipy==0.2.0 habitipy==0.2.0
# homeassistant.components.bluetooth # homeassistant.components.bluetooth
habluetooth==2.0.0 habluetooth==2.0.1
# homeassistant.components.cloud # homeassistant.components.cloud
hass-nabucasa==0.75.1 hass-nabucasa==0.75.1

View File

@ -7,11 +7,12 @@ from unittest.mock import patch
from bleak.backends.scanner import AdvertisementData, BLEDevice from bleak.backends.scanner import AdvertisementData, BLEDevice
from bluetooth_adapters import AdvertisementHistory from bluetooth_adapters import AdvertisementHistory
from habluetooth.manager import FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS from habluetooth.advertisement_tracker import TRACKER_BUFFERING_WOBBLE_SECONDS
import pytest import pytest
from homeassistant.components import bluetooth from homeassistant.components import bluetooth
from homeassistant.components.bluetooth import ( from homeassistant.components.bluetooth import (
FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS,
MONOTONIC_TIME, MONOTONIC_TIME,
BaseHaRemoteScanner, BaseHaRemoteScanner,
BluetoothChange, BluetoothChange,
@ -315,6 +316,89 @@ async def test_switching_adapters_based_on_stale(
) )
async def test_switching_adapters_based_on_stale_with_discovered_interval(
hass: HomeAssistant,
enable_bluetooth: None,
register_hci0_scanner: None,
register_hci1_scanner: None,
) -> None:
"""Test switching with discovered interval."""
address = "44:44:33:11:23:41"
start_time_monotonic = 50.0
switchbot_device_poor_signal_hci0 = generate_ble_device(
address, "wohand_poor_signal_hci0"
)
switchbot_adv_poor_signal_hci0 = generate_advertisement_data(
local_name="wohand_poor_signal_hci0", service_uuids=[], rssi=-100
)
inject_advertisement_with_time_and_source(
hass,
switchbot_device_poor_signal_hci0,
switchbot_adv_poor_signal_hci0,
start_time_monotonic,
"hci0",
)
assert (
bluetooth.async_ble_device_from_address(hass, address)
is switchbot_device_poor_signal_hci0
)
bluetooth.async_set_fallback_availability_interval(hass, address, 10)
switchbot_device_poor_signal_hci1 = generate_ble_device(
address, "wohand_poor_signal_hci1"
)
switchbot_adv_poor_signal_hci1 = generate_advertisement_data(
local_name="wohand_poor_signal_hci1", service_uuids=[], rssi=-99
)
inject_advertisement_with_time_and_source(
hass,
switchbot_device_poor_signal_hci1,
switchbot_adv_poor_signal_hci1,
start_time_monotonic,
"hci1",
)
# Should not switch adapters until the advertisement is stale
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 + 1,
"hci1",
)
# Should not switch yet since we are not within the
# wobble period
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 + 1,
"hci1",
)
# 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
assert (
bluetooth.async_ble_device_from_address(hass, address)
is switchbot_device_poor_signal_hci1
)
async def test_restore_history_from_dbus( async def test_restore_history_from_dbus(
hass: HomeAssistant, one_adapter: None, disable_new_discovery_flows hass: HomeAssistant, one_adapter: None, disable_new_discovery_flows
) -> None: ) -> None: