Charting WMI battery value as replacement for old 'BATTERY' option
This topic contains 4 replies, has 2 voices, and was last updated by Ian 2 weeks, 4 days ago.
2 September, 2019 at 12:31 am #2120
Hi, I used to use the ‘BATTERY’ option with a chart to visually show the charge percentage of the laptop battery:
BATTERY=active:1,interval:30,set:battery,display:%3: %1%,chart:bar linear 100 1 -10
Since the battery option in the latest version is deprecated, I’ve gone with the example listed in ‘useful WMI Queries’:
This works great as a numeric percentage, however for the life of me I cannot get it to chart the WMI value of %EstimatedChargeRemaining% as a horizontal bar (like the deprecated BATTERY option would) – I’ve looked at other examples where a WMI value is charted, but all I can get to chart is a simple ‘1’ (with a chart I imagine is showing 1% full). I’m obviously missing something, could anyone help me out?
2 September, 2019 at 7:23 am #2121
The critical piece of information you’re missing is the return value number. EstimatedChargeRemaining is not the first property in the class. What you need to do is look up the specs for the Win32_Battery wmi class to find out what number the EstimatedChargeRemaining property is.
The fastest way is type the class name into google and find the first result from docs.microsoft.com. In this case you’ll end up at
This page lists all the properties returned by the class. Now just count them off until you get to the property in question and you’ll find that EstimatedChargeRemaining is 15. Put this number into the chart definition as the series number.
chart:bar linear 100 15 -100
3 September, 2019 at 3:44 am #2123
Thanks Glenn for the tip. I’m still missing something. I used:
WMI=active:1,interval:10,text:Battery,namespace:root\cimv2,query:Win32_Battery,chart:bar linear 100 15 -10
but still I just see ‘Battery 1’ in Desktop Info. I tried it on both my laptop computers. I can see, as you said, that item 15 is the estimatedchargeremaining item, and strangely, if I use the wrong ‘chart:bar linear 100 1 -10’, I get the outline of a box that would store the chart, but if I use 15 for the series, I don’t even get an outline. Aargh! Any chance of a little further help? Thanks again for a great tool.0
3 September, 2019 at 6:51 am #2124
you have to add the display template option:
this is the complete item
WMI=active:1,interval:10,text:Battery,namespace:root\cimv2,query:Win32_Battery,chart:bar linear 100 15 -10,display:%EstimatedChargeRemaining%% (%battery%BatteryStatus%%)1+
3 September, 2019 at 6:29 pm #2125
Worked a charm. Thanks! I was trying to run the percentage as a number on one line, and then the chart as a bar on its own by repeating the WMI query, not including the display template because I (wrongly) thought that would duplicate the percentage as a number. Thanks again!1+