[APP][Cloud & Pro] SwitchBot (Release 2.0.4, Test 2.0.5)

I’ve used Switchbot for about a year and no problems, but since last friday, my AC can’t change to fan mode anymore (use it to spread the air when using my fireplace). Switching between warm or cold air and changing the temperature is still working fine. Has something changed? I’d rather not re-install the switchbot because I have quite the extensive flow for my heating.

Setting it to fan in the switchbot app still works as usual.

Any suggestions would be appreciated.

Switchbot have been having some server problems, so not sure if that’s the issue.

Hello @Adrian_Rockall,

I have some questions on using the SwitchBot Curtain 3 in combination with a Homey Pro 2023. Apologies in advance, if I am asking the obvious. I am not familiar with SwitchBot devices.

As the curtain driver will most likely be out of direct reach of my Homey I am considering the hub version instead of the BLE version.

Since these curtain drivers also support matter (unclear over WiFi or Thread): do I need the SwitchBot hub in order to control the curtain drivers, or can they be paired directly to Homey via you app or as a generic Matter device?

If I have to use their hub, is my understanding correct that their hub is controlling the curtain drivers and homey is controlling the SwithBot Hub? So I would need to pair the hub to Homey in your app and/or devices obtained via the hub?

Based on the information in your first post, when using a hub setup, I need to log in to my SwitchBot account. Does this mean that Homey will be depending on a cloud connection to SwitchBot in order to control the curtain drivers? Or is there a local connection and is the log in only needed to initially fetch the devices connected to the hub?

If you use the hub, Homey will communicate via the Internet as the hubs don’t support a local connection.

Matter is supported natively by Homey, so my app is not involved. To use Matter, you will need to add the curtains to a hub, as the curtains don’t have native support, and the hub controls the curtains. I believe it uses Matter over WiFi.

Another solution, if you have the technical knowledge to programme an ESP32, is load my code into one of those. That provides local control over WiFi/BLE and is very fast.

1 Like

Meter Pro with CO2 does not work.
I am not receiving any data from the Meter Pro with CO2. I have sent you the log files. I don’t understand how this can happen. In the Switchbot app, I can see everything, but not in Homey. I get various error messages such as ‘invalid token’ or an authorization error. Is there anything that can be done about this? I bought this meter to start flows.

Take care about yourself and your wife, hope she is ok soon.

Thank you. She is out of hospital now and hopefully they have removed all the cancer, so fingers crossed she will be fully recovered soon.

5 Likes

:crossed_fingers:

Harm, I suppose that you have connected the meter to a hub. Do you have other SwitchBot stuff connected with this hub and do they work properly?

Hi @Bernd_Gaykema , I dont. Its BLE technology isn’t it? I expected this to work without a hub, like some other SwitchBot products do.

Ah, I’m not sure how you have added it to Homey if you don’t have a hub as there is no BLE drive for the CO2 meter. Currently the only option is to use it with a hub.

Just by logging in with my switchbot account after downloading the app. Then you can easely choose the CO2 device.

Hello @Adrian_Rockall,

I am trying to get your ESP32 SwitchBot-app running (as the bluetooth range between my Homey Pro 2023 and a SwitchBot Curtain 3 is not sufficient). But with no success.

I am completely new to ESP32, but am willing to learn :slight_smile: . Either I am doing something wrong or my ESP32 board somehow does not work with your app.

I initialy tried to find one of the exact two boards on your GitHub page. However, those are not available (anymore) in my local (NL) Amazon store. As such I purchased a similar one with - I believe - similar specs: an ESP32-WROOM-32E developer board from Freenove (Freenove ESP32-WROOM Board)

I tried to follow your instructions on your GitHub page:

  • First I tried Method 2 and installed SwitchBotBLEHub.ino.merged.bin via the Flash downloader on the board. Flashing succeeded. However, after restarting the board the only thing that happens is that the power LED comes on and the TX LED rappidly flashes and continues to do so. The SwitchBot_ESP32 Access Point is not available in the list of available WiFi networks on my computer. So I assume this method did not work.
  • Then I tried Method 1 via the Andoino IDE. I noted that some of the specific library versions you indicate in your instruction are not available any more or are updated. E.g. ArduinoJson version 0.1.2 is not available anymore, version 7.2.1 is installed. Same for NimBLE-Arduino version 1.2.0: version 2.0.0 is installed (though 1.2.0 is available). If I try to verify/build your app in the IDE, however it throws a compilation error: ‘class NimBLEScan’ has no member named ‘setAdvertisedDeviceCallbacks’. I then tried using v1.2.0 of the NimBLE-Arduino library. Performing the verify/build step now throws me a different error: ‘time_t’ has not been declared / ‘time_t’ does not name a type.

I am not sure how to proceed. Have you got any pointers for me on how to get your ESP32 app working?

As you can read here I already asked Adrian to make a BLE version for Homey. We will see when he has the time to make it available.

I will have a play with the code again to refresh my memory and try the latest libraries.

1 Like

Hmm, as they are in your SwitchBot account, they appear in the device list of the API. Products used to have a flag that said if they were cloud enabled and the app filtered on that, but that was removed a while back. However, looking at recent logs, I can see that devices that aren’t connected via a hub have an empty ‘hubDeviceId’, so I might be able to use that to filter usable devices. The main problem is working out which devices that applies to, as some WiFi devices (Light Bulb, Humidifier, etc) don’t require a hub and I’m not sure if I know all of the devices that it should or shouldn’t apply to.

The problem is, without a bridge there is no way to communicate with the BLE only device via the cloud, so even though you can add it, it won’t work. That means all I have written above just means that you wouldn’t be able to add them to Homey and won’t make them work.

I have published a new test version that has BLE support for the Meter Pro and Meter Pro CO2.

I have updated the repo. The app now uses the latest libraries and i have added support for the Meter Pro and Meter Pro CO2.

Hello @Adrian_Rockall,

Thank you very much for helping out and updating the source code!

EDIT - I managed to solve the issue after my post; see below. But for context/knowledge sharing I kept the prior information. I do have some remaining question, added below, after the EDIT tag.

I managed to get a little bit further, but don’t have it fully working yet. My apologies in advance for the longer post, but I wanted to provide you the necessary details for context.

I first tried Method 2 again, flashing my ESP32 board with the flash tool and your (updated) binary file. That still didn’t work. I got the same behavior as before: power led on and the TX led rapidly flashing. I also checked the output of the Serial Monitor in the Arduino IDE. Apparently my board keeps resetting itself with the following repeating output:

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
invalid header: 0x61223d65

Note that I flash the board with the following settings in the start-up screen of the flash tool:

  • ChipType: ESP32 (as a have an ESP32 board)
  • WorkMode: Develop
  • LoadMode: UART (cannot change that)

So I tried building/compiling the Sketch in the Arduino IDE (Method 1). Initially that did also not work. Though the verification resulted in no errors, after uploading to the board and rebooting the board I got the following error:

Core dump data check failed:
Calculated checksum='9f943a62'
Image checksum='ffffffff'

After that I removed all downloaded libraries and board references. And started added those back again. Now I seemed to get a step further: the board seemed to do something and tried to set up the access point:

*WM: Configuring access point...
*WM: SwitchBot_ESP32
*WM: AP IP address:
*WM: 192.168.4.1

After which it crashed with the following error

assert failed: tcp_alloc /IDF/components/lwip/lwip/src/core/tcp.c:1851 (Required to lock TCPIP core functionality!)

I found this issue description (Crash with error message: “Required to lock TCPIP core functionality” · Issue #10526 · espressif/arduino-esp32 · GitHub) and related discussion on GitHub. This affects the AsyncTCP and ESPAsyncWebServer libraries your program uses.

As per your instructions I initially installed those libraries via the GitHub links (to the repo from me-no-dev) you provided. There are however newer versions in the GitHub repo from mathieucarbou, which are also available in the Arduino IDE. I removed the older versions from the me-no-dev repo and installed the latest versions directly from the Arduino IDE Libary Manager - which are the same versions as from mathieucarbou - that included a fix for the above issue.

This helped: after rebooting the board the SwitchBot_ESP32 Access Point was available. I was able to connect to the access point and connect the board to my WiFi. The output on the serial monitor was promising:

Connected to IP address: 10.0.0.17
HTTP server started
Application started

Then the board crashed again with the following error:

assert failed: igmp_joingroup /IDF/components/lwip/lwip/src/core/ipv4/igmp.c:460 (Required to lock TCPIP core functionality!)

It looks similar as the previous error (also related to ‘locking of TCPIP core functionality’), however triggerd by a different item: igmp_joingroup. I tried to find a reference to this ‘igmp_joingroup’ item in your source code or in the libraries used, but could not find it.

I don’t know how to proceed.

Note that I using the following versions of the IDE/libraries:

  • IDE: Arduino IDE v2.3.3
  • ArduinoJson (by Benoit) v7.2.1
  • Async TCP (by Me-No-Dev) v3.2.14
  • ESP Async WebServer (by Me-No-Dev) v3.3.23
  • ESPAsyncHTTPUpdateServer (by Mohammad Mahdi Nazari…) v2.0.0
  • NimNLE-Arduino (by h2zero) v2.0.0
  • ESP Async WiFi Manager (by alanswx) version unknown/downloaded via your indicated link

What I don’t understand is that you are able to compile and use the program without any problems, while I am running into these issues.

I hope you can help me again.

*** EDIT ***

I managed to solve the issue by downgrading the ‘esp32’ boards set in Boards Manager from v3.1.0-RC3 (which was installed when I installed Arduino IDE) to the last pe-RC version: v3.07. No sure why the older version works, but the newer does not.

Controlling the SwitchBot Curtains 3 now goes much quicker now. The only think I noted is that:

  • The position information (both capabilities ‘position’ and ‘position reading’) is updated very slowly. E.g. when I close the curtains (set position to 0%) only after approx 10 sec. after the curtain is closed, the position information in Homey is updated.
  • Also Homey sometimes gives time-out errors. That used to be the cases constantly before I installed the ESP32 hub; now they occasionally pop up when controlling the curtains.

I there something I can do to resolve those issues?