Fix ld2410_ble not being able to setup because it has a stale connection (#107754)
parent
79254c6867
commit
b12291633c
|
@ -2,7 +2,11 @@
|
|||
|
||||
import logging
|
||||
|
||||
from bleak_retry_connector import BleakError, close_stale_connections, get_device
|
||||
from bleak_retry_connector import (
|
||||
BleakError,
|
||||
close_stale_connections_by_address,
|
||||
get_device,
|
||||
)
|
||||
from ld2410_ble import LD2410BLE
|
||||
|
||||
from homeassistant.components import bluetooth
|
||||
|
@ -24,6 +28,9 @@ _LOGGER = logging.getLogger(__name__)
|
|||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Set up LD2410 BLE from a config entry."""
|
||||
address: str = entry.data[CONF_ADDRESS]
|
||||
|
||||
await close_stale_connections_by_address(address)
|
||||
|
||||
ble_device = bluetooth.async_ble_device_from_address(
|
||||
hass, address.upper(), True
|
||||
) or await get_device(address)
|
||||
|
@ -32,8 +39,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
f"Could not find LD2410B device with address {address}"
|
||||
)
|
||||
|
||||
await close_stale_connections(ble_device)
|
||||
|
||||
ld2410_ble = LD2410BLE(ble_device)
|
||||
|
||||
coordinator = LD2410BLECoordinator(hass, ld2410_ble)
|
||||
|
|
Loading…
Reference in New Issue