Closed LacmanHUN closed 8 months ago
After digging the wide web I found this site: https://false.ekta.is/2021/06/xiaomi-miijia-lywsd03mmc-with-pure-bluetoothctl/ and based on that I figured out where the Temp/Hum/Batt values can be fetched:
[LYWSD03MMC:/service001e/char002f/desc0031]# select-attribute /org/bluez/hci0/dev_A4_C1_38_60_0B_C1/service001e/char0032/desc0034 [LYWSD03MMC:/service001e/char0032/desc0034]# read Attempting to read /org/bluez/hci0/dev_A4_C1_38_60_0B_C1/service001e/char0032/desc0034 [CHG] Attribute /org/bluez/hci0/dev_A4_C1_38_60_0B_C1/service001e/char0032/desc0034 Value: 54 65 6d 70 65 72 61 74 75 72 65 20 61 6e 64 20 Temperature and 48 75 6d 69 64 69 74 79 00 Humidity. 54 65 6d 70 65 72 61 74 75 72 65 20 61 6e 64 20 Temperature and 48 75 6d 69 64 69 74 79 00 Humidity.
And if I set notification to char0032 I get the real values:
[LYWSD03MMC:/service0050/char005b/desc005d]# select-attribute /org/bluez/hci0/dev_A4_C1_38_60_0B_C1/service001e/char0032 [LYWSD03MMC:/service001e/char0032]# notify on [CHG] Attribute /org/bluez/hci0/dev_A4_C1_38_60_0B_C1/service001e/char0032 Notifying: yes Notify started [CHG] Attribute /org/bluez/hci0/dev_A4_C1_38_60_0B_C1/service001e/char0032 Value: 88 06 40 e2 09 ..@..
06-88: 16.72 Celsius, 09-E2: 2.53 V, 40: 64% Humidity.
But still I don't know what to send (handle, value) in your code to get actually these values for processing :
p.writeCharacteristic(0x0038, b'\x01\x00', True) p.writeCharacteristic(0x0046, b'\xf4\x01\x00', True)
Thanks, LacmanHUN
Hi erdose,
Eventually this change worked for me in the long run p.writeCharacteristic(0x0035, b'\x01\x00', True) #0x0038
And the script ran perfectly.
BR, Laszlo
Hi erdose!
I let the Xiaomi app to upgrad the FW on the little lywsd03mmc gadget to 2.1.1_0159 (as you can see below), since then the script fails at the point where it tries to subscribe for notification. This was previously possible to query with the earlier fw level. Since I'm not quite familiar with the data what the script is looking for, I have no clue which handle to change the script and the subscription info.
What I see in the loginfo.log: 2024-01-28 20:30:59 INFO *** 2024-01-28 20:30:59 INFO Start script... 2024-01-28 20:30:59 INFO Input parameters: Domoticz Server IP: 127.0.0.1 Domoticz Server Port: 8080 Domoticz Server User: * Domoticz Server Password: ***** 2024-01-28 20:31:09 INFO TH_IDX:5 2024-01-28 20:31:13 ERROR Bluetooth command failed (code: 3, error: Attribute can't be written)
What the btle.py can fetch of the gadget:
python btle.py A4:C1:38:60:0B:C1
Looking for some help solving this.
Thanks in advance! LacmanHUN