Files
goodwe-addon/goodwe_controller/DECISIONS/EV-21-car-cut-first.md
T
ems-agentandClaude 83e5b9c51f
checks / unit (pull_request) Successful in 46m35s
infra-pin / fresh (pull_request) Successful in 2s
EV-21 fix round 2 (review): a cut during Solar's own phase change ends it; wait cap in watts
PM R1: a cut due while Solar's own phase change is under way (seq set or plan.switch) is 0 A at once and ends the change at its 0 A; the 15 s wait cap is held in watts and converted with the phases at the write. test_ev21_fix2.py: T34 (iv) red at 5759e9d, T34 (v) 3->1, N6/P27 refused close red with seq_uncapped, N9 standing cap red with stale_drop. test_ev21_fix1.py: C18 now R1; C16 and Q1 accepted as coded (R5).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-28 18:27:18 +01:00

91 lines
5.4 KiB
Markdown

# EV-21 — Solar: the car is cut first for the quarter peak
Part 2 of the split of cancelled EV-05 (owner 2026-11-19). EV-20 made Solar
and graded a Solar car exactly as a Manual car; this card lets Solar lower the
car before the batteries give more for the peak. Manual and Off do not change.
The rules are the PM rulings Q1-Q6, OQ1-OQ10 and Q-A to Q-D (brief v2); the
formal check is reports/EV-21-formal-report.md. EV-05's review rounds 2-9 are
the failure catalogue it answers.
## The rule, in plain words
- **Solar only.** When the 15-minute period heads over the aim (cap less
margin), the car is lowered first. Slowing a battery charge counts as the
batteries taking more (PM Q2), so a charge they could slow down only counts
as headroom for the 15 s wait.
- **How far.** `floor((car W - excess W) / (230 x phases))` A, with the phases
the car draws on (1 for a one-phase car). Under 6 A it is 0 A, never between.
Never above the current Solar has set. An untrusted car figure cuts to 0 A.
- **When.** At once without real headroom: the guard is saturated or at the
peak reserve, the excess is more than the batteries can still add, a battery
figure is missing, the cover option is off, or 120 s or less of the period
is left. Otherwise after at most 15 s, so a cloud edge the batteries catch is
not a cut. A refusing or sign-stopped battery, one at its cut-out or reserve,
and one switched off in battery modes add nothing (a charge it takes can
still stop).
- **Once per episode.** The cut is sized from the episode's start: the car's
power then, less the largest excess seen in it. A lagging meter never takes
it again from the lowered car. A growing excess makes it deeper, never
shallower.
- **Back up.** While a cut is due or stands, Solar does not raise the car, start
it or change its phases; it may still lower it. The car comes back when the
period's projection with the car's start power (6 A) has been under the aim
for the start rule's time (`ev_start_min`), counted from when it went under.
After a second cut in one period it waits for the next period. Then Solar's
own start rule runs as before.
- **The period's end.** No cut state goes over the edge: no cut at :15:00 for
the old period's energy; a new period heading over is cut in its first cycle.
- **Grading.** Solar takes the car out of the alarm grading only while it can
really cut it: Solar writes (no shadow, Stop, safety stop or shutdown), no
other writer, no charger fault or stuck reading, and the read-back shows the
current Solar sent. A cut written but not read back is not a cut. In every
other case the car figure is None for the alarm, the banking and the guard,
exactly as in Off. A Solar car is never banked as the period's cause.
- **The cover option keeps its meaning.** Off: while Solar can cut the car the
guard leaves it out, and the cut comes at once. While Solar cannot cut it,
the guard keeps it in (as Off).
- **What the user sees.** While the cut works: no car-over row and no "Car over
the peak limit" note, the card's Why says "Solar lowered the car for the
peak.", and one grey note with the same words per charging session. When
Solar cannot cut the car, the row and note say the car sets the peak.
## Where it lives
- `app/ctl_car.py` decides, in `car_cycle` (after the guard) and in a cycle
that holds before the guard (missing or late readings, Q4): `_car_cut_tick`.
The state is in memory only (`_cut`): a restart starts afresh, no store key.
- `app/carmode.py` writes: the decision is a cap on Solar's plan
(`SolarWriter.cut_a`, `SolarPlan.step(cap=...)`). The plan lowers to it at
once, past the 30 s gate and the 6 A hold, and starts nothing under it. A
phase change under way closes no higher than the cap. The write goes through
Solar's one write rule: never over another writer's value; a refused cut is
tried again as the same value after 60 s, three times.
- The seam is unchanged: `write_current` and `write_phases` are still called
only from `ManualWriter`; a cut never selects phases.
## Choices the rulings left open
- **A lowering on its way** (`CUT_SENT_S`, 2 s) counts as Solar's own for
grading, once per value (PM Q1): a re-send of the same value, a retry
included, gets no new grace; after it, not read back is not cut.
- **While the 15 s wait runs** the cap is the power Solar gives the car then
(C4: no raise while due), held in watts and turned into amps with the
phases Solar writes on (PM R1).
- **A cut due during Solar's own phase change ends the change** at its 0 A,
at once (PM R1, C12): no select after it and no closing current. The
read-back may still show the old phases, so a cut is never sized there.
- **Under a cut the plan may lower** (formal C10), by its own 30 s rule.
- **The cut's own ramp-down.** The trusted car figure is capped by the new,
lower read-back, so for one corroboration window (60 s) after a cut the
charger took, the car's real power (fresh, not stuck, never above the current
before the cut) stands in for grading only. A car that does not come down is
graded as in Off after that window (T45).
- **Freshness (N9).** A cut is sized only from a projection that is not blind,
with the meter's own age within `stale_input_s` (`meter_max_age_s` on
`ha_signed`, whose age counts from the last change).
## Rollback
No new option, no store key, no migration. An older build ignores nothing it
does not know; it grades a Solar car as Manual again.