SwitchBot gets an open API!

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 which has support for the humidity/temperature sensor, bot, curtain, and hub IR functionality.

I posted my code here: GitHub - tomwpublic/hubitat_switchbot .

I'll add it to my HPM listing once it gets a bit more testing, so consider yourselves guinea pigs.

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.

3 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

1 Like

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

Sorry, we had a family thing come up... let me get this installed now...

1 Like

Hi,

I have two SwitchBot Curtain Rod devices
I am trying to use TOMW SwitchBot Curtain Driver v 0.9.4
Everything is working but after few minutes status of
"switch" and "windowShade" changes to "unknown".
This way it is impossible to create a reliable rule.
I can introduce a Local Variable fo the reliable status
tracking but why this is happening and how to fix this?

Thank you,

  • Vitaliy

Hi,

I will be very interested in any local control solution.
Being Home Automation enthusiast for about 25 years
I have very strong opinion all Home Automation must
be LOCAL. All these CLOUDS must not be a part of
Home Automation.

Thank you,

  • Vitaliy
1 Like

Does the Switchbot curtain motor unit have to sit in plain view, or can it be mounted/connected so it's on the back-side of the curtains. Wife took a look and was not happy about the "huge white thing" (her words) on the curtain rod. :slight_smile:

Download the Hubitat app