Open H159320 opened 6 days ago
SwitchBot has been having server issues, so the token issues could be due to that.
The updates are pushed via a webhook when the data changes, but I have noticed that it doesn't push every change. However, mine has been working and updates regularly.
Everything looks OK in the logs, but they are quite short. Could you set the level to Webhook and then clear the log. Wait for about 10 minutes, and then check again to see if anything has been received.
How do I do this?
Is it obligated to have a hub for this to work? Or can homey read the BLE directly?
It only works with a hub as the BLE information has not been provided and I haven't had time to try and reverse engineer it.
Use the same procedure to send the logs as before, but just change the drop list to show Webhook
Will it eventually work without a hub? :)
I just sended you the webhook log
If the BLE protocol is published or if I get time to reverse engineer the data, then I will add it, but I have no idea when that will be.
How long was the log active before you sent it?
A couple of minutes. I deleted all the logs and restarted the app. Then I opened the log again and sent it.
But I thought SwitchBot was an official partner? Can’t this be arranged in consultation with them? This should save you time and ensure that we can use the application.
Can you let it run for about 10 minutes or more and then send the logs.
I have a contact at SwitchBot, but that's only for the API. The BLE protocols are very unofficial, so I don't have support for that.
Basically, I created the app and then transferred it to a SwitchBot account when Athom wanted it to be official. However, I continue to maintain the app in my spare time, but with support from a dedicated contact higher up in the SwitchBot organisation.
Oh really. Sounds cool. Thanks for your hard work. I and, of course, the other users appreciate your work a lot. I will send the new log in 10 minutes.
Is there a chance that you will reverse engineer the BLE? This is because Switchbot is the only supplier of a good NDIR sensor at a fair price. Very interesting for hobbyists who want to improve their living environment at home.
I will probably have a crack at decoding the BLE data at some point.
So it seems no Webhook data is being received. I presume your Homey has a reliable Internet connection? It could just be that the values aren't changing, so they are not being sent.
As you can see, mine are infrequent.
You could also try running the repair option to see if that fixes the other errors as it shouldn't have those.
I have tried all of this. But do you use the hub? I notice that the CO2 meter only updates to the app when you press the button on the device for 2 seconds. Is it different for you
Yes, I use a hub. I seem to remember a setting in the SwitchBot mobile app for notification time, but as I am not at home, I can't get into the settings.
Hmm, can you please let me now if you find such a thing.
Everything is now a gain for me, because now I can’t do anything with it in terms of managing flows
Hello @AdyRock
I've parsed the data for the SwitchBot Meter Pro and SwitchBot Meter Pro (CO2) and identified the correct bytes and conversion logic that you would need to add these devices to Homey WITHOUT a hub (BLE advertisements only).
1. Temperature (Bytes 8–9) Interpretation: Byte 8: Lower 4 bits (0x0F) = Decimal part of temperature. Byte 9: Upper 7 bits (0x7F) = Whole number of temperature. Negative Flag: High bit (0x80) in Byte 9. If set, temperature is negative. FORMULA EXAMPLE: Temperature = (Byte 9 & 0x7F) + (Byte 8 & 0x0F) * 0.1 If Byte 9 & 0x80, Temperature = -Temperature
2. Humidity (Byte 10) Interpretation: Lower 7 bits (0x7F) = Humidity percentage. FORMULA EXAMPLE: Humidity = Byte 10 & 0x7F
3. Battery (Byte 2, from service_data) Interpretation: Lower 7 bits (0x7F) = Battery percentage. FORMULA EXAMPLE Battery = Byte 2 & 0x7F
4. CO2 (Bytes 13–14) Interpretation: 16-bit big-endian integer = CO2 ppm value. FORMULA EXAMPLE CO2 = (Byte 13 << 8) | Byte 14
The bytes are identical for both versions, simply the base version doesn't advertise CO2 at bytes 13-14. Please use this to add support for both devices in the Homey App.
Let me know if you need anything else.
@kiselio If you have the Meter Pro without the CO2, could you let me know what the first byte of the service data is? For the MP with CO2 it is 35 and is the intensifier for the device type, so I'm wondering if the MP without the CO2 is different?
Yes, I have both variants. The first byte of the service data for the Meter Pro without CO2 is 0x34 (decimal: 52), while for the Meter Pro with CO2, it is 0x35 (decimal: 53).
I have published a new test version that has BLE support for the Meter Pro and Meter Pro CO2.
I managed to pair the Meter Pro (CO2) with some difficulty. Pressing the button several times to force a payload to be sent resulted in the device being discovered in BLE mode by the Homey Pro after several tries. As is, it won't get discovered in the short scanning window the app gives you.
HOWEVER, I cannot pair the Meter Pro (Without CO2) no matter what I do. Change distance, swap new batteries, force a payload, set in pairing mode. Nothing works.
I confirmed the following:
Here's a screenshot of the CO2 working in BLE mode:
I don’t understand how you can take these screenshots if you can’t connect the meter?
This is the Meter Pro (CO2) which connect fine. I cannot connect the Meter Pro (WITHOUT CO2).
You misread what I wrote.
With or without the hub?
No hub, direct BLE connection
My CO2 meter still doesn't provide any data. Only when I press the physical button does the Switchbot app synchronize. Homey doesn't receive anything. Any idea what else I could do?
Install the Test version of the app, re-pair the device and it will push data without issues. Make sure you press the button on the device every 1 second or so during pairing so it gets discovered.
Where do I get the test version?
https://homey.app/en-gb/app/com.switchbot/SwitchBot/test/
Make sure you install the new Meter Pro with CO2 (BLE) device.
I have noticed these meters only broadcast BLE data when value changes. Homey, has a bug that makes it ignore any results passed back during the pairing if it takes more than 10 seconds, so that is the longest the app can scan for devices, Using my ESP32 bridge helps as it caches the last data from each device, so the reply during the pairing is immediately available.
What is the refresh rate of the CO2 meter on BLE? Mine is not refreshing. And when I try to read the status, is says: Error: No OAuth2 Client Found
Reading the status is for the cloud devices (connected to a hub), so you see that error because you haven't logged in to the cloud.
The app polls the BLE every 15 seconds on an HP2023 and 30 seconds on an HP2019. However, the Meter Pro appears only to publish data when a value changes. I'm not sure if that means Homey can miss updates as I don't know the internal workings of Homey.
My ESP32 hub constantly monitors the BLE broadcast and caches them, plus it pushes the updates to Homey via WiFi.
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.