Switchbot SmartLock PRO - Developing integration using API and MQTT

Hello all,
I’m starting a new project for the integration of the SWITCHBOT SMARTLOCK in OpenHAB.

The SWITCHBOT API are ready to use, but I prefer to integrate my SMARTLOCK device in openhab using the MQTT protocol, which I find more convenient.

So I’m trying to develop a little piece of software which acts like a proxy/bridge between switchbot api 1.1 and mqtt protocol.

I will update my github repository (domoticsduino (Domoticsduino) · GitHub) with the source code once it will be ready for testing

Version 0.1 is out :slight_smile:

I wrote a simple python service (as a docker compose container) which acts as a bridge between #switchbot api and mqtt protocol. At this time it’s valid for a smartlock and you can send the following command through mqtt

lock, unlock, devices, status

Please, feel free to download and try it:

https://github.com/domoticsduino/switchbot-api2mqtt

This is a video where I explain how it works:

Comments are welcome

Version 0.2 is out :slight_smile:

Now the bridge allows us to call any switchbot API service

Changelog

  • Generic version to invoke all switcbot API services using GET and POST method
  • MQTT payload containts all the details related to API call
  • Added MQTT_TOPIC_RESPONSE topic is used to obtain the last call response
  • Added API_BASEURL configuration property to set the API baseurl
  • Removed the SWITCHBOT_DEVICE_ID configuration property
  • No more automatic status retrieving

code on github: GitHub - domoticsduino/switchbot-api2mqtt: This Python script acts as a bridge between SwitchBot's cloud APIs (1.1 version) and the MQTT protocol. It allows you to seamlessly integrate your SwitchBot devices, such as smart locks, into your existing smart home ecosystem that supports MQTT, like OpenHAB

Hi, thank you for your work, I made a few changes to get it work with my SmartLock Ultra.

But do you know, if there is any possibility to get the information how and by who the door was unlocked? In the app protocol the information is available, so it should be somewhere in the cloud.

Hello,

Unfortunately, this information cannot be retrieved from API calls…or at least I haven’t found it :slight_smile:

In the meantime, if you’re interested, I managed to integrate my smart lock into openhab using the matter protocol, but only for the lock status… this way you can open, close, and retrieve the lock status locally, without needing to use the cloud.

Thank you, that was the first thing I did with the SmartLock :smiley:

I just tried this way for retrieving the additional information, too bad this isn’t possible.