Homey Community Forum

SwitchBot app (version 0.3.1 live, 0.3.9 test)

This app is used to control SwitchBot devices.
It supports both BLE and the hub methods for Curtains, Bots and the temperature / Humidity modules.

SwitchBot | Homey

When adding BLE devices, it is strongly recommended that you keep Homey and the device as close together as possible. If the distance is too large then Homey may cache partial data about the device that makes it unrecognisable. Once that data is cached it can be hard to remove and might require a restart of Homey to clear it.

There is one limitation for the app:

  1. The SwitchBot hub API only allows 1000 accesses per day. That means the refresh of the current state to get changes is very slow, and the more devices you have the slower the refresh. It does however control the devices well.

I have made a request to SwitchBot to provide either a local hub API and / or add support for notifications via a callback / webhook. This would be the most efficient way for them and us to keep track of the device status when operated by external events.
If you would like to see the hub interface improved then maybe you can also make a request to SwitchBot for these features. The more people that ask the more likely something will be done.

Using the Hub
To get the token required to access the SwitchBot API, go to SwitchBot phone app and select Profile –> Preferences then tap 10 times on “App Version”. A new Developer Options option will appear in the list. Tap on that and the token will be displayed.
Copy this token (it is quite long so use the Copy command on your device if you can)

Next, open the Configure App screen of the Homey SwitchBot app and paste the code in to the API TOKEN field.

Bot Switch Mode (Toggle / Press)
The latest version (0.2.4) has been updated to work with the Push Button mode of the Bot. For the BLE version, this is automatic as the required information is provided in the data packet. For the Hub version, the information is not made available via the API, so there is a setting in the Advanced Settings page to enable it.
Note: The actual setting for the device has to be set via the SwitchBot phone app as there is nothing documented in the protocols to be able to change it from the Homey app.

Alternative BLE connection
I have created an app that runs on a ESP32, Arduino compatible board. I have made the app available on Github:

The boards are pretty cheap on Amazon, but the installation is medium complexity, so may not be for everyone.

Once the board is programmed, it is plug and play with the latest version of the Homey SwitchBot app (v0.2.4). You just add BLE devices to Homey in the normal way.
There are two advantages to using the board:

  1. Very fast feed back of device state changes via a notification method. I can see the curtain position slider animate through several positions as the curtains open and close.
  2. Connects to Homey via WiFi, so can be positioned to reach SwitchBot devices that are too far from Homeys built in BLE.

There are instruction in the Github repository to assist programing the board.

Version History

0.1.1

  • Initial release

0.1.2

  • Added BLE Temperature and Humidity

0.2.0

  • Added HUB Temperature and Humidity, HUB Bot and BLE Bot

0.2.1

  • Added Invert Position and Motion Mode to advanced settings for curtains

0.2.2

  • Fixed Invert Position for HUB connected curtains

0.2.3

  • Added Air Conditioner Remote

0.2.4

  • Fixed operation of the Switch Bot to honour the single press mode when selected in the SwitchBot app. BLE can detect the mode setting but for the hub you have to adjust the Advanced setting.

0.2.5

  • Fix for the Homey BLE caching issue.
    Note, this fix is only for devices that are in the app and will not help fix the issue of detection when adding devices, if Homey has cached bad data for the new device that makes it impossible to recognise it.

0.2.6

  • Added On/Off capability to curtains so they can be fully opened/closed by tapping on the tile

0.2.7

  • Added a check for a SwitchBot device with no service data in the discovery, so the entry in the BLE cache can be cleared ready for the next discovery.

0.2.8

  • Fix Bot state check when using Homey’s BLE.
  • Adding my BLE hub no longer disables Homey’s BLE checking so both are now used.
  • Added error handler around JSON parsing to cope with bad data.

0.2.9

  • Attempt to add devices based on the localName id there is no service data.

0.2.10

  • Changed logging to multi-level to make it easier to spot general issues.
  • Cleaned up the retries loops.

0.2.11

  • Ensure log level is initialised at start up.

0.3.0

  • Optimised for Homey V6 firmware, but still compatible with V5.

0.3.1

  • Optimised for activating multiple devices simultaneously.
  • Added Position value to information.
  • Added buttons to send the logs from the configuration page.

0.3.2

  • Added Position value to hub curtian information.
  • Fixed issue during pair curtains.

0.3.3

  • Added support for Scenes.
  • Added support for the DVD and Speaker remote devices.

0.3.4

  • Added ‘Run Scene’ action flow card so scenes can be run without needing to add them as a device.

0.3.5

  • Fix remote parameters and command switched.

0.3.6

  • Fixed TV, DVD and set top box that I broke in 0.3.5 because they didn’t need reversing.

0.3.9

  • Added support for the SwitchBot Humidifier

If you have any requests or find any issues please get in touch on here.

14 Likes

I will add support for more SwitchBot devices in the future if there is a demand for it.

4 Likes

I had a reply from Switchbot:

Hello,

Integrating SwitchBot with Homey would be a good idea. And the other request you mention, I have noted them down and reported them to our developers. They will consider those seriously.

Also, we have been considering publish the local API of the SwitchBot Hub Mini, so that users can access to the Hub locally. I don’t have the ETA for that but our developers are working on it. When it is ready, we will release it to the public.

Thank you for your interest and great support.

Best,
SwitchBot Team

So fingers crossed they will do something so I can improve the app.

3 Likes

It would be great if you could add the Hub+, switches and thermometer as well. At the moment I’m still integrating the switches into Homey via Home Assistant.

2 Likes

I have submitted a new version for test, but as the app has not been published yet it means it has to go through the review again.
So the link in the first post will be unavailable until Athom have accepted it again.

When it is there, it will be version 0.2.0 and it will have support for the Bot and the Temperature / Humidity module on both BLE and via the API (hub).

The BLE and hub limitations are still there so hopefully Athom and SwitchBot will fix those at some point.

2 Likes

I look forward to it. Switchbot is a very good system and your app will make Homey even better :+1::+1::+1::+1::+1:

Hi Adrian,

Thanks for this initiative! I have a Hub mini and a bot which I have integrated in Homey via IFTTT (I know…) and webhooks. But a direct integratiin would be very much appreciated.

Good luck!

I get the error message below when I try to install it on my Homey:

Er is een onbekende fout opgetreden [incompatible_app_version]

Any idea what could cause this?

The app is written for Homey firmware v5, so if you are still on v4 then you will see that message.

1 Like

Thanks for the quick reply.

Hopefully the Homey v5 firmware release will fix the BLE issues, which will not be fixed in v4. Therefore I didn’t see much point in making it v4 compatible as it would never work properly.

The new test version is now live.

1 Like

Added the app and could add my Hub mini and bot.

Tip: to get the token go to SwitchBot app → Profile –> Preferences and tap 10 times on “App Version”. It will generate the token for you.

1 Like

Oh yes, thank you for adding that as I completely forgot to mention it.

2 Likes

I have 4 thermostats,2 bot and the hub mini and if you could create an app with our Homey,will be very appreciated😊Thanks for your work!

If you install the current test version (assuming you are Homey v5 firmware), then you can control the bots via the hub and, with that number of devices, refresh the current values from all the devices about every 30 minutes.

Thanks for your reply,haven’t see on the first post the link,i will try😁

1 Like

@Adrian_Rockall Hi,

Great app, thanks for your hard work.

1 Like

Thanks!! Works fantastic!!!

1 Like

Many many thanks. The app works very well and saves me a detour via IFTTT and Home Assistant. Great work! Are you planning to include the Hub Plus infrared devices in the app at some point?

I will add support for any device provided by the API.
I had an email this morning to say their local API is in beta and will be available via GitHub when released. So fingers crossed that is soon.

1 Like