Reputation: 41
I have tried the following command in macOS to get all the battery information:
pmset -g batt
The above command is displaying only one information(i.e 35% discharging).
system_profiler SPPowerDataType | grep "Device Name" | awk '{print $3}'
The above command is displaying device name.
Is there any command by using which together all battery information(Serial Number, Manufacturer, device name, cycle count, charging, etc.),we can fetch. Please help me in finding this. Thanks for your help in advance.
Upvotes: 4
Views: 6079
Reputation: 174
try this also, it work for me on Apple Silicon but not the above method-
ioreg -l| grep -e '"CurrentCapacity" =' -e '"MaxCapacity" =' -e '"CycleCount" =' -e '"model" = '
or below for formatted results
ioreg -l | grep -e '"CurrentCapacity" =' -e '"MaxCapacity" =' -e '"CycleCount" =' -e '"model" = ' | sed 's/[[:space:]]*\|[[:space:]]*/ /g' | awk '{$1=$1}1' OFS=" "
Upvotes: 0
Reputation: 363
The best command that I could think of is
ioreg -w0 -1 | grep Capacity
For me this returns something like this: | | "AppleRawCurrentCapacity" = 6417
| | "AppleRawMaxCapacity" = 6834
| | "MaxCapacity" = 6834
| | "CurrentCapacity" = 6417
| | "LegacyBatteryInfo" = {"Amperage"=18446744073709550119,"Flags"=4,"Capacity"=6834,"Current"=6417,"Voltage"=8204,"Cycle Count"=198}
| | "DesignCapacity" = 7150
| | "BatteryData" = {"StateOfCharge"=24064,"Voltage"=8204,"QmaxCell1"=46108,"ResScale"=0,"QmaxCell2"=0,"QmaxCell0"=54044,"CycleCount"=198,"DesignCapacity"=7150}
Don't forget that you can combine multiple commands into one to run after the other has completed with && eg:
system_profiler SPPowerDataType | grep "Device Name" | awk '{print $3}' && ioreg -w0 -1 | grep Capacity
You can also replace the word Capacity with things like board-id
If you want to process all this data I would create a bash script to do it for you,
Because you can cut up the lines to display the info that you want like:
ioreg -l | grep board-id | cut -d \" -f 4
Obviously you can just type this into the terminal but doing this for every command gets a bit tyresome!
Combine many of these commands to make a script (or even in python!) that would process all the data and return it in anyway you would like, if that is possible for what you want to use that data for!
I should think that all the possible accessible battery information is found in system information > power:
Battery Information:
Model Information:
Manufacturer: DP
Device Name: bq20z451
Pack Lot Code: 0
PCB Lot Code: 0
Firmware Version: 511
Hardware Revision: 000a
Cell Revision: 1210
ETC.....
EDIT:
Istats is a free CLI which allows you to view a lot of info but is obviously not native see https://robservatory.com/see-sensor-stats-in-terminal/
To find the battery temp with a single native command! :
bc <<< "scale=3; `ioreg -r -n AppleSmartBattery | grep Temperature | cut -c23-`/100"
Hope this helps
Upvotes: 4