I'm trying to get the power usage (in watts) but I can't figure out how. I looked at pmset and IOKit but couldn't find anything about it. coconutBattery can calculate it for laptops using the MacOS internal power information.
/usr/sbin/system_profiler SPPowerDataType | grep Wattage
The utility also accepts an -xml
flag; the specific key in the XML is sppower_ac_charger_watts
.
If you only need this information for a laptop, call IOPMCopyBatteryInfo and look at the values for the kIOBatteryVoltageKey and kIOBatteryAmperageKey keys to compute the power usage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With