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>
4.9 KiB
EV-05 — Solar mode: spare sun to the car
The design is reports/EV-01-design-report.md (sections 2 to 5, decisions 2 and
5) and the EV-05 brief v3 (owner answers Q1 and Q4, 2026-11-17). This record
keeps what the code had to decide.
Where it lives
carmode.SolarPlan decides (pure, monotonic clock): what current, on what
phases. carmode.SolarWriter makes the charger match it. It is a subclass of
ManualWriter, so the write, the read-back, the phase sequence and the
other-writer watch are Manual's and there is still one write_current and one
write_phases call in app/ (test_ev04.py's AST check). ctl_car builds the
inputs (car_sun_inputs) and runs the writer in the same background task.
The rules the brief left open
- Entering Solar starts at 0 A. Choosing Solar, a restart in Solar, the charger or Home Assistant coming back, a charger error or a stuck reading clearing, and control starting again all reset the plan: 0 A if the charger shows more, then the start rule. Switching from Manual to Solar therefore pauses a Manual charge for the start dwell. Simple and on the safe side.
- The peak cut is what the guard would ask the batteries for. The excess is
taken off the car only when the guard is engaged and wants a discharge
(
wanted_w > 0), and bymin(excess, wanted). Batteries that only stop charging in a cloud's first seconds are not "asked", so a cloud does not cut the car. A partial cut caps the car for the rest of that 15-minute period. - The cut waits 15 s while a battery can still give (owner 2026-11-18,
round 2):
ctl_car.CUT_WAIT_S, counted from the first cycle in a row in which the guard wants power. A battery "can give" when it is above its own cut-out level, not refusing to give and not under a safety stop (_car_batt_able). It cuts at once with nothing able, or with 120 s or less of the period left (CUT_NEAR_END_S): waiting 15 s with R s left raises what must come off afterwards by R / (R - 15), at most 8/7 at 120 s, and the cut then takes it off the car at once. test_ev05.py T21 (a step beyond the batteries, cut at 15 s) and T24 (c) (a late step, cut at once) show the period landing under the aim; the 10-hour day of test_ev05_long.py has no cut pause at the shippedslew_w0. - The 4.0 to 4.14 kW band on 3 phases. 3 phases need 4.14 kW at 6 A, the switch back to 1 phase is under 4.0 kW. Inside that band the car holds 6 A on 3 phases with no pause count (the hysteresis the design chose). Under 4.0 kW the down-switch comes after 5 minutes; if the 10-minute gap blocks it, the pause rule does instead.
- A phase switch also waits for the 30 s write rule, so the current set after a switch is never sooner than 30 s after the one before it.
- The meter's age. The spare is not computed from a meter reading older
than
stale_input_s, also whenmeter_max_age_s(P1) is longer. - A stale, stuck or not corroborated charging car makes the spare unknown:
hold, then 0 A after Pause after. A paused or idle car with a fresh reading
counts 0 W (
car_w_trustedis None outside mode3 C). - A stuck reading's 0 A is written whatever the frozen read-back says, since that read-back means nothing then. Every other exit skips the write when the charger already shows 0 A, and never writes over another writer.
- The guard's alarm path uses the Solar car like Manual's
(
car_alarm_w), and Solar's own 0 A (pause, cut, phase change) gets EV-15's bounded grace (_car_solar_pause). A Solar quarter is never banked as "set by the car", and Solar shows no Car over the peak limit. - 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_S60 s apart,MAX_TRIES3), then the gave-up row andCHARGER_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 andCUT_SETTLE_S(15 s) more for the meter.
Solar kWh
Per cycle in Solar: min(car power, max(0, spare - room)) Batteries first,
min(car power, max(0, spare)) Car first; never above today's kWh; reset at the
day change; kept in the store (car_sun).