Wrong battery value on MacOS
b1nhack opened this issue · 10 comments
The macchina battery percentage value doesn't match the MacOS system's (about 3 less)
It would help if you provided your macOS, macchina and libmacchina versions.
MacOS Sonoma 14.2.1
macchina 6.1.8
libmacchina 6.3.5
Can anyone with Apple hardware confirm this? If so, please let us know by contributing to the conversation.
I see this issue with the battery too. Let me know if I can help debug the issue.
# native macOS tool
$ pmset -g batt
Now drawing from 'Battery Power'
-InternalBattery-0 (id=33816675) 93%; discharging; 16:46 remaining present: true
# macchina
Battery - 88% & Discharging
Third-party battery replacements have caused issues, though way more sinister than this, in the past 1. Are these miscalculations occuring on machines with an authentic battery?
Footnotes
Yes! My machine is brand new, from the Apple store.
My MacBook also has the factory installed battery. Utils like pmset -g batt
seem accurate while the calculation with macchina
seem off.
I'll defer this to @123marvin123 as he knows more about the macOS side of things than I do.
I'm not sure what could be the reason for these larger differences between the "pmset -g batt" command and macchinas readout. For macchina, the values are coming directly from IOKit. Only minor floating point -> int conversion are expected.
This is what I get on my MacBook Air M1 with original battery:
pmset -g batt
Now drawing from 'Battery Power'
-InternalBattery-0 (id=22282339) 71%; discharging; 4:17 remaining present: true
Battery - 70% & Discharging
Not sure what is the difference between the properties of IOPMPowerSource
but it seems that CurrentCapacity
is the same as one displayed in Menu bar while StateOfChange
used in libmacchina 0 represents something slightly different.
At least that seems to be the case when I checked I/O Kit registry, in terminal, on my machine (mbp13 M1):
ioreg -w 0 -irc IOPMPowerSource
I'm including values that seems relevant to me.
While on 100% battery:
<class IORegistryEntry:IOService:IOPMPowerSource:AppleSmartBattery ...>
{
...
"CurrentCapacity" = 100
...
"BatteryData" = {
...
"StateOfCharge"=99
...
}
...
}
And for example on 71%, CurrentCapacity
is 71 while StateOfCharge
in BatteryData
is 68.
(But they can show same value sometimes)