Files
puter/POWER-REPORTING.md
T
soconnor 4bfa239aa0
Build and test / macos (push) Waiting to run
Signed release / release (push) Waiting to run
Refresh puter UI, power telemetry and demand-aware monitoring
2026-09-22 20:03:16 -04:00

54 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Power reporting
Battery telemetry now uses IORegistryEntryCreateCFProperties on AppleSmartBattery,
not regular expressions over human-readable `ioreg` output. On this macOS build,
the tree-prefix indentation caused the old reader to miss BatteryInstalled and
every top-level battery/adapter field.
Readings have separate meanings:
- System load: PowerTelemetryData.SystemLoad in milliwatts, converted to watts.
- Charger → Mac: SystemPowerIn, only while ExternalConnected. This includes
charging; it is not wall-socket consumption or the charger's rated maximum.
- Battery: voltage × signed current. Positive current charges, negative current
discharges. Two's-complement unsigned current is decoded as signed Int64.
- Reported capability: AdapterDetails.Watts. The charger's model name may say
140 W while the current connection reports only 94 W available.
- Negotiated ceiling: AdapterVoltage × Current, not measured current draw.
Unknown readings are not rendered as zero. Zero battery current remains a valid
idle reading. Disconnected adapters are dropped even if stale registry details
remain. Capacity falls back to nested BatteryData on newer registry layouts.
Missing capacity/temperature no longer implies a dead battery or 0 °C.
Available SMC power readings remain a fallback; fresh registry data takes priority.
Registry keys are hardware/OS-dependent and are not a universal power-meter API.
Values are point-in-time samples; their sum may differ because of sampling times,
conversion losses and sensor coverage. No wall-power or cable e-marker claims.
The dropdown is a native NSPopover anchored to an NSStatusItem. Left-click toggles
the panel, right-click presents native metric/update-speed submenus. Command-Shift-M
opens the same panel from the Options menu. Power rows have contextual copy actions
and explanatory help. The native popover owns its outer material and rounding;
actions use Liquid Glass on macOS 26+. Reduce Transparency uses an opaque content
background. There is no second glass rectangle with competing corner radii.
Popover show/close events join the existing demand scheduler. Opening it requests
power/system samples at five-second cadence, without full process inventory,
port enumeration, fan scanning or slow hardware diagnostics. Closing it drops
that demand. Menu-bar readings remain observed even with the main window closed.
Tests cover charging, discharging, two's-complement current, zero vs unknown,
invalid values, nested capacities and dropdown-only sampling demand.
Validation on 22 September 2026: 38 tests passed and Release built successfully.
Computer use verified the panel's live battery/charger values, removed duplicate
corner arcs, and opened the native reading submenu with Battery power and Charger
input choices. The submenu originally dismissed its parent; native menu-tracking
notifications now suspend transient popover dismissal while menus are active.
Actual right-click status-button behavior and all appearance/accessibility modes
still need broader manual coverage; automated tests do not establish those.
Native API reference:
https://developer.apple.com/documentation/iokit/1514310-ioregistryentrycreatecfpropertie