[APP][Cloud & Pro] SwitchBot (Release 1.1.43, Test 1.1.48)

The log all looks OK. I can see the app is polling and getting the correct responses for your two curtain bots.
Is it controlling the curtains that you are still having difficulty with?
If so could you operate the curtains via the Homey app and then send the log to me again as quickly as possible after operating them. If there are problems sending commands than I will see the errors that are reported.

I have no problem operation the curtains. but again, after a while my homey crashes and then I have reboot it to get it to work again.

Ah, Iā€™m sorry, I have just remembered the problem you were having. Because you posted just after the information about the server outage I thought that had given you problems. I need to get more sleep :slight_smile:

could you try the test version to see if that improves things: SwitchBot | Homey

Done, It now says 0.4.3 experimental.
Should now wait and see if it crashes again?

1 Like

Seems to be stable now, I have not had any crash since Monday! so that`s a great improvement.

Thx for the help!

2 Likes

Could you please consider adding projector ir remote support? Shouldnā€™t be much different from TV. Always grateful for your work.

I have released a new version (1.0.0) that uses your SwitchBot credentials to connect HUB devices instead of obtaining an API. This is first big improvement from the new collaboration with SwitchBot as the login method is dedicated to the Homey app.

The app ā€˜shouldā€™ continue to work with your current devices that are connected via the API key, but, it is recommended that you perform a one-time repair on each device to update the authentication method.
Adding new devices will use the new method regardless of how you added previous devices so you will need to provide your credentials at least once.

New features in the future may depend on the new authentication method so I strongly recommend that you do the repair. All your flows, etc should continue to work as before.

Please let me know if you find any issues with the update.

1 Like

To be clear, this is not for BLE devices, or for them too?

Correct, the new authentication method only applies to the HUB connection.
I have updated the previous post to make that clear. Thanks for pointing out the possible confusion.

1 Like

I just switched. Works great.

1 Like

Hello,

Trying to get the arduino bridge thingy to work, but struggling a lotā€¦
First off the docs specify some version which are not available (arduino json) then there is also a bunch of missing libraries (seems you switched to some OTA and wifi manager recently).
And the secrets.h file is no longer usedā€¦
I managed to get around this and compile the app with seems to work.
Then as secrets.h is not used I instead connect to the WIFI network and configure my ssid and password on the webpage.
So far so goodā€¦

Seems it connects and finds my curtains as I can see the following in the arduino log:

***Broadcasting my details: 04:66:fe:7e:b9:94***
Curtain: position = 0, battery = 84
Received request to write device e2:e3:6e:bf:b8:68 with [87,15,69,1,5,255,100] (22)
Converting string [87,15,69,1,5,255,100] to buffer: 87, 15, 69, 1, 5, 255, 100, 0, bytes = 8
Looking for BLE device: e2:e3:6e:bf:b8:68

***Broadcasting my details: 04:66:fe:7e:b9:94***
Curtain: position = 0, battery = 84

***Broadcasting my details: 04:66:fe:7e:b9:94***
Curtain: position = 0, battery = 84

Next up I click open/close in homey and this is where nothing happens i.e. the curtains dont move an inceā€¦
In the arduino log I get this:

Received request to write device e2:e3:6e:bf:b8:68 with [87,15,69,1,5,255,100] (22)
Converting string [87,15,69,1,5,255,100] to buffer: 87, 15, 69, 1, 5, 255, 100, 0, bytes = 8
Looking for BLE device: e2:e3:6e:bf:b8:68
lld_pdu_get_tx_flush_nb HCI packet count mismatch (1, 2)
Failed to connected to device
lld_pdu_get_tx_flush_nb HCI packet count mismatch (1, 2)
Failed to connected to device
lld_pdu_get_tx_flush_nb HCI packet count mismatch (1, 2)
Failed to connected to device
Received request to write device d5:61:e7:b6:4c:a1 with [87,15,69,1,5,255,0] (20)
Converting string [87,15,69,1,5,255,0] to buffer: 87, 15, 69, 1, 5, 255, 0, 0, bytes = 8
Looking for BLE device: d5:61:e7:b6:4c:a1
lld_pdu_get_tx_flush_nb HCI packet count mismatch (1, 2)
Failed to connected to device
lld_pdu_get_tx_flush_nb HCI packet count mismatch (1, 2)
Failed to connected to device
lld_pdu_get_tx_flush_nb HCI packet count mismatch (1, 2)
Failed to connected to device
lld_pdu_get_tx_flush_nb HCI packet count mismatch (1, 2)
Failed to connected to device
lld_pdu_get_tx_flush_nb HCI packet count mismatch (1, 2)
Failed to connected to device

***Broadcasting my details: 04:66:fe:7e:b9:94***
Curtain: position = 0, battery = 84

I can browse to the device (via wifi) and the API seems to work, and it seems homey and the device has connections (at least I can see arduino logs whenever I click in home)ā€¦
Also seems the battery (84%) is the one shown in homeyā€¦ but seems the device cant talk to my switchbot curtains properly?

If I thug either curtain I can see live updates in Homey of the device position as well as in arduino logs:

Curtain: position = 7, battery = 84
Curtain: position = 12, battery = 84
Curtain: position = 18, battery = 84
Curtain: position = 25, battery = 84
Curtain: position = 32, battery = 84
Curtain: position = 40, battery = 84
Curtain: position = 56, battery = 84
Curtain: position = 64, battery = 84
Curtain: position = 80, battery = 84
Curtain: position = 88, battery = 84
Curtain: position = 96, battery = 84
Curtain: position = 87, battery = 77
Curtain: position = 100, battery = 84
Curtain: position = 49, battery = 77
Curtain: position = 36, battery = 77
Curtain: position = 23, battery = 77
Curtain: position = 11, battery = 77
Curtain: position = 0, battery = 77
Curtain: position = 0, battery = 77

So this is where I am stuck nowā€¦
No idea what to do or what could be amiss, maybe I have the wrong version somewhere (as some dependencies were missing I had to guess some versions), and also all versions I download from git will be ā€œa versionā€ not strictly the one you haveā€¦

But everything except sending commands from homey seems to work fineā€¦
Unfortunately this is kind of an important feature :slight_smile:

// Michael

You are correct that I recently updated the code to use a WiFi connection feature plus the ability to update the code OTA.
As a lot of users arenā€™t able to get as far as you I am heading towards being able to supply programmed units.

I will update the instructions as soon as I can with details of the libraries I have used.

I havenā€™t seen the errors that you are getting so it could be a library version issue.

At the moment I am in the process of adding support for the Bulb but as soon as I have got that working I will make the binary available for OTA update.

Rightā€¦

I noticed the Switchbot API on github has updated the ratelimiting to 10K requests per day: OpenWonderLabs/SwitchBotAPI: SwitchBot API Documents (github.com).
Will there still be performance issues with the hub then or would that be a viable option?

My main issue with using direct BLE connection from homey is that there is a delay between initiating the command (pressing a button) and when the command is execute (often in the range of 30 seconds).
Also the position is ā€œnever updatedā€ so I cant do toggling reliably (i.e if position < 0.1 ā€¦).
I dont really need ā€œreal-time animationsā€ā€¦ but eventually reliable positions and ā€œa few secondsā€ response time on my buttons would be niceā€¦

// Michael

The app has been updated to the faster rate so it is more responsive. It basically means the data refreshes approximately every 8 seconds per device. So the rate is every 8 seconds if you have one device, 16 seconds if you have two, 24 seconds if you have three, etc.
I did a test with the new login method and I could poll all devices every 5 seconds without getting the normal error when it reached 10000 accesses. At one point I reached 89000 accesses in one day.
However, I wonā€™t make that live unless Switchbot says it is OK.

I am also working with Switchbot to use a Webhook so updates will be pushed when they happen. Iā€™m not sure when or even if that will actually happen but fingers crossed.

2 Likes

I assume this means a button click will be delayed by 16 seconds as I have 2 devices (and if switching both it would be delayed by 24 seconds)ā€¦

Would it be possible to reduce the poll interval and allow fire a call ā€œinstantlyā€ when a button is pressed?

Getting updates when someone thugs the curtain seems like something I could wait a few minutes onā€¦
But pressing ā€œcurtain closeā€ and seeing nothing for 20 seconds is kind of annoying :slight_smile:

Anyways, will get my self a hub then and see if that works betterā€¦

Thanksā€¦

Button presses, etc, are already sent immediately. I have calculated the update interval to allow for spare accesses to send commands straight away, so the polling is only for reading status updates.
If I operate my curtains via the Switchbot hub / cloud it takes around 3 seconds to actually start moving, the same as it does through my ESP32 BLE hub. It seems the delay is with connecting via BLE to send the command. For optimum speed the connection would need to be maintained but that would block any other connections so the Switchbot devices automatically disconnect after a few seconds of no activity.

1 Like

I guess the signal is weak so the app has to retry the command several times. It will attempt to send the command 5 times if it doesnā€™t get a valid response. If the device doesnā€™t receive the command then it has to timeout, which I think is around 5 to 10 seconds depending on which stage fails.

I have updated my ESP32 app on GitHub.
The new version exposes an Access Point to configure the WiFi instead of using a secrets file.
It also supports OTA updates and I am including the latest binary file in GitHub.
Also, it now supports the Bulb via BLE.

If anyone is interested in using the ESP module but not confident in programming one then I am considering supply these at cost of hardware + a small fee + P & P.
The boards I have used are on Amazon https://www.amazon.co.uk/dp/B08DR5T897/ref=cm_sw_em_r_mt_dp_48ZXX067HET452GZC218?_encoding=UTF8&psc=1
And I put them inside these boxes https://www.amazon.co.uk/dp/B07FKKCTQL/ref=cm_sw_em_r_mt_dp_9RMK855M4K3HTEP41TXW?_encoding=UTF8&psc=1

So for just the programmed board it would cost about 10 GBP + P & P.
For the programmed board in a case it would be 17 GBP + P & P.
Payment would be via PayPal.

PM me if you are interested along with your address and I will work out P & P and give you a quote.

I am a little bit confused now. Sometimes it say there is no hub needed, sometimes its needed. Can someone answer this please :slight_smile: ?

My situation:
Iā€™ve bought one curtain bot and wanted to add into Homey directly.

What I tried:

  • add directly with ā€œCurtains (BLE)ā€ ā†’ not found
  • add with "Curtains (HUB) (added API before) ā†’ device found and added. But if I try to open/close, a message "Deviceā€™s cloud service not enabled. Enabling is not possible without a hubā€¦

The swtichbot app inside homey has some logs, I see statuscode 100 and success in normal requests.
By a command ā€œsetPositonā€, the feedback is statusCode 174 - Device cloud service not enabled"

Am I doing something wrong? Please help. Thanks!
Philip

PS: Ive only tried the official version, not the test versionā€¦

You will have to enable the cloud option for each device in the SwitchBot phone app.

When itā€™s enabled you will see a small cloud icon on the device tile.

Also, I guess itā€™s possible the API knows about devices that are added to your account, but without a hub it has no way to control them.

So, without a SwitchBot hub, you can probably see the devices via the API but not control them. I hadnā€™t realised that myself until you mentioned it though.

The reason the BLE doesnā€™t find it is probably because Homey is too far away from the curtain bot.