I’ve just tried to get this working and get battery status showing up, but I couldn’t get it working using this method, I’m probably doing something wrong.
I have however got it working my own way as follows.
I have the Xiaomi Aqura Temp and Humidity sensor the square one.
This when added to Vera created a “parent device” a Generic I/O device and two child devices one for the Temp sensor and one for the Humidity sensor etc.
- Add a new “BatteryLevel” Variable to each of the child devices.
To do this go to the device then “Advanced” and select the “New Service” tab
Enter the following values and then press the Add button and then the Reload Engine button.
New Service: urn:micasaverde-com:serviceId:HaDevice1
New Variable: BatteryLevel
New Value: 0
Repeat this step on any other child devices, so I did this on both the Temp and Humidity sensor child devices.
- Create a Vera Scene or PLEG action or whatever to run this LUA code every day or hour or however often you want the battery information to be updated and populated on the child devices from the parent device.
local updateBatteryInfo = luup.variable_get(“urn:micasaverde-com:serviceId:ZigbeeDevice1”, “PowerSourceLevel”, 393)
luup.variable_set(“urn:micasaverde-com:serviceId:HaDevice1”, “BatteryLevel”, updateBatteryInfo,394)
luup.variable_set(“urn:micasaverde-com:serviceId:HaDevice1”, “BatteryLevel”, updateBatteryInfo,395)
return true
Line 1 gets the current battery level from the parent / master device, from the “PowerSourceLevel” variable.
Lines 2 and 3 then set that battery level value on the two child devices into the new “BatteryLevel” variable.
Here you can see on my parent device looking in the variables tab that the “PowerSourceLevel” is currently at 100 %
After running my code in the Vera settings - Apps - Develop Apps - Test Lua Code area both of the child devices changed their battery status from 0 % to 100 %
- Optional - Hide the parent / master I/O device from the Vera UI7 web GUI.
In the Startup Lua add a line like:
luup.attr_set(“invisible”,“1”,393)
Where ID 393 is your ID number of your parent device.
Note:- This new forum seems to change the quotation mark formatting of posted code. If the code doesn’t work, check the quotes are correct.
The battery status is now showing up for these two devices in the Vera Mobile app.
However I was also expecting the same in the Imperihome app but for some reason the battery status is not shown on the devices.
I can however long press on a device and select Details and the battery status is shown there OK, so not sure what’s up with that.