It is currently March 29th, 2024, 3:50 pm

Can't get Battery Status from UsageMonitor

Get help with creating, editing & fixing problems with skins
User avatar
sammilucia
Posts: 10
Joined: November 28th, 2020, 11:18 pm

Can't get Battery Status from UsageMonitor

Post by sammilucia »

Hi!

I'm trying to use the new UsageMonitor to retrieve the Battery Status.

Running Rainmeter as Administrator, I can retrieve...

Code: Select all

Category=Processor Information
Counter=% Processor Time
...fine using the below code, but I can't get anything sensible out of the Battery Status. It does display fine in PerfMon.exe.

Is there something I'm doing wrong or are some PerfMon things not supported?

Code: Select all

[BatteryDischarge]
Measure=Plugin
Plugin=UsageMonitor
Category=Battery Status
Counter=Discharge Rate

[mainText]
Meter=STRING
MeterStyle=mainTextStyle | mainTextCommon
MeasureName=BatteryDischarge
Text=%1
NumOfDecimals=1
Thank you 😊
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm

Re: Can't get Battery Status from UsageMonitor

Post by SilverAzide »

sammilucia wrote: ↑November 29th, 2020, 12:25 am Is there something I'm doing wrong or are some PerfMon things not supported?
No, you are not doing anything wrong. The Battery Status class can't be queried by UsageMonitor. In fact, the WMI BatteryStatus class (which is what PerfMon is querying, is actually undocumented by Microsoft. If you Google it, you'll find lots of folks with examples of how to use it, but there is no official documentation on this class. I'm not sure why PerfMon even shows it, other than it is probably querying all the WMI classes programmatically and just showing you everything it found.

If you are trying to build a battery skin, you have a couple options. One is to use HWiNFO, as it will show you the data you are looking for. Another way is to use PowerShell or command queries to fetch the data from the WMI class using a CommandMeasure. Or you can write a plugin to do it, which is what I did.
β€’ Gadgets β€’ Wiki β€’ GitHub β€’ More Gadgets... β€’
User avatar
CyberTheWorm
Posts: 860
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: Can't get Battery Status from UsageMonitor

Post by CyberTheWorm »

The only source of knowledge is experience. Albert Einstein
Deviant Art Page
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm

Re: Can't get Battery Status from UsageMonitor

Post by SilverAzide »

Yes, that works, but it doesn't tell you voltages and charge/discharge rates, which is what it appears the OP is looking for.
β€’ Gadgets β€’ Wiki β€’ GitHub β€’ More Gadgets... β€’
User avatar
sammilucia
Posts: 10
Joined: November 28th, 2020, 11:18 pm

Re: Can't get Battery Status from UsageMonitor

Post by sammilucia »

SilverAzide wrote: ↑November 29th, 2020, 4:00 am No, you are not doing anything wrong. The Battery Status class can't be queried by UsageMonitor.
ah, thank you so much! that makes sense ... i'm not losing it 😜
SilverAzide wrote: ↑November 29th, 2020, 4:00 am If you are trying to build a battery skin, you have a couple options. One is to use HWiNFO, as it will show you the data you are looking for. Another way is to use PowerShell or command queries to fetch the data from the WMI class using a CommandMeasure. Or you can write a plugin to do it, which is what I did.
thank you. I don't really want to rely on another piece of software (including PowerShell) because I can't control how performant it is. that's why I was trying to use UsageMonitor.

is your plugin available for use or private use only?

thanks so much for clarifying!
User avatar
sammilucia
Posts: 10
Joined: November 28th, 2020, 11:18 pm

Re: Can't get Battery Status from UsageMonitor

Post by sammilucia »

CyberTheWorm wrote: ↑November 29th, 2020, 3:13 pm What about the power plugin https://docs.rainmeter.net/manual/plugins/power/
ty 😊
SilverAzide wrote: ↑November 29th, 2020, 4:41 pm Yes, that works, but it doesn't tell you voltages and charge/discharge rates, which is what it appears the OP is looking for.
yes that's correct. I really want to see battery discharge rate so I can see if there's a runaway process, because I use my laptop on battery all day.
User avatar
sammilucia
Posts: 10
Joined: November 28th, 2020, 11:18 pm

Re: Can't get Battery Status from UsageMonitor

Post by sammilucia »

dvo wrote: ↑November 29th, 2020, 6:10 pm https://www.nirsoft.net/utils/battery_information_view.html this can write it to xml and that you could you parse in rm... :welcome:
thank you dvo. I do trust Nirsoft to be well written, however I think I'd rather write a plugin and have it nice and efficient and integrated.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm

Re: Can't get Battery Status from UsageMonitor

Post by SilverAzide »

sammilucia wrote: ↑November 29th, 2020, 7:00 pm is your plugin available for use or private use only?
You can use it. Install the Gadgets suite and you'll find a Battery Meter skin. It uses a custom plugin, which is really just uses WMI to query the battery (among other things). There is a readme text file in the Resources folder which will describe how to use the plugin. You'll see how it works if you look at the Battery Meter code. There's also a variant skin which is identical, but uses HWiNFO instead.
β€’ Gadgets β€’ Wiki β€’ GitHub β€’ More Gadgets... β€’
User avatar
sammilucia
Posts: 10
Joined: November 28th, 2020, 11:18 pm

Re: Can't get Battery Status from UsageMonitor

Post by sammilucia »

SilverAzide wrote: ↑November 29th, 2020, 10:23 pm You can use it. Install the Gadgets suite and you'll find a Battery Meter skin.
thank you so much, it works brilliantly! 😊 (top right)

Image

the theme is an edit of https://flyinghyrax.deviantart.com and not for release, all credit goes to yourself and FlyingHyrax.

thanks again SilverAzide 😊
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm

Re: Can't get Battery Status from UsageMonitor

Post by SilverAzide »

sammilucia wrote: ↑November 29th, 2020, 10:58 pm thank you so much, it works brilliantly! 😊 (top right)
Kewl... 8-)
β€’ Gadgets β€’ Wiki β€’ GitHub β€’ More Gadgets... β€’