SwitchBotAPI-BLE icon indicating copy to clipboard operation
SwitchBotAPI-BLE copied to clipboard

Lock BLE API

Open AdyRock opened this issue 2 years ago • 77 comments

Current Situation

There is no BLE API documentation for the lock API except for the device id

Proposed Change

Add documentation for the Lock BLE API

Additional Context

It is desirable to integrate the lock into other home automation systems.

AdyRock avatar Jun 11 '22 12:06 AdyRock

I also think this would be a nice feature and probably shouldn't be closed as the BLE fix isn't available yet. I understand that it's not possible yet, but the issue shouldn't be closed IMO.

Jacksonbm1 avatar Jun 21 '22 13:06 Jacksonbm1

Hey team, any updates on this?

kaxio avatar Jul 12 '22 05:07 kaxio

I saw a post in a live chat with a cofounder of switchbot that said the ble lock api is coming:

Here's the op:

"Hey. It's Richard here. I am one of the cofounders of this little robot SwitchBot. I am more on sales and marketing, but i also know how to code and play around with JavaScript and Python myself. I have around 160+ connected device, 20-30 scenes/ routines/automations or whatever you call it at my place and most of them are in use, which means I kinda know what smart home is. Also I use Alexa most of the time at home and Siri when I am on my phone. Just wanna say hi and if you guys have anything you wanna tell me, just let me know. Would like to interact with you guys more from now on. In case i missed you comments, pin me again. I am also on Twitter in case you wanna talk there too. https://twitter.com/richardmou63/"

Here's the reply that says the lock api is coming:

"1. Lock API is definitely on its way. We gotta test the security level before releasing and there is no ETA yet."

Post: https://www.reddit.com/r/TrySwitchBot/comments/vzr3y6/first_post_hello_world/?utm_source=share&utm_medium=ios_app&utm_name=iossmf

Jacksonbm1 avatar Jul 18 '22 04:07 Jacksonbm1

I don't understand. Why was this issue closed even though there is still no documentation on using the switchbot lock via BLE?

brandon-dacrib avatar Aug 31 '22 19:08 brandon-dacrib

It's listed as open for me? But I believe comments may re open it. Pretty sure GitHub auto closes issues that don't get updates and go stale

Jacksonbm1 avatar Aug 31 '22 19:08 Jacksonbm1

with V1.1 of the API dropping about a week ago and bringing back the lock and unlock capability to the webAPI (which is awesome, thank you very much for that), is there any timetable in regards to this functionality being added to the bleAPI?

martindinicolino avatar Sep 25 '22 07:09 martindinicolino

Best way I can find is to message Richard Mou on twitter. He responds quickly

Jacksonbm1 avatar Sep 26 '22 19:09 Jacksonbm1

Looking forward for the BLE API support!

r-glebov avatar Oct 14 '22 08:10 r-glebov

Best way I can find is to message Richard Mou on twitter. He responds quickly

i‘m not on twitter, could somebody do that please?

martindinicolino avatar Oct 14 '22 08:10 martindinicolino

Current Situation

There is no BLE API documentation for the lock API except for the device id

Proposed Change

Add documentation for the Lock BLE API

Additional Context

It is desirable to integrate the lock into other home automation systems.

This is Davidson from the dev team. We are working on the BLE API and we will update the BLE API doc hopefully in the next month. I myself will oversee the progress and keep you posted. Thanks a lot for being patient and supportive! You guys are the best!

Minsheng avatar Nov 15 '22 13:11 Minsheng

This is Davidson from the dev team. We are working on the BLE API and we will update the BLE API doc hopefully in the next month. I myself will oversee the progress and keep you posted. Thanks a lot for being patient and supportive! You guys are the best!

This is fantastic news! Out of curiosity, what features will the api include?

  • ability to lock/unlock
  • ability to read state of lock
  • ability to read state of door
  • ability to read state of battery

Best

Jacksonbm1 avatar Nov 15 '22 15:11 Jacksonbm1

This is Davidson from the dev team. We are working on the BLE API and we will update the BLE API doc hopefully in the next month. I myself will oversee the progress and keep you posted. Thanks a lot for being patient and supportive! You guys are the best!

This is fantastic news! Out of curiosity, what features will the api include?

  • ability to lock/unlock
  • ability to read state of lock
  • ability to read state of door
  • ability to read state of battery

Best

We plan to support these triggers first,

  • ability to read state of lock
  • ability to read state of door
  • ability to read state of battery

The actions will have to come after.

Davidson

Minsheng avatar Nov 21 '22 03:11 Minsheng

awesome! @Minsheng do you have an estimated timeline for both reading and actions? Asking as our company is deciding which product to choose, so it may be worth to wait, but we need to understand how long. Thank you!

marcomow avatar Nov 21 '22 08:11 marcomow

This is fantastic news! Out of curiosity, what features will the api include?

  • ability to lock/unlock
  • ability to read state of lock
  • ability to read state of door
  • ability to read state of battery

Please also add the ability to set PIN. This will create a huge use case for vacation homes.

sonny-chen avatar Nov 22 '22 04:11 sonny-chen

awesome! @Minsheng do you have an estimated timeline for both reading and actions? Asking as our company is deciding which product to choose, so it may be worth to wait, but we need to understand how long. Thank you!

We have released the broadcast definition for Lock. The pull request is being reviewed atm. We don't have a timeline for the implementation of Lock actions yet. Please stay tuned.

Minsheng avatar Nov 25 '22 06:11 Minsheng

great job, thank you for your work! patiently waiting for the ability to lock and unlock to be added to the BLE API though 🤞

martindinicolino avatar Dec 10 '22 17:12 martindinicolino

Just goona buy in advance the lock waiting for this integration to be live asap 😃

federicotravaini avatar Dec 12 '22 22:12 federicotravaini

Happy New Year ;) Any updates?

advorsky73 avatar Jan 01 '23 22:01 advorsky73

@advorsky73 check this repo out: https://github.com/Danielhiversen/pySwitchbot

donavanbecker avatar Jan 01 '23 22:01 donavanbecker

@donavanbecker thats for cloud api, how does this help for BLE ??? 🤔

advorsky73 avatar Jan 02 '23 12:01 advorsky73

@advorsky73 pretty sure this is all BLE: https://github.com/dsypniewski/pySwitchbot/blob/ed46ac93e2c8985037e21f31e4bb7b933e17714f/switchbot/devices/lock.py

From this PR: https://github.com/Danielhiversen/pySwitchbot/pull/164

donavanbecker avatar Jan 02 '23 12:01 donavanbecker

@advorsky73 it's all BLE, not cloud. I did some investigating of messages between the lock and the app. I'll try to make a PR here once I'll finish up and organize my notes. Next release of HA should also have this integrated, it already is in the beta.

dsypniewski avatar Jan 02 '23 13:01 dsypniewski

FINALLY!! Home assistant added support for this lock via BLE! check version 2023.1 ;) Works fine and exposes several states: image

I've just bought Daniel a coffee! hehe

jpconfessor avatar Jan 05 '23 03:01 jpconfessor

@jpconfessor beautiful! thanks for letting us know 👍

are we sure locking and unlocking work over BLE though? I thought that wasn‘t yet available vie the BLE API, but i‘d love to be corrected

this is a big improvement as is, but it‘s worth even more if it‘s locally controlled

martindinicolino avatar Jan 05 '23 05:01 martindinicolino

@martindinicolino Yes, as I said before it's local. I spend about a month reverse engineering the lock communication and making the integration for Home Assistant, that's why the integration works while there aren't any action related docs released by SwitchBot yet. The only internet connection is needed during setup to retrieve the locks encryption key from SwitchBot internal API.

dsypniewski avatar Jan 05 '23 06:01 dsypniewski

@dsypniewski this is huge! thank you for your effort

i‘ll give it a try as soon as i get home

martindinicolino avatar Jan 05 '23 06:01 martindinicolino

yes! I was able to validate using my ble proxy logs (from esphome).

I’ve noticed that the very first command after a while requires a connection, and due to this it takes around 1s to lock/unlock… if you try again.. it is almost instant…. so, this very first command is still waaaay faster than api (I was using the smartthings integration.. so, even worst!)

I’ve watched the release video from HA and they’ve mentioned some improvements around this area in the new version of esphome that requires a serial update (not OTA) in order to give us full performance. I will give it a try to see if I can reduce this even more :)

setup: I am using home assistant 2023.1 with the switchbot integration via bluetooth proxies around my house (esp32 devices - m5 atom lite) - check this: https://esphome.github.io/bluetooth-proxies/

jpconfessor avatar Jan 05 '23 13:01 jpconfessor

I have also set this up in Home Assistant and can confirm it is local. You should be proud of your work here. I know I read a lot of comments about hesitation in buying this lock due to the lack of local support on Home Assistant. I would expect sales of this lock to improve greatly due to this improvement. Great job.

kklicker777 avatar Jan 05 '23 18:01 kklicker777

yes! I was able to validate using my ble proxy logs (from esphome).

I’ve noticed that the very first command after a while requires a connection, and due to this it takes around 1s to lock/unlock… if you try again.. it is almost instant…. so, this very first command is still waaaay faster than api (I was using the smartthings integration.. so, even worst!)

I’ve watched the release video from HA and they’ve mentioned some improvements around this area in the new version of esphome that requires a serial update (not OTA) in order to give us full performance. I will give it a try to see if I can reduce this even more :)

setup: I am using home assistant 2023.1 with the switchbot integration via bluetooth proxies around my house (esp32 devices - m5 atom lite) - check this: https://esphome.github.io/bluetooth-proxies/

Works great, as described! Thanks everyone for this solution! Regards

andreasbuff avatar Jan 05 '23 19:01 andreasbuff

@martindinicolino Yes, as I said before it's local. I spend about a month reverse engineering the lock communication and making the integration for Home Assistant, that's why the integration works while there aren't any action related docs released by SwitchBot yet. The only internet connection is needed during setup to retrieve the locks encryption key from SwitchBot internal API.

Excellent work. Works flawlessly, thanks you so much ! Do you have any donations link ? That's the kind of work that definitely deserve it.

Write avatar Jan 07 '23 13:01 Write