mirror of
https://github.com/home-assistant/core.git
synced 2026-09-27 18:08:37 -04:00
Update ibeacon-ble to 1.0.1 (#80785)
This commit is contained in:
@@ -58,7 +58,21 @@ BEACON_RANDOM_ADDRESS_SERVICE_INFO = BluetoothServiceInfo(
|
||||
service_uuids=[],
|
||||
source="local",
|
||||
)
|
||||
|
||||
TESLA_TRANSIENT = BluetoothServiceInfo(
|
||||
address="CC:CC:CC:CC:CC:CC",
|
||||
rssi=-60,
|
||||
name="S6da7c9389bd5452cC",
|
||||
manufacturer_data={
|
||||
76: b"\x02\x15t'\x8b\xda\xb6DE \x8f\x0cr\x0e\xaf\x05\x995\x00\x00[$\xc5"
|
||||
},
|
||||
service_data={},
|
||||
service_uuids=[],
|
||||
source="hci0",
|
||||
)
|
||||
TESLA_TRANSIENT_BLE_DEVICE = BLEDevice(
|
||||
address="CC:CC:CC:CC:CC:CC",
|
||||
name="S6da7c9389bd5452cC",
|
||||
)
|
||||
|
||||
FEASY_BEACON_BLE_DEVICE = BLEDevice(
|
||||
address="AA:BB:CC:DD:EE:FF",
|
||||
|
||||
@@ -2,16 +2,27 @@
|
||||
|
||||
|
||||
from dataclasses import replace
|
||||
from datetime import timedelta
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.ibeacon.const import DOMAIN
|
||||
from homeassistant.components.ibeacon.const import DOMAIN, UPDATE_INTERVAL
|
||||
from homeassistant.const import STATE_HOME
|
||||
from homeassistant.helpers.service_info.bluetooth import BluetoothServiceInfo
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from . import BLUECHARM_BEACON_SERVICE_INFO, BLUECHARM_BEACON_SERVICE_INFO_DBUS
|
||||
from . import (
|
||||
BLUECHARM_BEACON_SERVICE_INFO,
|
||||
BLUECHARM_BEACON_SERVICE_INFO_DBUS,
|
||||
TESLA_TRANSIENT,
|
||||
TESLA_TRANSIENT_BLE_DEVICE,
|
||||
)
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.components.bluetooth import inject_bluetooth_service_info
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
from tests.components.bluetooth import (
|
||||
inject_bluetooth_service_info,
|
||||
patch_all_discovered_devices,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
@@ -195,3 +206,49 @@ async def test_rotating_major_minor_and_mac_no_name(hass):
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(hass.states.async_entity_ids("device_tracker")) == before_entity_count
|
||||
|
||||
|
||||
async def test_ignore_transient_devices_unless_we_see_them_a_few_times(hass):
|
||||
"""Test we ignore transient devices unless we see them a few times."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
assert await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
before_entity_count = len(hass.states.async_entity_ids())
|
||||
inject_bluetooth_service_info(
|
||||
hass,
|
||||
TESLA_TRANSIENT,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_entity_ids()) == before_entity_count
|
||||
|
||||
with patch_all_discovered_devices([TESLA_TRANSIENT_BLE_DEVICE]):
|
||||
async_fire_time_changed(
|
||||
hass,
|
||||
dt_util.utcnow() + timedelta(seconds=UPDATE_INTERVAL.total_seconds() * 2),
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(hass.states.async_entity_ids()) == before_entity_count
|
||||
|
||||
for i in range(3, 17):
|
||||
with patch_all_discovered_devices([TESLA_TRANSIENT_BLE_DEVICE]):
|
||||
async_fire_time_changed(
|
||||
hass,
|
||||
dt_util.utcnow()
|
||||
+ timedelta(seconds=UPDATE_INTERVAL.total_seconds() * 2 * i),
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(hass.states.async_entity_ids()) > before_entity_count
|
||||
|
||||
assert hass.states.get("device_tracker.s6da7c9389bd5452cc_cccc").state == STATE_HOME
|
||||
|
||||
await hass.config_entries.async_reload(entry.entry_id)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get("device_tracker.s6da7c9389bd5452cc_cccc").state == STATE_HOME
|
||||
|
||||
Reference in New Issue
Block a user