1
mirror of https://github.com/home-assistant/core synced 2024-08-28 03:36:46 +02:00

Close stale connections in yalexs_ble to ensure setup can proceed (#106842)

This commit is contained in:
J. Nick Koston 2024-01-02 06:50:10 -10:00 committed by GitHub
parent 4bfeb87377
commit 54ba00095b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,6 +10,7 @@ from yalexs_ble import (
LockState, LockState,
PushLock, PushLock,
YaleXSBLEError, YaleXSBLEError,
close_stale_connections_by_address,
local_name_is_unique, local_name_is_unique,
) )
@ -47,6 +48,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
id_ = local_name if has_unique_local_name else address id_ = local_name if has_unique_local_name else address
push_lock.set_name(f"{entry.title} ({id_})") push_lock.set_name(f"{entry.title} ({id_})")
# Ensure any lingering connections are closed since the device may not be
# advertising when its connected to another client which will prevent us
# from setting the device and setup will fail.
await close_stale_connections_by_address(address)
@callback @callback
def _async_update_ble( def _async_update_ble(
service_info: bluetooth.BluetoothServiceInfoBleak, service_info: bluetooth.BluetoothServiceInfoBleak,