EV-05 round 3: a refused way-out 0 A is tried again; one cut per excess
checks / unit (pull_request) Successful in 24m5s
infra-pin / fresh (pull_request) Successful in 2s

Review of 17a7b29:
- Critical: every way out of Solar (Off, Stop, shadow, safety stop, charger
  error, stuck reading, no car) now owes a 0 A until the charger takes it:
  tried again 60 s apart, 3 times (EV-04's rule), then the gave-up row and
  CHARGER_REFUSED; never over another writer. Shutdown does not trust last_a
  while a write of ours is unconfirmed. The card no longer says paused while
  the 0 A is not taken.
- Major: an excess episode is taken off the car once, measured from the car's
  power when it began, until the car shows it and 15 s more.

Tests: refused-then-accepted 0 A for each exit, a 0 A never taken, shutdown
during a start write's read-back, a cut from 16 A with a slow car; the fuzz
checks refused exits of every kind (N9).

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
ems-agent
2026-11-18 12:15:00 +01:00
co-authored by Claude
parent 17a7b299d2
commit d2504efa82
9 changed files with 338 additions and 58 deletions
@@ -58,6 +58,22 @@ inputs (`car_sun_inputs`) and runs the writer in the same background task.
- **Shadow mode** runs the plan without writing, so the card says what it would
set; the charger got its one 0 A when shadow mode came on.
## Round 3 (review of 17a7b29)
- **A way-out 0 A is written until the charger takes it** (`SolarWriter.
_exit_zero`): Off, Stop, shadow, a safety stop, a charger error, a stuck
reading and no car each owe a 0 A; one that is not taken is tried again by
EV-04's rule (`RETRY_S` 60 s apart, `MAX_TRIES` 3), then the gave-up row and
`CHARGER_REFUSED`. Once taken, or once the charger shows 0 A, nothing more.
Never over another writer. A stuck reading cannot confirm a write, so there
only a taken write counts (up to 3 tries). At shutdown there is one try, and
a write of ours not yet confirmed (cancelled during its read-back) means the
current is unknown, so the 0 A is written.
- **One excess, one cut** (`SolarPlan.ep`): an excess episode is measured from
the car's power when it began, so the same excess is not taken off again
while the meter still shows the old power. A new cut needs the car to show
the lower power and `CUT_SETTLE_S` (15 s) more for the meter.
## Solar kWh
Per cycle in Solar: `min(car power, max(0, spare - room))` Batteries first,