Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

macwatt

Read the real charger and power telemetry off an Apple Silicon MacBook — what the machine is actually drawing, where it's going, and how much the brick is wasting. No sudo. Read-only. One file, no dependencies.

Why this exists

powermetrics is the usual answer for power on macOS, and it has two problems:

  1. It needs sudo, which makes it awkward to poll or script.
  2. It doesn't report input power at all, and on M4 its CPU Power field reads a flat 0 mW.

Meanwhile the SMC is already publishing instrumented, calibrated power numbers through IOKit that nothing surfaces. They live in the AppleSmartBattery node, under a dictionary called PowerTelemetryData, and they are readable by any user with plain ioreg.

The numbers are real, not estimated — the budget closes to the milliwatt:

SystemPowerIn = BatteryPower + SystemLoad

macwatt checks that identity on every sample and tells you if it ever fails to close, which is your signal that something in the parse drifted.

Output

  battery 100%, on AC

  adapter offers       89.0 W   (20 V @ 4.45 A contract)
  PMU input ceiling    89.0 W   (4450 mA cap, 100% of adapter)
  ----------------------------------------------------
  drawing now          19.2 W   (20.18 V @ 0.95 A)  = 22% of ceiling
       into battery     0.0 W
       into system     19.2 W
       (budget check: ok)

  brick loss            0.4 W   -> ~19.6 W at the wall

  volt at the Mac     20.18 V   (20 V contract, +0.18 V)
  implied path R      none   at or above contract; source is holding the rail

Three different things get conflated as "how many watts is my charger doing," and this separates them:

Line What it actually means
adapter offers What the brick advertised in its USB-C PD contract. A claim, not a measurement.
PMU input ceiling What the Mac's power controller configured itself to accept. Can be lower than the contract.
drawing now What is genuinely flowing, measured at the Mac.

A charger that renegotiates downward mid-session shows up as the middle line dropping while the top line stays put — which is invisible to every other tool and to the battery icon.

Install

Single file, standard library only, Python 3.8+.

curl -fsSL https://raw.githubusercontent.com/ytomasch/macwatt/main/macwatt.py -o /usr/local/bin/macwatt && chmod +x /usr/local/bin/macwatt

Or run it straight out of a clone with python3 macwatt.py.

Usage

macwatt                 one snapshot of this machine
macwatt -w              watch, refreshing every 15s
macwatt -w -i 30        watch at a custom interval
macwatt -n 5            take 5 samples and stop
macwatt -j              newline-delimited JSON, one object per sample
macwatt --host user@ip  read a different Mac over SSH

The SMC refreshes these values roughly every 15–20 seconds, so polling faster than that just gives you the same numbers again.

Set MACWATT_HOST to make an SSH target the default — useful for monitoring a Mac from a machine that isn't one:

export MACWATT_HOST=user@mac.local

-j emits flat JSON with raw milliwatt/millivolt/milliamp integers and an ISO timestamp, so macwatt -w -j >> power.ndjson gives you something you can chart later without reparsing text.

Diagnosing a charger with it

The last two lines are the useful part, and they answer a question that is otherwise annoyingly hard: is my charging problem the cable or the brick?

macwatt compares the voltage the adapter says it negotiated against the voltage actually measured at the Mac. If there's a shortfall, it reports the series resistance that would explain the whole drop, plus how much heat that resistance would be dissipating.

The trick is that one reading tells you nothing — two readings at different currents tell you everything. Take a sample at idle, then load the machine up and take another:

  • Implied ohms stay roughly constant → it really is resistive. Bad cable, dirty connector, or an undersized extension. The heat figure tells you how bad; anything approaching a watt is a connector you can feel.
  • Implied ohms move a lot between the two → nothing is resistive. The brick is regulating below its own advertised contract, i.e. it's the charger failing, not the cable.

That distinction normally requires a USB-C power meter inline. Here it's two invocations.

Requirements and limits

  • Apple Silicon MacBooks. The tool reads AppleSmartBattery, so desktop Macs have no such node and it will say so.
  • Developed and tested against an M4. Other generations expose the same dictionary, but if a field is missing it renders as -- rather than guessing.
  • If PowerTelemetryData is absent entirely, it exits with a clear message rather than reporting zeros.
  • AdapterEfficiencyLoss is the SMC's own figure for what the brick is burning, so the "at the wall" number is as good as Apple's estimate — treat it as indicative, not as a substitute for a wall meter.

License

MIT — see LICENSE. Copyright (c) 2026 Amur Labs LLC.

About

Real charger and power telemetry from an Apple Silicon MacBook - input, battery and system watts the SMC publishes but powermetrics does not. No sudo, stdlib only.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages