SwitchBotAPI Driver for SwitchBot Bot

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

Hi @_RiC,
Thanks for the clarification. Regarding the DeviceID and OpenToken in the configuration, please do not use quotes ("). For example, if you have as DeviceID "abc123", then please fill in abc123
Hope this works.
When you have it running and the on/off status does not match the status of the bot itself, update the status of the Bot device with the SwithBot app to match the status in the hub.

And I'd like to echo what @tomw mentioned about the differences in both drivers.

2 Likes

They were all in pressmode, but it was late and I think I used the wrong ID. -.- Sorry my bad.
After some testing I tested the @toffehoff's version again and got it to work.
Thank you very much :slight_smile:

1 Like

Thank you very much I have fixed the problem I used the wrong ID -.-, now both versions work.
Is it possible to get rid of this? Even if the debug logging is turned off it logs.

Hi @_RiC, Thanks for flagging the logging. These lines should only appear if you update/change the settings (like OpenToken, DeviceID or devicemode); so you won't see them regularly.

Hi, I think im reading this correctly, i want to buy the curtain bots and control them via HE, To do this ill need a switchbot hub as well and an active internet connection? or will they work without the internet connection?

Yes, you need the SwitchBot hub and an active internet connection at the time when you want to control the curtains. Right now, there isn't an official API for operation without an internet connection.

1 Like

Hi @tomw,

I'm using your curtain driver but having a bit of an issue, wondering if you could help?

The switchbot system driver has created my curtain device, and if I go into that device and use the SwitchBot app, I can see the "Current States" changing from open to closed (although they're the wrong way around for me).

However I cant control it from Hubitat, I dont see any logs generated when I click anything.

E.g. I've tried On/Off toggles, I've tried Set Level/Set Position - but none seem to actually send anything to the device.

Any ideas what I'm doing wrong?