Switchbot Lock

@dsypniewski @smartmatic Unfortunately no I’m still not able to add the lock. Server is definitely within BLE range of the lock (mobile app communicates just fine, and I can sniff traffic from the lock on the server with RSSI of -73).

Makes sense it is likely a neighbors plug.

Any troubleshooting steps I should try? Happy to send HA logs, Bluetooth integration diagnostics, etc.

Happy New Year peeps!

Could you run this script on the server and see if it detect’s your lock?
The version of PySwitchbot library has to be at 0.31.0 or above.

import asyncio
from switchbot.discovery import GetSwitchbotDevices

print(asyncio.run(GetSwitchbotDevices().get_locks()))

@dsypniewski Yup! Detects no problem:

{'2A18BC0E-1ED8-3FB0-8EB3-46CF6ACCA938': SwitchBotAdvertisement(address='2A18BC0E-1ED8-3FB0-8EB3-46CF6ACCA938', data={'rawAdvData': b'o\x80=', 'data': {'battery': 61, 'calibration': True, 'status': <LockStatus.LOCKED: 0>, 'update_from_secondary_lock': False, 'door_open': False, 'double_lock_mode': False, 'unclosed_alarm': False, 'unlocked_alarm': False, 'auto_lock_paused': False}, 'model': 'o', 'isEncrypted': False, 'modelFriendlyName': 'Lock', 'modelName': <SwitchbotModel.LOCK: 'WoLock'>}, device=BLEDevice(2A18BC0E-1ED8-3FB0-8EB3-46CF6ACCA938, None), rssi=-73, active=True)}

So I guess the problem has to be on HA side, and you don’t see any errors or warnings in the logs regarding this integration, right? Could you post advertising data preferably in structure bleak.backends.scanner.AdvertisementData?

Correct, no errors in the logs for Switchbot integration. Here’s the advertising data for the lock:

            {
              "name": "E3-24-EA-ED-F1-6F",
              "address": "E3:24:EA:ED:F1:6F",
              "rssi": -75,
              "advertisement_data": [
                null,
                {
                  "2409": {
                    "__type": "<class 'bytes'>",
                    "repr": "b'\\xe3$\\xea\\xed\\xf1o\\x18\\x83\\x00 '"
                  }
                },
                {},
                [],
                null,
                -74,
                [
                  "/org/bluez/hci1/dev_E3_24_EA_ED_F1_6F",
                  {
                    "Address": "E3:24:EA:ED:F1:6F",
                    "AddressType": "random",
                    "Alias": "E3-24-EA-ED-F1-6F",
                    "Paired": false,
                    "Trusted": false,
                    "Blocked": false,
                    "LegacyPairing": false,
                    "RSSI": -74,
                    "Connected": false,
                    "UUIDs": [],
                    "Adapter": "/org/bluez/hci1",
                    "ManufacturerData": {
                      "2409": {
                        "__type": "<class 'bytearray'>",
                        "repr": "bytearray(b'\\xe3$\\xea\\xed\\xf1o\\x18\\x83\\x00 ')"
                      }
                    },
                    "ServicesResolved": false,
                    "AdvertisingFlags": {
                      "__type": "<class 'bytearray'>",
                      "repr": "bytearray(b'\\x06')"
                    }
                  }
                ]
              ],
              "details": {
                "path": "/org/bluez/hci1/dev_E3_24_EA_ED_F1_6F",
                "props": {
                  "Address": "E3:24:EA:ED:F1:6F",
                  "AddressType": "random",
                  "Alias": "E3-24-EA-ED-F1-6F",
                  "Paired": false,
                  "Trusted": false,
                  "Blocked": false,
                  "LegacyPairing": false,
                  "RSSI": -75,
                  "Connected": false,
                  "UUIDs": [],
                  "Adapter": "/org/bluez/hci1",
                  "ManufacturerData": {
                    "2409": {
                      "__type": "<class 'bytearray'>",
                      "repr": "bytearray(b'\\xe3$\\xea\\xed\\xf1o\\x18\\x83\\x00 ')"
                    }
                  },
                  "ServicesResolved": false,
                  "AdvertisingFlags": {
                    "__type": "<class 'bytearray'>",
                    "repr": "bytearray(b'\\x06')"
                  }
                }
              }
            }

Everything seems to be like it should be - apart from the mac address it looks pretty much the same as my lock. Hmm, for now I think I’m out of ideas as to what could be causing this.

Ha, I was afraid you would say that! Just for my own sanity I moved the physical server right next to the lock, and still nada. I might try spinning up another HA instance on a different computer and see if that one can see it for some reason.

Otherwise I suppose I’ll wait for the official 2023.1 release, and see if things decide to work. :slight_smile:

Thanks for the help!

@dsypniewski Unfortunately I’m still having no luck— I’m on 2023.1.1, have enabled debug logging, and have set up an entirely new HA instance on another PC. None will see the lock, and nothing shows up in the logs.

The SwitchBot app is reporting a low battery on the lock (waiting on new batteries to arrive tomorrow), any chance that is messing with the auto discovery or advertisement?

Thanks so much for all your work on this!

I don’t think it should matter especially if the library itself can detect it just fine. Could you show the pop-up that comes up when you choose the option to add switch bot integration?

You got it! Attached.

Wait! Something showed up in the log, and it matches the address of my lock:

2023-01-06 08:49:30.499 DEBUG (MainThread) [homeassistant.components.switchbot.config_flow] Discovered bluetooth device: {'name': 'E3-24-EA-ED-F1-6F', 'address': 'E3:24:EA:ED:F1:6F', 'rssi': -76, 'manufacturer_data': {2409: b'\xe3$\xea\xed\xf1o\xba\x94\x08 '}, 'service_data': {}, 'service_uuids': [], 'source': 'C8:E0:EB:40:C1:6C', 'advertisement': AdvertisementData(manufacturer_data={2409: b'\xe3$\xea\xed\xf1o\xba\x94\x08 '}, rssi=-76), 'device': BLEDevice(E3:24:EA:ED:F1:6F, E3-24-EA-ED-F1-6F), 'connectable': True, 'time': 338480.251754268}

Still doesn’t show up in the add integration flow though sadly

RESOLVED! My bluetooth scanner was in passive mode. Reverting to active fixed it immediately, and the lock was automatically discovered.

How did you change it

Solved since the release 2023.1.0. Thanks!

Thanks! This works great for me. I managed to get my lock set up in Home Assistant, but I’m wondering if there’s some way to also pair the keypad, so I can see its remaining battery life.

Do you know where I can find the encryption key? Is it physically printed on the lock somewhere?

You need to get it via this project:

install the latest version of Python3 and run from a command line

1 Like

I’m a newbie re haos. I assume I have to import the Python3 library into haos before I can run any of the code above. Please tell me how to do this.

My switchbot lock is a tri-state:

  1. Latch bolt, deadbolt and 3 point system locked.

  2. Deadbolt and 3 point unlocked but latch bolt stil locked.

  3. Deadbolt and 3 point unlocked. Latch bolt unlocked for 3 seconds and beep

Homeassistand only does the first 2 states.

My door does not have a lever trim on the outside. I turn de key to open the latch bolt.

I just solved this issue
Delete an re-add the lock device solves this issue.