How to observer the battery in Edge driver?

I have a zigbee device, I add it in the Edge driver:


It looks working properly:

Here I find a bug:
The battery level display is an incorrect percentage. The current power supply is 3.06V, which should show 100%, but in reality it shows 95%.
I search infos in the offical respository:

I want to refer to these schemes to observe the voltage values, but in reality, the callback registered for “PowerConfiguration. attributes. BatteryVoltage. ID” in “zigbee_handlers” has not been called at all.
What should I do next? Thanks!

1 Like

Why should it show 100%? A full battery is around 3.2 V so 95% isn’t unreasonable.

Have you read the default battery handler code in the Lua libraries? That is where a lot of the interesting stuff can be found. A few Zigbee leak sensor devices are using bespoke code for a voltage lookup table or a linear conversion, but the majority are leaving things to the default handlers.

2 Likes

Thanks! I confirmed with our electronic engineer what you said, and the full charge voltage is indeed around 3.2V!
But our PDM hope to display it in the panel program like the following table:

1724739156824

I have previously configured the table in the following file:

By printing the log in the function “device_init” , I confirm that the configuration has taken effect. But when the supply voltage is 3.08V, the display still hasn’t reached 100%.

Hi, @chenjun
Can you provide more details?

  • Share the driver logs to see how the message is coming in and what the driver converts that event to
  • Share the code you added in “configurations.lua”

@nayelyz Thanks! I add codes to “fingerprints.yml” as below:
企业微信截图_17248059068765
And I add codes to “configurations.lua” as below:

In the file “init.lua”, I add log as below:

Here is the log print:

Can you figure out what’s wrong with the Edge Driver? Thanks!

Hi,@nayelyz
I solved the problem by referencing the driver of “zigbee-presence-sensor”.
It looks like the call “battery_defaults.enable_battery_voltage_table” is not working properly.