lywsd03mmc icon indicating copy to clipboard operation
lywsd03mmc copied to clipboard

Get the data from the BLE advertisements

Open jcea opened this issue 4 years ago • 6 comments

Please, support getting the data from the periodic (in my device every 2.5 seconds) advertisements, instead of establishing a BT connection, to keep battery usage low.

jcea avatar Feb 04 '21 17:02 jcea

I'm struggling to find any information about the broadcast data, although I can seem some sources saying that it may be encrypted (which isn't something I've had to deal with so far). Are you aware of any more information about it anywhere?

uduncanu avatar Feb 15 '21 16:02 uduncanu

View lywsd03mmc fork. With AtcMiThermometerClient you can retrieve thermometers data without connecting. Limitations : can't get firmware and hardware revisions, can't get history.

from lywsd03mmc import AtcMiThermometerClient
# AtcMiThermometerClient(scan_for=15.0, retry=3, debug=False)
client = AtcMiThermometerClient()

client.get_datas()

for thermometer in client.thermometers:
    print('----\n', thermometer) # print all data `)

Result:

Discovered device a4:c1:38:xx:xx:xx
Discovered device a4:c1:38:yy:yy:yy
Device disconnected
Proceed...
Discovered device a4:c1:38:xx:xx:xx
Discovered device a4:c1:38:yy:yy:yy
Received new data from a4:c1:38:xx:xx:xx
----
 mac:   A4:C1:38:xx:xx:xx - ATC_xxxxxx
temp:   22.8 °C
hum:    37 %
batt:   86 %
volts:  2.98 V
rssi:   -54 dB
skip:   False
----
 mac:   A4:C1:38:yy:yy:yy - ATC_yyyyyy
temp:   21.7 °C
hum:    42 %
batt:   88 %
volts:  2.996 V
rssi:   -71 dB
skip:   False

afer92 avatar Feb 20 '22 16:02 afer92

This is nice, @afer92, but it requires a modified firmware.

jcea avatar Feb 23 '22 03:02 jcea

This is nice, @afer92, but it requires a modified firmware.

Indeed. The interest of the modified firmware is to preserve the battery. The draw back is the lack of history. To choose is to renounce.

afer92 avatar Feb 23 '22 13:02 afer92

https://esphome.io/components/sensor/xiaomi_ble.html#obtaining-the-bindkey

arizzi avatar Jan 29 '23 08:01 arizzi

I will have a look, it's a good idea. I use advertissements for miflora sensors (sea device-mqtt.

afer92 avatar Feb 05 '23 20:02 afer92