Switchbot lock integration not working - getting Unknown error encountered message

I had my Switchbot lock showing up in HA but the state wasn’t updating and the lock/unlock didn’t work. I deleted the integration and rebooted. HA found the lock and configure gave me two options - enter my name/pw or run the find script. Neither worked. The first option gave me an Unknown error encountered message. Now I don’t even have the lock showing up since the integration configuration didn’t finish. Help please.

Did you by chance setup your account with SSO? This would cause problems with the username/password option.

“This integration doesn’t support SSO accounts (Login with Google, etc.) only username and password accounts.”

Edit: Also, how far is your SwitchBot lock from your BT dongle (or BT Proxy device)? I’ve found the range to be fairly low for reliable operation.

same for me. I had the lock registered and could access the entities through a BT proxy (esp32). then about 4 weeks ago they became unavailable, and I deleted them, hoping I could re-register them again)

When scanning for BT integration I get a prompt that no device is available. Reset the lock (take batteries out and re-calibrate).

the device is also registered through SwBot Hub mini using the switchbot cloud integration (entered API token & key as per instructions). The cloud integration in HA shows no devices available; in the switchbot app, however, the lock shows as registered with the cloud.

the lock shows up on my BT scanner app and recognizes the hub mini, too, which is the same distance from the lock as the bt proxy esp

the lock shows up with it’s MAC in the BLE proxy logs like so:

[10:56:44][VV][esp32_ble_tracker:423]: Parse Result:
[10:56:44][VV][esp32_ble_tracker:440]: Address: XX:54:XX:X4:X:EX (RANDOM)
[10:56:44][VV][esp32_ble_tracker:442]: RSSI: -76
[10:56:44][VV][esp32_ble_tracker:443]: Name: ‘’
[10:56:44][VV][esp32_ble_tracker:451]: Ad Flag: 6
[10:56:44][VV][esp32_ble_tracker:457]: Manufacturer data: XX:54:XX:X4:X:EX.38.83.00.20 (10)
[10:56:44][VV][esp32_ble_tracker:468]: Service data:
[10:56:44][VV][esp32_ble_tracker:469]: UUID: 0xFD3D
[10:56:44][VV][esp32_ble_tracker:470]: Data: 6F.80.64
[10:56:44][VV][esp32_ble_tracker:473]: Adv data: 02.01.06.0D.FF.69.09.XX:54:XX:X4:X:EX.38.83.00.20.06.16.3D.FD.6F.80.64 (24)

all versions are on the latest
Core 2023.11.3
Supervisor 2023.11.6
Operating System 11.1 (VM ware)
Frontend 20231030.2
ESPHome 2023.11.6

FYI,
I was able to restore the devices from a backup - despite the integration not being able to find the device (I had it working at some point earlier, so could get the setup from a backup).

this is the device entry in the “\homeassistant\config.storage\core.config_entries” , under
“data”: {
“entries”: [
{…},
{
“entry_id”: “078b07323f79f82ea50fc215176ab632”,
“version”: 1,
“domain”: “switchbot”,
“title”: “Lock A5FB”,
“data”: {
“key_id”: “61”,
“encryption_key”: “b6eb214822b9c24752d835a3baccabff”,
“address”: “XX:54:XX:X4:XX:EX”,
“sensor_type”: “lock”
},
“options”: {
“retry_count”: 3
},
“pref_disable_new_entities”: false,
“pref_disable_polling”: false,
“source”: “bluetooth”,
“unique_id”: “XX54XXX4XXEX”,
“disabled_by”: null
},
{…}
]

and also in the file “\homeassistant\config.storage\core.device_registry”, under
“data”: {
“devices”: [
{…},
{
“area_id”: “hallway”,
“config_entries”: [
078b07323f79f82ea50fc215176ab632
],
“configuration_url”: null,
“connections”: [
[
“mac”,
“XX:54:XX:X4:XX:EX”
],
[
“bluetooth”,
“XX:54:XX:X4:XX:EX”
]
],
“disabled_by”: null,
“entry_type”: null,
“hw_version”: null,
“id”: “51af086d6dfccf420e03770bfe555ec3”,
“identifiers”: ,
“manufacturer”: “switchbot”,
“model”: “WoLock”,
“name_by_user”: null,
“name”: “Lock A5FB”,
“serial_number”: null,
“sw_version”: null,
“via_device_id”: null
},
{…}
]

notice the corresponding ID in the two files (078b07323f79f82ea50fc215176ab632); you want to have a unique one of your own to use.

so maybe you can try editing these two files in order to add the lock to your config, then restart HA - make sure to do a full system backup before that, of course.

This worked for me and I have the lock functional and available in HA under the Switchbot BT integration again.

For what it’s worth to people who don’t want to go down the route of getting the key etc. The Switchbot Hub 2 - exposes the lock over matter which Home Assistant can see and control with no further configuration.