mirror of
https://github.com/home-assistant/core.git
synced 2026-04-27 20:23:58 +01:00
Fix timestamps for bluetooth scanners that bundle advertisements (#94511)
#94138 added support for raw/bundled advertisements. We should use the same monotonic time for all advertisements in the bundle if not time is passed, or calculate the timestamp and pass it if its known
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
"""Tests for the Bluetooth integration API."""
|
||||
import time
|
||||
|
||||
from bleak.backends.scanner import AdvertisementData, BLEDevice
|
||||
import pytest
|
||||
|
||||
from homeassistant.components import bluetooth
|
||||
from homeassistant.components.bluetooth import (
|
||||
MONOTONIC_TIME,
|
||||
BaseHaRemoteScanner,
|
||||
BaseHaScanner,
|
||||
HaBluetoothConnector,
|
||||
@@ -31,6 +35,11 @@ async def test_scanner_by_source(hass: HomeAssistant, enable_bluetooth: None) ->
|
||||
assert async_scanner_by_source(hass, "hci2") is None
|
||||
|
||||
|
||||
async def test_monotonic_time() -> None:
|
||||
"""Test monotonic time."""
|
||||
assert MONOTONIC_TIME() == pytest.approx(time.monotonic(), abs=0.1)
|
||||
|
||||
|
||||
async def test_async_scanner_devices_by_address_connectable(
|
||||
hass: HomeAssistant, enable_bluetooth: None
|
||||
) -> None:
|
||||
@@ -51,6 +60,7 @@ async def test_async_scanner_devices_by_address_connectable(
|
||||
advertisement_data.manufacturer_data,
|
||||
advertisement_data.tx_power,
|
||||
{"scanner_specific_data": "test"},
|
||||
MONOTONIC_TIME(),
|
||||
)
|
||||
|
||||
new_info_callback = manager.scanner_adv_received
|
||||
|
||||
Reference in New Issue
Block a user