Just used the old battery again after depleting more, back to 219 again… not good.
Edit
Correction, that seem to happen initially when changing Battery.
Now battery back to 4% which is better. Might incline to higher value. Will see tomorrow.
17-10-2017: Battery raised to 46%
18-10-2017: Battery raised to 50%
Any luck on getting the battery to report correctly on the Aqara? I purchased 1 and used the DH suggested but the battery bounces between 0% and 2%. Not a major issue but would like to correct it if possible.
While waiting on a solution for the battery on the Aqara’s I’ve modified the DH to not show the battery. I also ordered an Original Xiaomi sensor which I do believe shows the battery correctly.
I don’t want to keep this for myself, just forgot to share, i now see.
Please remember that i am not sure this is correct, but please feel free to use it and test it with me.
Be aware that this percentage goes up and down a bit. But that seems to be the same behavior as my Aeon sensors.
resultMap = getBatteryResult(cluster.data.get(6))
def volts = rawValue / 2.55
def maxVolts = 100
if (volts > maxVolts) {
volts = maxVolts
}
result.value = volts.toInteger()
result.descriptionText = "${linkText} battery is ${result.value}%"
return result
I just replaced a sensor battery, which had 65% (test battery), with a new one. Now have to wait an hour for check-in.
Will report back.
First report:
Old battery: 65%
New Battery: 52%
As you can see this is not encouraging, but i’m quite confident the percentage will still rise a bit.
More tomorrow.
I understand the doubts but still think you have it right with the 6th integer and 2.55. It is possible that its a bad battery? Do you have another sensor to see how it reports that battery?
I did find another DH for a Xiaomi water sensor and when I just checked to see what that one had for battery reporting it has the following…
I made another change to the devicehandler. Specially for WebCore.
If you want to create a script that checks the lastcheckin as a date to see if a sensor hasn’t checked in for awhile, you need a DateTime, not a stringvalue.
You can use a stingvalue and convert this to a date in WebCore, but if you have a DateTime it is so much easier to use.
Thanks, I’m not using WebCore yet. Still dipping my toes in the water, I’ll jump in the deep end soon enough… LOL.
That other DH for the water sensor also had another interesting area about the battery. In the Tile he has it reporting a color BG as well. I modified it a slight bit but it will show a green BG down to 51% then go yellow from 26 to 50% then go Red lower than 25%
DOH! Thats on me, my mistake. I made the same change too, if you look at my picture the word battery is missing. I just copied and pasted the wrong code, i took it from my notepad and not out of the IDE. Sorry for the confusion.
It’s not the mesh. There are some network management features in the V2 hub which are not available in the V1 hub so the drop off problem is just constant for V1 with these particular devices. This would be true even if you only had one device sitting 6 feet from the hub.
The battery code looks to be slightly off. I had one aqara device bouncing between 98% and 0%; looking at the data, it looks like it’s a 16-bit value of bat voltage in mV as follows:
result = getBatteryResult((cluster.data.get(7)<<8) + cluster.data.get(6))