Reputation: 99
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.
Upvotes: 9
Views: 9424
Reputation: 8386
This works even on mac Minis which don't have batteries:
$ sudo powermetrics | grep "Combined Power"
Combined Power (CPU + GPU + ANE): 17021 mW
You can get CPU/GPU/ANE split up with:
$ sudo powermetrics | grep " Power"
CPU Power: 16935 mW
GPU Power: 82 mW
ANE Power: 0 mW
Combined Power (CPU + GPU + ANE): 17017 mW
(results are real results from my M1 Mini)
Upvotes: 0
Reputation: 5257
You should use ioreg -n "AppleSmartBatteryManager" -r -l
and from there it should be easy to calculate.
Upvotes: 2
Reputation: 593
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.
Upvotes: 2
Reputation:
/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
.
Upvotes: 8