C1: an own 0 A not yet read back is kept with the mode; a start in Off with it writes the 0 A (retried), without it nothing; a start that will not write warns once when the charger still has the add-on's current. C6: Solar's 30 s gate also counts from Manual's latest write. C9: an exit also owes its 0 A when the read-back shows Solar's own value. Rows for C5 and C8 too. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w
111 lines
6.6 KiB
Markdown
111 lines
6.6 KiB
Markdown
# EV-20 — Solar mode: spare sun to the car (charging only)
|
|
|
|
Part 1 of the split of cancelled EV-05 (owner 2026-11-19). The design is
|
|
`reports/EV-01-design-report.md` sections 2-5 and decision 5; the rules are
|
|
EV-20's brief (Expected 1-15, D1-D4). EV-21 (the car cut first for the peak)
|
|
and EV-22 (another writer's phase change) are separate cards. This record keeps
|
|
what the code had to decide.
|
|
|
|
## Where it lives
|
|
|
|
`app/carmode.py`: `SolarPlan` (pure: the spare, the room, the dwells, the auto
|
|
phases) and `SolarWriter`, a subclass of EV-04's `ManualWriter`. It writes only
|
|
through `ManualWriter._write` and `_advance`, so the two write call sites stay
|
|
exactly two (test_ev04 / test_ev20 T55). `app/ctl_car.py` builds the inputs
|
|
(`car_spare_w`, `car_room_w`), runs the step beside the cycle, the release at
|
|
shutdown and today's solar kWh.
|
|
|
|
## One rule for every write (EV-05 review rounds 2-9)
|
|
|
|
EV-05 needed nine review rounds, mostly on exits and other writers. EV-20 keeps
|
|
one small set of facts and derives every path from them:
|
|
|
|
- `sent_a`: the current Solar last decided, recorded BEFORE the write goes out;
|
|
`taken`: the charger confirmed it. A write cancelled while it waits is never
|
|
trusted (round 2, T37).
|
|
- A value is written when Solar DECIDES a new one. One the charger did not take
|
|
is tried again after 60 s, three times, then the gave-up row and one
|
|
CHARGER_REFUSED warning (EV-04's rule; round 2's Critical, T36). A new 0 A
|
|
gets its own three tries and never waits.
|
|
- A read-back that shows what Solar sent confirms it, however late (round 9's
|
|
second Major, T48).
|
|
- A read-back that differs from what Solar sent is never written over:
|
|
EV-04's `_watch` judges it, and while the difference stands Solar writes
|
|
nothing in its running state. After 30 s the hold (amber row, one
|
|
CHARGER_OTHER warning) stops every write, the way-out 0 A and the shutdown's
|
|
included (N16; rounds 5-7). Only pressing Solar lifts it.
|
|
- `live`: Solar's own current may stand on the charger (a non-zero value it
|
|
sent, or a 0 A not yet confirmed). A way out (Off, Stop, shadow, a safety
|
|
stop, a charger error or stuck reading, no car, shutdown) writes 0 A only
|
|
then. So a start in shadow writes nothing, and once the way-out 0 A is
|
|
confirmed nothing more is written, shutdown included (rounds 6 and 7).
|
|
- The start-up and a charger (or Home Assistant) that comes back write 0 A
|
|
first whatever the charger shows, with the read-back references cleared, so
|
|
its own value is never "another writer" (D2; round 9's first Major, T29,
|
|
T30, T61).
|
|
|
|
## Choices the brief left open
|
|
|
|
- **Writes over an unexplained read-back stop at once**, not after 30 s: the
|
|
plan goes on, the next decision waits. A way out still writes its 0 A inside
|
|
those 30 s (T39 (b)): 0 A is the safe side.
|
|
- **The phases follow the charger.** Solar's arithmetic uses the phases the
|
|
charger reports (1 for a one-phase car); its plan adopts them whenever it is
|
|
not switching. It selects only by its own dwells (and a start from a pause in
|
|
auto, on 1 phase), never "back" over a change it did not make (D4: EV-22).
|
|
A lower current is never blocked by the 10-minute phase gap (round 8, T46).
|
|
- **An interrupted phase change ends at its 0 A.** Manual's restore of the old
|
|
current stays Manual's.
|
|
- **Pressing Solar** lifts another writer's hold and takes the charger as it
|
|
is; Solar's own value is then decided and written afresh. Choosing Solar from
|
|
another mode starts paused: 0 A, then the start rule.
|
|
- **Stale and unknown.** The spare is unknown with a meter older than
|
|
`stale_input_s` (P1's own bound may be longer), readings late past it, a
|
|
missing or NaN battery or grid figure, or a charging car whose figure is
|
|
stale, stuck or not corroborated. A paused or idle car counts as 0 W. Unknown
|
|
holds the current for `ev_pause_min`, then 0 A. A cycle that returns early for
|
|
missing or late readings still steps Solar (Manual is left as it was).
|
|
- **The guard treats a Solar car exactly as a Manual car** (Expected 8): every
|
|
alarm-path test that said "Manual" says "Manual or Solar"
|
|
(`car_controlled`). Solar's own phase change gets EV-15's grace as Manual's;
|
|
its own 0 A pause gets it from the send, at most `OWN_PAUSE_MAX_S`, and only
|
|
while the read-back still shows that 0 A (round 8's second Major).
|
|
- **D1 wording.** The card's Why says "Solar charges the car at {a} A. This
|
|
sets the peak."; STYLE.md allows a grey note and a grey row one sentence, so
|
|
they say "Solar charges the car at {a} A, which sets the peak." `{a}` is the
|
|
charger's read-back, never Manual's stored current.
|
|
- **D3 at shutdown.** In Solar the charger's 0 A goes out before the inverters'
|
|
0 W: up to three tries 5 s apart, each waiting 4 s for its read-back
|
|
(`write_current(took_s=...)`), all inside `RELEASE_WAIT_S` (15 s, also a
|
|
wall-clock bound for a charger that hangs). Not taken: one CHARGER_RELEASE
|
|
warning, the notice *Car may still be charging* after the inverters are
|
|
released, and the next start writes 0 A first (D2) and takes the notice down.
|
|
- **A charger error** sets 0 A (while owed) with one CHARGER_ERROR warning
|
|
and the card's Why; the existing grey error row shows it. No new
|
|
notification.
|
|
- **Solar kWh** is counted per cycle in Solar only: `min(car, max(0, spare -
|
|
room))` Batteries first, `min(car, max(0, spare))` Car first; never above
|
|
today's kWh; stored with its day, reset at the day's change.
|
|
- **Rollback.** An older build reads a stored `car_mode = solar` as Off
|
|
(`start_mode`) and writes nothing; no state migration.
|
|
|
|
## SPIKE-05 decisions (brief v4/v5)
|
|
|
|
- **C1.** An own 0 A that is out and not read back is kept in the store with
|
|
the mode (`car_exit_0a_pending`). A start in Off with that flag writes the
|
|
0 A (when it may write), retried by the exit rule; Off without it writes
|
|
nothing (N10). A start that will not write (shadow, control stopped) after
|
|
Manual or Solar, with the charger showing a current, writes nothing and
|
|
raises one warning, *Charger kept its current*, taken down at 0 A.
|
|
- **C5.** Each shutdown try waits 4 s for its read-back (D3 above).
|
|
- **C6.** One write clock: Solar's 30 s gate also counts from Manual's latest
|
|
non-zero write, the start included. Solar's first write after Manual is its
|
|
0 A, which is never gated.
|
|
- **C8.** A charger or HA outage ends a phase change: the return restarts the
|
|
plan paused, so nothing of the sequence resumes; only a 0 A may come before
|
|
the start rule.
|
|
- **C9.** An exit owes its 0 A while Solar's own value may stand: by its own
|
|
bookkeeping (a 0 A not read back counts) or by the read-back showing a value
|
|
it sent, confirmed, tried or saw at a refused try.
|
|
- **C3** is T43-T45; **C7** is EV-22's.
|