mirror of
https://github.com/home-assistant/core
synced 2024-10-04 21:22:45 +00:00
Update switchbot to use close_stale_connections_by_address (#106835)
This commit is contained in:
parent
584b6c2862
commit
9231e00561
|
@ -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…
Reference in a new issue