Update switchbot to use close_stale_connections_by_address (#106835)

This commit is contained in:
J. Nick Koston 2024-01-02 09:44:17 -10:00 committed by GitHub
parent 584b6c2862
commit 9231e00561
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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: