Open erich74 opened 1 year ago
The bottom button works as a "Switch" in Home Assistant...
Thank you very much for your answer:
Would you please mind elaborating a little bit how the button button can be used as a switch in HA? FYI I am integrating the MJWSD05MMC with OpenMQTTGateway BLE gateway based on ESP32. I am retrieving the data from MQTT to HA. Here is a typical advertisement I am receiving, how would the buttom button should be advertised?:
{"id":"A4:C1:38:DF:DE:2F","mac_type":0,"adv_type":0,"name":"BTH_DFDE2F","rssi":-46,"servicedata":"2fdedf38c1a4f4088711410c64bc05","servicedatauuid":"0x181a","brand":"Xiaomi","model":"LYWSD03MMC","model_id":"LYWSD03MMC_PVVX","type":"THB","tempc":22.92,"tempf":73.256,"hum":44.87,"batt":100,"volt":3.137}
The time of arrival of the message from the moment of pressing or releasing the button is 5 ms. Then there are 3 repeats of the transmission after 50 ms. ESP Home is a brake and is not suitable for such applications (lot of gaps when receiving BLE packets). ESP Home on ESP32 is not recommended for use.
Thanks for the detailed explanation. Please note that I am not using ESP Home but the openmqttgateway project (https://docs.openmqttgateway.com/).
Thanks for the detailed explanation. Please note that I am not using ESP Home but the openmqttgateway project (https://docs.openmqttgateway.com/).
I didn't find BLE version 5.0+ there. For ESP 32 chip - Bluetooth 4.2 max ESP32-C3 - Bluetooth 5.0 is specified, but there are no implementations.
Yes this is BLE 4.2 (I am using a regular ESP32 chip). This is not an issue for reading temp & hum as I don't need to have a high refresh rate.
For the switch this might be a different story but in any case, I changed RS Mode to "switch" but it is not advertised for what I see in my MQTT client:
{"id":"A4:C1:38:DF:DE:2F","mac_type":0,"adv_type":0,"rssi":-45,"servicedata":"2fdedf38c1a4d009b510430c648805","servicedatauuid":"0x181a","brand":"Xiaomi","model":"LYWSD03MMC","model_id":"LYWSD03MMC_PVVX","type":"THB","tempc":25.12,"tempf":77.216,"hum":42.77,"batt":100,"volt":3.139}
The "BTHome v1" protocol is used to transmit events 0x181C - 16-bit UUID Service 0x181C BTHome v1, no security 0x181E - 16-bit UUID Service 0x181E BTHome v1, security enable Opening/Closed, Opening counter
Invert RS event
- Swaps "Opening"<->"Closed"
Ok I am using your custom advertisement method and not BTHome so this should be the reason?
Other protocols/formats do not contain "events". There are events only in Mijia and BT Home. The data transmission on the receiving side uses several accepted values and is rounded over a period, and "events" are perceived and processed immediately upon receipt. "Events" have a different priority and processing principle.
If you pressed a button and, for example, the light bulb did not turn on for 200 ms, then anyone starts looking for a hammer for this button. As a result, any action that does not display execution within 200 ms is uncomfortable for a person and causes various inappropriate reactions.
ok understood, for whatever reason BTHome protocol is not working on my ESP32 with the OMG firmware (I do not get the encrypted data like temp and hum) , therefore I will stick to your advertising method and will not use Events (which is not a big deal, this was just a nice to have).
Pressing and holding two buttons for a long time (more than 20 seconds) on the MJWSD05MMC resets to the default settings.
ok good to know, thanks a lot for your great work and support!
On all thermometers with a button, you can assign different events. On LYWSD03MMC, a revision is required - the installation of a reed switch. Then it turns into a door or window sensor. As well as the counter. There is no "Connect" assignment option for MJWSD05MMC, since it was originally assigned to another button.
The "Connect" button is necessary to connect to the thermometer in the explorer. The WEB bluetooth API does not yet support scanning BT 5.0+ devices and devices with long advertising periods. (But the connection itself in Android supports with any BLE devices, including BT5.3. Problems arise due to the introduction of erroneous and malicious fixes for BLE in Linux since 2016. Since the publication of BT 5.0 with LE Long Range options and periodic BLE advertising. So that people could not use BLE for long distances and limit the operation of battery power - so that batteries were changed more often.)
First off I would really like to thank you for your work. I have flashed my MJWSD05MMC with your latest 4.3 beta fw
I have few questions though:
Thanks a lot! Eric