Review of b4a222f, brief v6 Expected 11 (owner 2026-11-18):
- Solar keeps watching for another writer while it is not writing (Stop,
shadow, safety stop), so hold is true for every reader: the exit, the
shutdown, the peak alarms, and Start afterwards.
- car_solar_can_cut() also needs Solar to be writing: the peak alarms stand
as in Off and the quarter is banked.
- A start or restart in Solar with shadow on writes nothing (the
not-writing 0 A is owed only when Solar had the charger before).
- Once that exit 0 A is taken, nothing more is written, shutdown included.
Tests: alarm rows for Stop, shadow on and safety stop against an Off twin;
shutdown after another writer in shadow and Stop; a start in shadow with the
car already charging; Start after a stop; two variants inside the 30 s watch.
Co-Authored-By: Claude <noreply@anthropic.com>
7.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.
Round 4 (review of d2504ef, brief v5)
- The wait needs headroom (owner 2026-11-18):
ctl_car._car_batt_headroom. The 15 s wait runs only while a battery is above its cut-out, the guard is neither saturated nor floor-limited (peak reserve), and the batteries' output is more thanHEADROOM_W(100 W) under what they can give (guard.able_w, else the site rating). Otherwise the cut comes at once. Before, "above the cut-out" alone let the car run 15 s while the batteries were already at full output, and the period landed over the aim (review repro: house 25 900 and 25 950 W, test_ev05.py R4/N4 against a car-Off twin).
Round 5 (review of 8818768)
- Headroom counts only the batteries that can give (
ctl_car._car_giving): above their cut-out, not refusing to give (SAFETY-73), not under a safety stop, switched on. Their output is compared with their own ratings (andguard.able_wwhen the guard names it). Before, the site rating still counted a refusing unit, so a battery that gave its full rating looked like it had headroom and the cut waited (review repro: battery A refuses, house to 20 950 W, period 3436 W against the twin's 3363 W).
Round 6 (review of 69f5818)
- Solar grades the car out of the peak alarms only while it can cut it
(
ctl_car.car_solar_can_cut): not while another writer holds the charger, a write of ours was refused or given up, a way-out 0 A is not taken, the charger shows a fault or cannot be read. Otherwise the normal alarms stand as in Off, and the quarter is banked as the car's (it can set the peak). - A refusing battery counts for nothing at every N: at N=1 the refusal is
Controller.batt_refused(SAFETY-52). The site's own safety stops (circulation, site sign) leave no battery able to give. - A battery switched Off still counts for the headroom: the peak guard's floor draws on it, so it can catch a cloud edge.
- Only pressing Solar lifts Solar's other-writer hold. Leaving Solar (Off, Manual) or setting Manual's current or phases is not the user taking the charger back, so nothing is written over that writer (N10).
Round 7 (review of b4a222f, brief v6 Expected 11)
- Solar keeps watching for another writer while it is not writing (Stop,
shadow, a safety stop), so
holdis true for every reader: the exit 0 A, the shutdown, the peak alarms and Start afterwards (Solar holds off until Solar is pressed or the read-back matches). - The peak alarms stand while Solar is not writing:
car_solar_can_cut()also needscar_writing(). The quarter is banked as the car's. - A start or restart in Solar with shadow on writes nothing (owner
2026-11-18), even with a car already charging under another writer: N10
wins over the restart 0 A. The not-writing 0 A is owed only when Solar had
the charger before (
had_control). - Once that exit 0 A is taken, nothing more is written, shutdown included. A shutdown while Solar is writing still sends its 0 A before the inverters (T26).
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).