SwitchBot gets an open API!

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

@dadarkgtprince did a fair amount of testing and debug with me. Thanks for that!

I updated with some improvements to the code on GitHub and bumped the version so that HPM updates will pick them up. Please let me know if anyone has additional feedback for the Curtain driver.

1 Like

Can't wait to try this out .... no shipment date yet :slightly_frowning_face:

1 Like

Does anyone know what the switchbot uses to communicate other than Bluetooth? If it uses RF at 433MHz, I wonder if you could get one of these flashed with tasmota to get local control. Not sure if these can control multiple devices though.

Hi all!

I just got this working with my curtains. Thanks for making the driver! Your readme guide was well written.

I run my curtain device in switch mode and can expose it to Google home. I then make a routine to use the voice commands "Open the curtain" and "Close the curtain" to turn on and turn off the switch respectively.

My only points of feedback for curtain use of the driver:

  1. I don't know if this is possible since making it a 'switch' makes it an easy installation, but using a "Open" and "Close" command for the device would be more intuitive than "Turn on" and "Turn off".
  2. I would suggest modelling this after a "dimmer" device instead of a switch to allow for percentage setting, so the curtain can be opened halfway. I see that there is a 'setPosition' option in the API, so perhaps that can be used?
2 Likes

I do support the WindowShade capability, which exposes open(), close(), and setPosition() commands in Hubitat. I'm not sure if these can be mapped to device types in things like Google Home and Alexa, though. They're there for use where they're relevant, though.

Dimmer is a great suggestion, and it should be trivial to add. I'll make the change and send you something in PM to try before I push it live.

1 Like

At least for Alexa, it is simple enough to create routines that use open/close as trigger words.

1 Like

Thanks for your idea and testing help @rudyscoggins.

The SwitchLevel functionality as well as a critical bugfix with setPosition from WindowShade are in version 0.9.4 on GitHub and updated in HPM.

2 Likes