I'm looking for a way to read out the current energy drain of various macOS devices that should be backwards compatible at least to macOS 12.
So far I already had a couple of good idea – well initially I thought so – to get that data from ioreg or IOKit, reading out AppleSmartBattery object.
I'm trying to write a small program in Rust that collects the energy usage of our companies macOS devices and record this how much happened while in the office and how much on the road. Therefore I need to consider cases where the battery is charging as well as the battery is full and energy is drawn from the power adapter or usb-c connected display directly via PD.
So far I was able to read the desired data out via ioreg with plist output and parse the information into a struct. The issue I have testing this out that my 1st approach of going for PowerTelemetryData which would be perfect is only available on macOS 13+ systems. The second approach reading out the subobjects of BatterData and PowerOutDetails seem to only be available on macOS 12 devices now and then.
Any suggestions or hints?