Skip to content

Stop charging at once when a limit is set; read the cable through adapter cuts - #81

Merged
broisnees merged 1 commit into
mainfrom
fix/instant-limit-bridge
Nov 15, 2026
Merged

broisnees merged 1 commit into
mainfrom
fix/instant-limit-bridge

Conversation

@broisnees

Copy link
Copy Markdown
Collaborator

Why (traced on a Mac with no charge-inhibit key, which limits through macOS's charge limit)

  • The limit was slow to bite. After the limit was set to 80% at 89%, current kept flowing for 42 s. The panel truthfully said "Charging", which read as the switch not working.
  • An adapter cut looked like an unplug. Whether eWiz cut the adapter or macOS did while draining to its limit, IOKit cleared ExternalConnected. The panel said "On battery" with the cable in, and the plug cue could fire.
  • The tie-breaker signal. An unplug test on that Mac: during a cut ExternalChargeCapable stays Yes; on a real unplug it goes No in the same sample. AdapterDetails lingers ~1 s after a pull, so it can't be used.

Changes

  • Helper. After setting a native limit below the current level, the helper cuts the adapter for up to 90 s (nativeBridgeWanted), then hands back to macOS's limit. Measured: 1.4 s from the limit being set to charging stopping.
  • BatteryMonitor.cablePresent = ExternalConnected || ExternalChargeCapable.
  • ControlResponse.adapterPresent passes on the SMC AC-W reading where the key exists. The app uses it for discharging, re-reads every 3 s while a cut is on, and checks the helper before a plug or unplug cue.
  • HelperBuild 31 → 33.

Tests

swift test: 287 pass (new: cable presence through a cut). Helper build 33 was run on the Mac described above, and the bridge behaviour was verified with scripts/plug-trace.py.

…pter cuts

Traced on a Mac that limits through macOS's charge limit: macOS took 42 s to
stop charging after the limit was set. The helper now cuts the adapter for up
to 90 s after setting a native limit below the current level (1.4 s to stop).

On the same Mac an adapter cut (eWiz's, or macOS draining to its limit) clears
ExternalConnected exactly like an unplug; ExternalChargeCapable stays Yes until
a real pull. BatteryMonitor.cablePresent uses both. The helper also reports the
SMC AC-W reading where present, the app follows a cut every 3 s, and plug cues
check the helper before sounding. HelperBuild 33.
@broisnees
broisnees merged commit c76b13a into main Nov 15, 2026
1 check passed
@broisnees
broisnees deleted the fix/instant-limit-bridge branch November 15, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant