Hi all. On my C-8 Pro (platform 2.5.3.123), the built-in Aqara drivers never update the battery attribute. Every one of my Aqara sensors has shown 100% since I moved them from a community driver to the built-in drivers in October 2024. The last battery event on each one dates from that switch. I only noticed when a temperature sensor's battery died and it went silent while still showing 100%.
Drivers and models affected:
- Aqara Zigbee Weather Sensor,
lumi.weather: 11 devices - Aqara Zigbee Contact Sensor,
lumi.sensor_magnet.aq2: 8 devices - Aqara Vibration Sensor,
lumi.vibration.aq1: 4 devices.
The sensors do send their battery level. With debug logging on, the Weather Sensor driver logs the hourly Xiaomi heartbeat, then does nothing with it:
description: read attr - raw: 89690100005201FF42250121E50B0421A8430521C6E1062401000100006429C2076521D313662BD58A01000A2112F1, dni: 8969, endpoint: 01, cluster: 0000, size: 52, attrId: FF01, encoding: 42, command: 0A, value: 250121E50B0421A8430521C6E1...
The value is the usual Xiaomi structure: a length byte, then tag / ZCL type / little-endian value. Tag 0x01, type 0x21 (uint16) is the battery in mV. Here that's E50B = 0x0BE5 = 3045 mV. The other tags in this example are 0x64 temperature, 0x65 humidity and 0x66 pressure.
To test it, I wrote a small user driver that reads tag 0x01 from 0xFF01 (and 0xFF02 for older models). It sets battery from the voltage on a linear scale (2.5 V = 0%, 3.0 V = 100%), and it works on both the weather sensor and the contact sensor. I'd much rather stay on the built-in drivers, though.
Request: could the built-in Aqara/Xiaomi drivers (Weather, Contact, Vibration, and probably the other Xiaomi end devices) decode the battery voltage from the 0xFF01/0xFF02 heartbeat and update battery? Optionally they could also expose a batteryVoltage attribute or a configurable empty/full voltage - that's what I have done in my mini driver. CR2032 voltage stays almost flat until the cell is nearly empty, so even the raw voltage would help catch a failing battery before the device drops off.
Thanks.