SwitchBot gets an open API!

Finally - what some of us (at least me) have been waiting for. A open API for SwitchBot. The article also gives Node-RED examples. Looks like it will not be too difficult to create a Hubitat integration.

I'm particularly interested in trying out the Switchbot Curtain.

15 Likes

I haven't seen Switchbot before, but it looks cool. Thanks for sharing.

The REST API doesn't look too bad. It does have a cloud interaction but otherwise looks pretty lightweight.

I am intrigued by the direct bluetooth control, though. Apparently there's no hub required to use the BT interface, and it could potentially provide a local-only solution if something like @iharyadi's bluetooth-to-Zigbee device could handle the communication.

2 Likes

Nice, maybe this will finally become useful for Hubitat and other hub users now there is an API.

Too bad they couldn't have just made a Zigbee version in the first place. I am not thrilled with the idea having to create and maintain yet another (Bluetooth in this case) network.

Nice... was kinda of looking at this for my curtains. But now can look a little more seriously.

I haven't dug deep into the api but doesn't look like they have a callback option. Would like the device to report back to hubitat its state when changed instead of having to always poll for it. Hopefully they'll add something like that in the future.

2 Likes

I watched one of the review videos from the guy with the switchbot kettle demo. It turns out there is an IR blaster in the hub, which is kind of cool. And they expose it from the API. So, cloud interaction is still unfortunate if you have an unreliable or laggy internet connection, but it might be a cool thing to try out as an alternative to Harmony or Broadlink or whatever.

2 Likes

I bought the hub for about 20 quid last year, under smartthings. Expected great things due to to learning IR blaster.

Was disappointed because there was no way of say, setting a 'volume up' button to be a press and hold. Which meant that on my TV, to flick volume between say, 50 and 10 I need to hit the button 40 times. Way too slow, especially with cloud.

Shame.

Would be great if the api manages to get a decent hubitat integration as the UI sucks. It's just sat in a drawer. I will add that the 'support' was absolutely useless. Wasn't worth sending it back for the sake of 20 quid.

1 Like

I just got 2 curtain bots, they aren’t perfect but “good enough” I’d give it a 3/5 right now and my complaints were the calibration process kept getting confused and jumping to the other one mid calibration. Once I got over that hump they been fine for a month now.

1 Like

I just ordered a hub and temp/humidity sensor- totally fell for the 10% coupon on Amazon. I'll take a stab at a driver for those and probably for the IR functionality.

2 Likes

Is there anybody who has a hub and Bot (the switch/button version) and would be willing to test out the driver I am writing? I have Meter (HT sensor) and Curtain testing covered.

1 Like

Just the hub here.

nice! can't wait to see what comes of this. @tomw i have a hub, switchbot, and curtains. i can test for you if needed

2 Likes

What do you use it for? IR, or something else? Just trying to make sure I understand the most critical features to support.

It was for the learning IR functions. Just wanted to be able to link everything together and seemed a cheap alternative to a harmony etc.

If it's possible to

  1. Use the main software to create and store custom remotes (which it is), then
  2. Use hubitat locally to make use of the defined remotes/custom buttons without cloud delays, and
  3. Can send repeat button presses or better, have "push and hold for x seconds" (to simulate holding the vol up/down

Then it would be ace. Lack of push and hold really was the nail in the coffin for me. I think this may be a limitation of the software still.

2 Likes

Unfortunately their exposed HTTP API only has a cloud-based option. Let's see how the performance is when running directly from Hubitat.

I'm also looking at their bluetooth library as an alternate option for local operation, but it only works for bots, meters, and curtains.

2 Likes

Yeah, I was probably ecpecting too much from a cheap bit of kit. The software is awful. Annoyingly it's (probably) easy enough to improve, but the company sounds like it's spread pretty thin. I initially contacted them over something minor and it escalalated into an absolute waste of time.

I got the hub plus and the bot today. I’d be happy to help test.

2 Likes

I finished up my driver and posted my code here: GitHub - tomwpublic/hubitat_switchbot . Check out the readme on GitHub for the list of currently supported devices.

You can also find it in HPM by searching for "hubitat_switchbot".

I have tested with the HT meter and the hub IR functionality and all seems to work. Please let me know if you see any issues with any of the devices.

6 Likes

Hey all, I've played around a bit with the API and I've created a little driver to control a Bot device. Since I have only a Bot device (and no curtain or plug or ...), hence you won't find support for any other SwitchBot devices ...
Anyways, it does work significantly faster than using IFTTT (which I did before)
hubitat/Drivers/api-bot at toffehoff/hubitat (github.com)

1 Like

I tested with a Bot today with my driver. It works but requires some special handling:

  • The Cloud Service for the Bot has to be enabled in the SwitchBot app on mobile before the cloud API can access it. I didn't have to do this with the HT meter, but this may be required for both Bot and Curtain.
  • The cloud API unfortunately does not allow adjusting mode between switch and press. It can only be set in the mobile app. My driver supports on(), off(), and push(). When the Bot is in press mode, on() and push() both do the press action. When it is in switch mode, on() and off() behave as expected and push() does nothing.

EDIT: updated description of switch vs. press modes based on additional testing.

FYI: @dadarkgtprince and @charlesrblack

2 Likes

Got it up and able to control my devices easily (haven't tested the hub IR yet, but switchbot and curtains rock)

When testing the curtains, I did come across a few bumps in the road. I have my curtains grouped to open from the middle. When I would open/close, it would only work from the main curtain, and not the secondary one (in the app you would create a primary and a secondary). That's fine, I can just use the main one to control them, but both of them wouldn't always go when I did it. Sometimes the main one would go alone, sometimes the secondary one would go alone, but most of the time both went together. I'm not sure if this may be a disconnect between the curtain and my hub that caused this as i do have my curtains a distance away from my hub, but it did happen a couple times.

2 Likes