Review of 8818768: the headroom test compared the output with the site
rating, which still counted a battery refusing to give (SAFETY-73) or under
a safety stop, so the 15 s wait ran at the real maximum (N4). Now only the
units that can give (above their cut-out, not refusing, not stopped,
switched on) count, in what they give and in their ratings.
Tests: R5a (A refuses, B at full rating, against a car-Off twin: the cut at
910, period 3361 W), R5b (headroom and a slow battery: the cut at exactly
15 s), R5c (floor-limited alone decides: cut at once). DOCS wrapped to 79.
Co-Authored-By: Claude <noreply@anthropic.com>
6.1 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).
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).