LYWSD03MMC support (implemented since 0.6.0)
After a deeper study of the information available on the Internet, it seems that there is hope for the implementation of support for other sensors (as far as I understand, support for sensors with a method similar to ours is implemented in ESPHome). In addition to the already implemented work with LYWSDCGQ, I talk about:
-
~~LYWSD02~~ (rectangular body, E-Ink) - dump received, work is done, supported since v0.4.0...
-
~~HHCCJCY01~~ (MiFlora) - dump received, work is done, supported since v0.4.0...
-
~~CGG1~~ (round body, E-Ink) - dump received, work is done, supported since v0.4.0...
-
LYWSD03MMC ( square body, segment LCD) - ~~dump received, need some help, start reading from this post.~~ Collected tech.details summary. The decryption issue has been resolved, ~~only the time for implementation is needed. Testing~~ Released
ATTENTION! This topic discusses only questions regarding the operation of LYWSD03MMC sensors and methods for extracting encryption keys.
~~UPD. The dump didn’t help... Apparently, the advertisements are encrypted. But there is still hope!~~
Have you checked: https://habr.com/ru/post/452558/ (if needed google translate do good work)
I have LYWSD02 and here is what it sending:
hcidump --raw | grep -v "3F 58 70" HCI sniffer - Bluetooth packet analyzer ver 5.50 device: hci0 snap_len: 1500 filter: 0xffffffff
04 3E 2B 02 01 03 01 20 AF 16 2D C1 2E 1F 1E FF 06 00 01 09 20 02 BE C7 A9 2E B4 17 E3 07 73 B4 62 81 C9 1F 5B 17 73 F8 3A F3 03 F7 75 DF 04 3E 2B 02 01 03 01 20 AF 16 2D C1 2E 1F 1E FF 06 00 01 09 20 02 BE C7 A9 2E B4 17 E3 07 73 B4 62 81 C9 1F 5B 17 73 F8 3A F3 03 F7 75 D8 04 3E 2B 02 01 00 00 0B 32 AD 1A B1 CC 1F 02 01 1A 1B FF 75 00 42 04 01 01 6F CC B1 1A AD 32 0B CE B1 1A AD 32 0A 01 98 00 00 00 00 00 C5 04 3E 2B 02 01 03 01 20 AF 16 2D C1 2E 1F 1E FF 06 00 01 09 20 02 BE C7 A9 2E B4 17 E3 07 73 B4 62 81 C9 1F 5B 17 73 F8 3A F3 03 F7 75 DF 04 3E 2B 02 01 00 00 0B 32 AD 1A B1 CC 1F 02 01 1A 1B FF 75 00 42 04 01 01 6F CC B1 1A AD 32 0B CE B1 1A AD 32 0A 01 98 00 00 00 00 00 CD 04 3E 2B 02 01 03 01 20 AF 16 2D C1 2E 1F 1E FF 06 00 01 09 20 02 BE C7 A9 2E B4 17 E3 07 73 B4 62 81 C9 1F 5B 17 73 F8 3A F3 03 F7 75 D9 04 3E 2B 02 01 00 00 0B 32 AD 1A B1 CC 1F 02 01 1A 1B FF 75 00 42 04 01 01 6F CC B1 1A AD 32 0B CE B1 1A AD 32 0A 01 98 00 00 00 00 00 CE 04 3E 2B 02 01 03 01 20 AF 16 2D C1 2E 1F 1E FF 06 00 01 09 20 02 BE C7 A9 2E B4 17 E3 07 73 B4 62 81 C9 1F 5B 17 73 F8 3A F3 03 F7 75 CF 04 3E 28 02 01 00 00 78 B8 72 7D 5B 3F 1C 02 01 06 03 02 1A 18 14 16 95 FE 70 20 5B 04 4F 78 B8 72 7D 5B 3F 09 06 10 02 4A 01 E1 04 3E 2B 02 01 00 00 0B 32 AD 1A B1 CC 1F 02 01 1A 1B FF 75 00 42 04 01 01 6F CC B1 1A AD 32 0B CE B1 1A AD 32 0A 01 98 00 00 00 00 00 C4 04 3E 2B 02 01 03 01 20 AF 16 2D C1 2E 1F 1E FF 06 00 01 09 20 02 BE C7 A9 2E B4 17 E3 07 73 B4 62 81 C9 1F 5B 17 73 F8 3A F3 03 F7 75 CC 04 3E 2B 02 01 00 00 0B 32 AD 1A B1 CC 1F 02 01 1A 1B FF 75 00 42 04 01 01 6F CC B1 1A AD 32 0B CE B1 1A AD 32 0A 01 98 00 00 00 00 00 C4 04 3E 2B 02 01 03 01 20 AF 16 2D C1 2E 1F 1E FF 06 00 01 09 20 02 BE C7 A9 2E B4 17 E3 07 73 B4 62 81 C9 1F 5B 17 73 F8 3A F3 03 F7 75 CF 04 3E 2B 02 01 00 00 0B 32 AD 1A B1 CC 1F 02 01 1A 1B FF 75 00 42 04 01 01 6F CC B1 1A AD 32 0B CE B1 1A AD 32 0A 01 98 00 00 00 00 00 C4 04 3E 2B 02 01 03 01 20 AF 16 2D C1 2E 1F 1E FF 06 00 01 09 20 02 BE C7 A9 2E B4 17 E3 07 73 B4 62 81 C9 1F 5B 17 73 F8 3A F3 03 F7 75 C9 04 3E 2B 02 01 00 00 0B 32 AD 1A B1 CC 1F 02 01 1A 1B FF 75 00 42 04 01 01 6F CC B1 1A AD 32 0B CE B1 1A AD 32 0A 01 98 00 00 00 00 00 CE 04 3E 2B 02 01 03 01 20 AF 16 2D C1 2E 1F 1E FF 06 00 01 09 20 02 BE C7 A9 2E B4 17 E3 07 73 B4 62 81 C9 1F 5B 17 73 F8 3A F3 03 F7 75 DF 04 3E 2B 02 01 00 00 0B 32 AD 1A B1 CC 1F 02 01 1A 1B FF 75 00 42 04 01 01 6F CC B1 1A AD 32 0B CE B1 1A AD 32 0A 01 98 00 00 00 00 00 BF 04 3E 2B 02 01 00 00 0B 32 AD 1A B1 CC 1F 02 01 1A 1B FF 75 00 42 04 01 01 6F CC B1 1A AD 32 0B CE B1 1A AD 32 0A 01 98 00 00 00 00 00 C3 04 3E 2B 02 01 03 01 20 AF 16 2D C1 2E 1F 1E FF 06 00 01 09 20 02 BE C7 A9 2E B4 17 E3 07 73 B4 62 81 C9 1F 5B 17 73 F8 3A F3 03 F7 75 CF 04 3E 2B 02 01 00 00 0B 32 AD 1A B1 CC 1F 02 01 1A 1B FF 75 00 42 04 01 01 6F CC B1 1A AD 32 0B CE B1 1A AD 32 0A 01 98 00 00 00 00 00 C5 04 3E 2B 02 01 03 01 20 AF 16 2D C1 2E 1F 1E FF 06 00 01 09 20 02 BE C7 A9 2E B4 17 E3 07 73 B4 62 81 C9 1F 5B 17 73 F8 3A F3 03 F7 75 C9 04 3E 2B 02 01 00 00 0B 32 AD 1A B1 CC 1F 02 01 1A 1B FF 75 00 42 04 01 01 6F CC B1 1A AD 32 0B CE B1 1A AD 32 0A 01 98 00 00 00 00 00 D4
Sorry, this capture have this "all ready" supported (round one) sensor on the range... But you can easily filter it away...
https://www.dropbox.com/s/kbk98bzyue84fu5/dump.txt?dl=0
Values where 33% and 26,7C thru whole capture time.
Russian is my native language ) Yes, I saw this article. The fact is that its author uses a connection to the sensor. This is not our method ) We parse broadcast data, which greatly saves battery power and gives other pluses as a result from processing a continuous data stream (look at the description of the use_median option in readme.md, for example).
Yes, I know that you use a different method, but of course, received data should be at same format. So if you can "inject" those hcidump results to your code, you should see if your code works. Hopefully, my dumps help...
I just found another model that seems to be fairly new: LYWSD03MMC Some shops have it for 18$ for three of them which is pretty cheap. Sadly seem to be sold out right now. Unsure yet if it broadcasts similarly to the other devices. I plan to buy some and will let you know when I get a chance to play with them. Also trying to find the MiFlora for cheap somewhere, but no luck apart from Amazon around here.
I pushed pre-release with other sensors support. Installation in HACS is also available if you enable "Show betas" on the integration page. A MiFlora dump is still needed to implement support for other MiFlora sensor features besides temperature. Thanks @JJussi and Sergey Sazonov for LYWSD02 and CGG1 dumps!
I can only confirm that the original sensor still works fine with the new code. I new attributes (rssi and sensor type are also available). I don't have any of the other sensors, so cannot test that.
If you are finished, I can do a final review if you want. But you have to make a PR than.
There is still work to do after we have MiFlora dump - at least new classes for its sensors will be needed. While I would not like to do PR in the master. Plus there are a few more details that I would like to correct before being released to the master. After that, of course, we will do everything right.
Thank you! I can confirm that LYWSD02 works perfectly!
I just found another model that seems to be fairly new: LYWSD03MMC Some shops have it for 18$ for three of them which is pretty cheap. Sadly seem to be sold out right now. Unsure yet if it broadcasts similarly to the other devices. I plan to buy some and will let you know when I get a chance to play with them. Also trying to find the MiFlora for cheap somewhere, but no luck apart from Amazon around here.
I wonder if it's this model? If so, I have one on the way - happy to share a dump of its data once it arrives (unless someone else beats me to it).
Looks like.. As it says there:
Brand | XIAOMI Mijia Model | LYWSD03MMC
I noticed that the LYWSD02 and 03 sensors do not show the battery status on the display... And the fact is that 02 does not broadcast it. Curious, will 03 do it?
P.S. Tomorrow I expect to get a MiFlora sensor, and on the weekend I plan to finish with its full support.
I just pushed v0.4.0-beta.2 pre-release with MiFlora full support. I found that MiFlora does not broadcasts battery status (googled it - people write that it was disabled in the latest firmware versions). Another strange thing is that MiFlora repeats the measurement data several times (the packets are different, rssi is different, but the packet_id is identical) - I had to check this before processing. Other sensors have never sent me packets with the same id. As a result, it turned out that MiFlora updates the data once a minute approximately...
Can you mention in documentation (in README), how often devices are broadcasting the sensors value? Based on your investigation you probably know it. :-) It will be also great to mention, that the broadcasting interval is fixed (cannot be changed).
I am asking for this info, because my LYWSDCGQ is reporting every minute - and I am confused if it is correct default behavior, or it will drain the baterry fast.
Do you mean the interval the data is updated in Home Assistant? This is mentioned in the README and is a setting (period)
Period (positive integer)(Optional) The period in seconds during which the sensor readings are collected and transmitted to Home Assistant after averaging. Default value: 60
So, yes, 1 minute is default, but you can change it if you want.
Or do you mean the interval the actual sensor sends out it's data? I don't think you can change the interval LYWSDCGQ is actually sending data, am I right @Magalex2x14 ?
This is mentioned in the README and is a setting (period)
But as I understand, this period parameter is just filtering the incomming data to avoid too often updating (and storing) in Home-Assistant database. But this period parameter is not affecting, how often the Xiaomi device is broadcasting data via BLE. So Xiaomi device has no idea, that some period value is defined in integration script, and Xiaomi still reporting with same speed. Is it correct?
... I am asking for documentation of BLE data broadcasting intervals.
It may still be worthwhile to clarify the sensor broadcast interval and the component measurement period (period option)... For example, my three LYWSDCGQs send 20-25 unique messages at RSSI -75 ..- 70 dBm. With the option period = 60, the component accumulates 20-25 messages received per minute, and after the period expires, averages them and updates the sensor status in HA. The period does not affect the consumption of the sensor. It only affects the HA sensor update rate and the number of averaged values.
P.S. Ernst is wright, we can't change sensor broadcasting interval. P.P.S. Yes, ma-zal, correct.
I am asking for documentation of BLE data broadcasting intervals.
Why not... I'm sure of the broadcast interval LYWSDCGQ and MiFlora that I have. For the rest, statistics from users are needed (especially since the sensor attributes have the number of received packets for the measurement period - "last mean of" or "last median of").
@Magalex2x14 In the README (first section), you mentioned the following:
this custom component is parsing the Bluetooth Low Energy packets payload that is emitted each second by the sensor
Not sure if this is correct
Yes, that’s true, but not quite. In fact, it sends about every second, but not all packets contain measurements, and, as it turned out in the case of MiFlora, not all of them are unique... We need to change the wording, yes...