mirror of
https://github.com/home-assistant/core.git
synced 2025-07-12 15:57:06 +00:00
Update switchbot to use close_stale_connections_by_address (#106835)
This commit is contained in:
parent
3419b8d082
commit
26cf30fc3a
@ -98,6 +98,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
# connectable means we can make connections to the device
|
# connectable means we can make connections to the device
|
||||||
connectable = switchbot_model in CONNECTABLE_SUPPORTED_MODEL_TYPES
|
connectable = switchbot_model in CONNECTABLE_SUPPORTED_MODEL_TYPES
|
||||||
address: str = entry.data[CONF_ADDRESS]
|
address: str = entry.data[CONF_ADDRESS]
|
||||||
|
|
||||||
|
await switchbot.close_stale_connections_by_address(address)
|
||||||
|
|
||||||
ble_device = bluetooth.async_ble_device_from_address(
|
ble_device = bluetooth.async_ble_device_from_address(
|
||||||
hass, address.upper(), connectable
|
hass, address.upper(), connectable
|
||||||
)
|
)
|
||||||
@ -106,7 +109,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
f"Could not find Switchbot {sensor_type} with address {address}"
|
f"Could not find Switchbot {sensor_type} with address {address}"
|
||||||
)
|
)
|
||||||
|
|
||||||
await switchbot.close_stale_connections(ble_device)
|
|
||||||
cls = CLASS_BY_DEVICE.get(sensor_type, switchbot.SwitchbotDevice)
|
cls = CLASS_BY_DEVICE.get(sensor_type, switchbot.SwitchbotDevice)
|
||||||
if cls is switchbot.SwitchbotLock:
|
if cls is switchbot.SwitchbotLock:
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user