mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Bump habluetooth to 2.5.2 (#115721)
This commit is contained in:
parent
e7076ac83f
commit
6dcfe861fd
@ -20,6 +20,6 @@
|
|||||||
"bluetooth-auto-recovery==1.4.0",
|
"bluetooth-auto-recovery==1.4.0",
|
||||||
"bluetooth-data-tools==1.19.0",
|
"bluetooth-data-tools==1.19.0",
|
||||||
"dbus-fast==2.21.1",
|
"dbus-fast==2.21.1",
|
||||||
"habluetooth==2.4.2"
|
"habluetooth==2.5.2"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ dbus-fast==2.21.1
|
|||||||
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.2.0
|
ha-ffmpeg==3.2.0
|
||||||
habluetooth==2.4.2
|
habluetooth==2.5.2
|
||||||
hass-nabucasa==0.78.0
|
hass-nabucasa==0.78.0
|
||||||
hassil==1.6.1
|
hassil==1.6.1
|
||||||
home-assistant-bluetooth==1.12.0
|
home-assistant-bluetooth==1.12.0
|
||||||
|
@ -1029,7 +1029,7 @@ ha-philipsjs==3.1.1
|
|||||||
habitipy==0.2.0
|
habitipy==0.2.0
|
||||||
|
|
||||||
# homeassistant.components.bluetooth
|
# homeassistant.components.bluetooth
|
||||||
habluetooth==2.4.2
|
habluetooth==2.5.2
|
||||||
|
|
||||||
# homeassistant.components.cloud
|
# homeassistant.components.cloud
|
||||||
hass-nabucasa==0.78.0
|
hass-nabucasa==0.78.0
|
||||||
|
@ -843,7 +843,7 @@ ha-philipsjs==3.1.1
|
|||||||
habitipy==0.2.0
|
habitipy==0.2.0
|
||||||
|
|
||||||
# homeassistant.components.bluetooth
|
# homeassistant.components.bluetooth
|
||||||
habluetooth==2.4.2
|
habluetooth==2.5.2
|
||||||
|
|
||||||
# homeassistant.components.cloud
|
# homeassistant.components.cloud
|
||||||
hass-nabucasa==0.78.0
|
hass-nabucasa==0.78.0
|
||||||
|
@ -22,7 +22,6 @@ from homeassistant.setup import async_setup_component
|
|||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
_get_manager,
|
|
||||||
async_setup_with_one_adapter,
|
async_setup_with_one_adapter,
|
||||||
generate_advertisement_data,
|
generate_advertisement_data,
|
||||||
generate_ble_device,
|
generate_ble_device,
|
||||||
@ -183,7 +182,7 @@ async def test_adapter_needs_reset_at_start(
|
|||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
"habluetooth.scanner.OriginalBleakScanner.start",
|
"habluetooth.scanner.OriginalBleakScanner.start",
|
||||||
side_effect=[BleakError(error), None],
|
side_effect=[BleakError(error), BleakError(error), None],
|
||||||
),
|
),
|
||||||
patch(
|
patch(
|
||||||
"habluetooth.util.recover_adapter", return_value=True
|
"habluetooth.util.recover_adapter", return_value=True
|
||||||
@ -239,46 +238,47 @@ async def test_recovery_from_dbus_restart(
|
|||||||
|
|
||||||
assert called_start == 1
|
assert called_start == 1
|
||||||
|
|
||||||
start_time_monotonic = time.monotonic()
|
start_time_monotonic = time.monotonic()
|
||||||
mock_discovered = [MagicMock()]
|
mock_discovered = [MagicMock()]
|
||||||
|
|
||||||
# Ensure we don't restart the scanner if we don't need to
|
# Ensure we don't restart the scanner if we don't need to
|
||||||
with patch_bluetooth_time(
|
with patch_bluetooth_time(
|
||||||
start_time_monotonic + 10,
|
start_time_monotonic + 10,
|
||||||
):
|
):
|
||||||
async_fire_time_changed(hass, dt_util.utcnow() + SCANNER_WATCHDOG_INTERVAL)
|
async_fire_time_changed(hass, dt_util.utcnow() + SCANNER_WATCHDOG_INTERVAL)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert called_start == 1
|
assert called_start == 1
|
||||||
|
|
||||||
# Fire a callback to reset the timer
|
# Fire a callback to reset the timer
|
||||||
with patch_bluetooth_time(
|
with patch_bluetooth_time(
|
||||||
start_time_monotonic,
|
start_time_monotonic,
|
||||||
):
|
):
|
||||||
_callback(
|
_callback(
|
||||||
generate_ble_device("44:44:33:11:23:42", "any_name"),
|
generate_ble_device("44:44:33:11:23:42", "any_name"),
|
||||||
generate_advertisement_data(local_name="any_name"),
|
generate_advertisement_data(local_name="any_name"),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Ensure we don't restart the scanner if we don't need to
|
# Ensure we don't restart the scanner if we don't need to
|
||||||
with patch_bluetooth_time(
|
with patch_bluetooth_time(
|
||||||
start_time_monotonic + 20,
|
start_time_monotonic + 20,
|
||||||
):
|
):
|
||||||
async_fire_time_changed(hass, dt_util.utcnow() + SCANNER_WATCHDOG_INTERVAL)
|
async_fire_time_changed(hass, dt_util.utcnow() + SCANNER_WATCHDOG_INTERVAL)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert called_start == 1
|
assert called_start == 1
|
||||||
|
|
||||||
# We hit the timer, so we restart the scanner
|
# We hit the timer, so we restart the scanner
|
||||||
with patch_bluetooth_time(
|
with patch_bluetooth_time(
|
||||||
start_time_monotonic + SCANNER_WATCHDOG_TIMEOUT + 20,
|
start_time_monotonic + SCANNER_WATCHDOG_TIMEOUT + 20,
|
||||||
):
|
):
|
||||||
async_fire_time_changed(
|
async_fire_time_changed(
|
||||||
hass, dt_util.utcnow() + SCANNER_WATCHDOG_INTERVAL + timedelta(seconds=20)
|
hass,
|
||||||
)
|
dt_util.utcnow() + SCANNER_WATCHDOG_INTERVAL + timedelta(seconds=20),
|
||||||
await hass.async_block_till_done()
|
)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert called_start == 2
|
assert called_start == 2
|
||||||
|
|
||||||
|
|
||||||
async def test_adapter_recovery(hass: HomeAssistant, one_adapter: None) -> None:
|
async def test_adapter_recovery(hass: HomeAssistant, one_adapter: None) -> None:
|
||||||
@ -327,43 +327,42 @@ async def test_adapter_recovery(hass: HomeAssistant, one_adapter: None) -> None:
|
|||||||
|
|
||||||
assert called_start == 1
|
assert called_start == 1
|
||||||
|
|
||||||
scanner = _get_manager()
|
mock_discovered = [MagicMock()]
|
||||||
mock_discovered = [MagicMock()]
|
|
||||||
|
|
||||||
# Ensure we don't restart the scanner if we don't need to
|
# Ensure we don't restart the scanner if we don't need to
|
||||||
with patch_bluetooth_time(
|
with patch_bluetooth_time(
|
||||||
start_time_monotonic + 10,
|
start_time_monotonic + 10,
|
||||||
):
|
):
|
||||||
async_fire_time_changed(hass, dt_util.utcnow() + SCANNER_WATCHDOG_INTERVAL)
|
async_fire_time_changed(hass, dt_util.utcnow() + SCANNER_WATCHDOG_INTERVAL)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert called_start == 1
|
assert called_start == 1
|
||||||
|
|
||||||
# Ensure we don't restart the scanner if we don't need to
|
# Ensure we don't restart the scanner if we don't need to
|
||||||
with patch_bluetooth_time(
|
with patch_bluetooth_time(
|
||||||
start_time_monotonic + 20,
|
start_time_monotonic + 20,
|
||||||
):
|
):
|
||||||
async_fire_time_changed(hass, dt_util.utcnow() + SCANNER_WATCHDOG_INTERVAL)
|
async_fire_time_changed(hass, dt_util.utcnow() + SCANNER_WATCHDOG_INTERVAL)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert called_start == 1
|
assert called_start == 1
|
||||||
|
|
||||||
# We hit the timer with no detections, so we reset the adapter and restart the scanner
|
# We hit the timer with no detections, so we reset the adapter and restart the scanner
|
||||||
with (
|
with (
|
||||||
patch_bluetooth_time(
|
patch_bluetooth_time(
|
||||||
start_time_monotonic
|
start_time_monotonic
|
||||||
+ SCANNER_WATCHDOG_TIMEOUT
|
+ SCANNER_WATCHDOG_TIMEOUT
|
||||||
+ SCANNER_WATCHDOG_INTERVAL.total_seconds(),
|
+ SCANNER_WATCHDOG_INTERVAL.total_seconds(),
|
||||||
),
|
),
|
||||||
patch(
|
patch(
|
||||||
"habluetooth.util.recover_adapter", return_value=True
|
"habluetooth.util.recover_adapter", return_value=True
|
||||||
) as mock_recover_adapter,
|
) as mock_recover_adapter,
|
||||||
):
|
):
|
||||||
async_fire_time_changed(hass, dt_util.utcnow() + SCANNER_WATCHDOG_INTERVAL)
|
async_fire_time_changed(hass, dt_util.utcnow() + SCANNER_WATCHDOG_INTERVAL)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(mock_recover_adapter.mock_calls) == 1
|
assert len(mock_recover_adapter.mock_calls) == 1
|
||||||
assert called_start == 2
|
assert called_start == 2
|
||||||
|
|
||||||
|
|
||||||
async def test_adapter_scanner_fails_to_start_first_time(
|
async def test_adapter_scanner_fails_to_start_first_time(
|
||||||
@ -418,61 +417,61 @@ async def test_adapter_scanner_fails_to_start_first_time(
|
|||||||
|
|
||||||
assert called_start == 1
|
assert called_start == 1
|
||||||
|
|
||||||
scanner = _get_manager()
|
mock_discovered = [MagicMock()]
|
||||||
mock_discovered = [MagicMock()]
|
|
||||||
|
|
||||||
# Ensure we don't restart the scanner if we don't need to
|
# Ensure we don't restart the scanner if we don't need to
|
||||||
with patch_bluetooth_time(
|
with patch_bluetooth_time(
|
||||||
start_time_monotonic + 10,
|
start_time_monotonic + 10,
|
||||||
):
|
):
|
||||||
async_fire_time_changed(hass, dt_util.utcnow() + SCANNER_WATCHDOG_INTERVAL)
|
async_fire_time_changed(hass, dt_util.utcnow() + SCANNER_WATCHDOG_INTERVAL)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert called_start == 1
|
assert called_start == 1
|
||||||
|
|
||||||
# Ensure we don't restart the scanner if we don't need to
|
# Ensure we don't restart the scanner if we don't need to
|
||||||
with patch_bluetooth_time(
|
with patch_bluetooth_time(
|
||||||
start_time_monotonic + 20,
|
start_time_monotonic + 20,
|
||||||
):
|
):
|
||||||
async_fire_time_changed(hass, dt_util.utcnow() + SCANNER_WATCHDOG_INTERVAL)
|
async_fire_time_changed(hass, dt_util.utcnow() + SCANNER_WATCHDOG_INTERVAL)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert called_start == 1
|
assert called_start == 1
|
||||||
|
|
||||||
# We hit the timer with no detections, so we reset the adapter and restart the scanner
|
# We hit the timer with no detections, so we reset the adapter and restart the scanner
|
||||||
with (
|
with (
|
||||||
patch_bluetooth_time(
|
patch_bluetooth_time(
|
||||||
start_time_monotonic
|
start_time_monotonic
|
||||||
+ SCANNER_WATCHDOG_TIMEOUT
|
+ SCANNER_WATCHDOG_TIMEOUT
|
||||||
+ SCANNER_WATCHDOG_INTERVAL.total_seconds(),
|
+ SCANNER_WATCHDOG_INTERVAL.total_seconds(),
|
||||||
),
|
),
|
||||||
patch(
|
patch(
|
||||||
"habluetooth.util.recover_adapter", return_value=True
|
"habluetooth.util.recover_adapter", return_value=True
|
||||||
) as mock_recover_adapter,
|
) as mock_recover_adapter,
|
||||||
):
|
):
|
||||||
async_fire_time_changed(hass, dt_util.utcnow() + SCANNER_WATCHDOG_INTERVAL)
|
async_fire_time_changed(hass, dt_util.utcnow() + SCANNER_WATCHDOG_INTERVAL)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(mock_recover_adapter.mock_calls) == 1
|
assert len(mock_recover_adapter.mock_calls) == 1
|
||||||
assert called_start == 3
|
assert called_start == 4
|
||||||
|
|
||||||
# We hit the timer again the previous start call failed, make sure
|
now_monotonic = time.monotonic()
|
||||||
# we try again
|
# We hit the timer again the previous start call failed, make sure
|
||||||
with (
|
# we try again
|
||||||
patch_bluetooth_time(
|
with (
|
||||||
start_time_monotonic
|
patch_bluetooth_time(
|
||||||
+ SCANNER_WATCHDOG_TIMEOUT
|
now_monotonic
|
||||||
+ SCANNER_WATCHDOG_INTERVAL.total_seconds(),
|
+ SCANNER_WATCHDOG_TIMEOUT * 2
|
||||||
),
|
+ SCANNER_WATCHDOG_INTERVAL.total_seconds(),
|
||||||
patch(
|
),
|
||||||
"habluetooth.util.recover_adapter", return_value=True
|
patch(
|
||||||
) as mock_recover_adapter,
|
"habluetooth.util.recover_adapter", return_value=True
|
||||||
):
|
) as mock_recover_adapter,
|
||||||
async_fire_time_changed(hass, dt_util.utcnow() + SCANNER_WATCHDOG_INTERVAL)
|
):
|
||||||
await hass.async_block_till_done()
|
async_fire_time_changed(hass, dt_util.utcnow() + SCANNER_WATCHDOG_INTERVAL)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(mock_recover_adapter.mock_calls) == 1
|
assert len(mock_recover_adapter.mock_calls) == 1
|
||||||
assert called_start == 4
|
assert called_start == 5
|
||||||
|
|
||||||
|
|
||||||
async def test_adapter_fails_to_start_and_takes_a_bit_to_init(
|
async def test_adapter_fails_to_start_and_takes_a_bit_to_init(
|
||||||
@ -497,9 +496,11 @@ async def test_adapter_fails_to_start_and_takes_a_bit_to_init(
|
|||||||
nonlocal called_start
|
nonlocal called_start
|
||||||
called_start += 1
|
called_start += 1
|
||||||
if called_start == 1:
|
if called_start == 1:
|
||||||
raise BleakError("org.bluez.Error.InProgress")
|
|
||||||
if called_start == 2:
|
|
||||||
raise BleakError("org.freedesktop.DBus.Error.UnknownObject")
|
raise BleakError("org.freedesktop.DBus.Error.UnknownObject")
|
||||||
|
if called_start == 2:
|
||||||
|
raise BleakError("org.bluez.Error.InProgress")
|
||||||
|
if called_start == 3:
|
||||||
|
raise BleakError("org.bluez.Error.InProgress")
|
||||||
|
|
||||||
async def stop(self, *args, **kwargs):
|
async def stop(self, *args, **kwargs):
|
||||||
"""Mock Start."""
|
"""Mock Start."""
|
||||||
@ -538,7 +539,7 @@ async def test_adapter_fails_to_start_and_takes_a_bit_to_init(
|
|||||||
):
|
):
|
||||||
await async_setup_with_one_adapter(hass)
|
await async_setup_with_one_adapter(hass)
|
||||||
|
|
||||||
assert called_start == 3
|
assert called_start == 4
|
||||||
|
|
||||||
assert len(mock_recover_adapter.mock_calls) == 1
|
assert len(mock_recover_adapter.mock_calls) == 1
|
||||||
assert "Waiting for adapter to initialize" in caplog.text
|
assert "Waiting for adapter to initialize" in caplog.text
|
||||||
|
Loading…
x
Reference in New Issue
Block a user