SwitchBotAPI Driver for SwitchBot Bot

Hi all,
Recently SwitchBot has released their SwitchBotAPI.
I've created a small driver to control my Bot devices directly from my HE7 hub without IFTTT.

In case any of you are looking how to connect your SwitchBot bot to HE7, you can the driver here:
hubitat/Drivers/api-bot · toffehoff/hubitat (github.com)

Personally, I would have loved to be able to interact with my SB hub directly, so I would my home-setup run locally. But alas.
On a positive note, using the SwitchBotAPI (instead of IFTTT), does make the bot respond significantly faster.

10 Likes

Thanks @toffehoff for posting this driver, and welcome to the community!

2 Likes

Thanks @Sebastien.

To all: I just did a small update to the driver so the on/off command will only be sent to the SB-API when there is actually a change in the state of the switch.

Thanks for this!
I was going to look into this myself but hit the issue that the iPhone app does not give you tokens yet.

@damianm There is an instruction on how to get the token (you first need to get the app in developer mode), you can see it in the README. If that does not work, you can send an message to support of SwitchBot requesting your token.

2 Likes

They state the iPhone app does not support this yet and I tried the instructions anyway. I will contact support. Thanks.

1 Like

Thanks for this its exactly what ive been looking for.

How do i go about adding the bots to hubitat? I have the driver installed. My switchbot devices are cloud integrated and i have the token,

Many thanks

I ha e the iPhone app and was able to get a token no problem. I have added the driver in to hubitat also. I’m just wondering how to add the bots into hubitat.

Hi @PhilDeez, @jim273. To add a bot to hubitat, you need to create a new virtual switch device. Once you have created the virtual switch, change the driver to the switchbot driver and update the device. Then you will see the three parameters (OpenToken, DeviceID and Press/Switch mode).
To get the DeviceID, I've mentioned a curl command in the README you can use to get these.
Hope this helps!

5 Likes

Thankyou , Ive now managed to add a device but struggling with getting the device ID.

When i use the curl command and the cmd prompt it comes back with {message":"Unauthorised"}

Im not sure what im doing wrong but cant seem to get the device ID

Thanks

I am having the same problem

I also have a switch bot humidity sensor that was triggering a exhaust fan thru iftt. Is there anyway to bring that directly into hubitat using this driver?

It's a different driver, but I wrote support for H&T, curtain, and IR remote support (in addition to Bots). It's discussed and linked to in this thread and is also available on HPM: SwitchBot gets an open API!

Hi @jim273,
make sure you have the command in 1 line and no newlines.
And replace the with your token (so you should also replace the < > signs).

Hi @PhilDeez,
I've only implemented the bot-devices (since I only have those). If you'd like to add other type of SB devices, I'd suggest to have a look at the driver tomw built.

1 Like

Thanks this worked

Weird this one doesn't want to work, while this one works.

Hi @_RiC, thanks for your comment. You're not giving me much to work with for me to understand why it is not working for you. But, if the other driver does work for you, that is also a solution :slight_smile:

It's weird the status changes from on to off, everything works it's connected to the cloud, if I use the bot ID with "...." with quotes the debug in the log says it's wrong so everything is setup correctly. But the bots don't do anything. While the other app I posted works. But I only used the your driver app did I need something more?

The on/off state works but the push doesn't do anything if I push it.

So I needed the drivers from the tomwnpublic? Because now it works, I just tested :confused:

Mine and @toffehoff drivers are separate. You don't need both if one works.

What mode do you have for your Bot in the SwitchBot app (switch or press)? What mode did you select in @toffehoff's driver? I noticed that some commands take effect and others don't in various modes, so it is important for these to match.

If you only plan to use a Bot and if you can get @toffehoff's driver to work it is great because it's super lightweight- all is contained in one driver file that is easy to keep up to date. Mine is needed if you have multiple device types (curtain, IR, Bot, HT, etc) and is useful if you have a large system, because it helps you with some of the device ID management.

1 Like