EV-20 review round 1: no 1-phase current on 3 phases after a select; rows for mE, mF, mC
checks / unit (pull_request) Successful in 32m26s
infra-pin / fresh (pull_request) Successful in 2s

After its own phase select (taken, or with a late read-back), Solar ends the
sequence with the lower of the currents for the new phases and the phases the
charger reports, and keeps the plan on them; the old phases' current comes
back only when no select went out (EV-28's cap). Rows: T19/T33 settle write
refused or ignored once and select confirmed late; an exit after a given-up
write; shutdown in Off with the 0 A owed; Stop with a refused 0 A and another
writer. NoCharger.write_current takes took_s; ev_mode_start text names C1;
NL solar_hold wording.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w
This commit is contained in:
Claude
2026-11-23 00:34:24 +01:00
parent e0138a2ae5
commit 9c82bc816a
9 changed files with 114 additions and 14 deletions
+1 -1
View File
@@ -256,7 +256,7 @@ The label and description each setting shows on the Configuration tab, in tab or
| Car charger | Charger limit (A) | `ev_max_a` | The most current the charger may ever be asked for. Never above what the charger reports. Lower it for a weaker fuse or cable. |
| Car charger | Phases | `ev_phases` | How many phases the charger may use: 1, 3, or 1 and 3 (auto). |
| Car charger | Batteries help with the peak | `ev_batt_cover` | While the car charges. On: the batteries cover it down to the peak reserve. Off: the peak guard leaves the car out, so the car alone can set the peak. |
| Car charger | Mode after a restart | `ev_mode_start` | Keep the last mode, or start in Off. A restart in Solar sets the charger to 0 A first, other modes leave its current. |
| Car charger | Mode after a restart | `ev_mode_start` | Keep the last mode, or start in Off. A restart sets 0 A first in Solar, and in Off when a 0 A was pending. |
| Car charger | Sun kept back (W) | `ev_margin_w` | Solar: this much spare sun is never given to the car. |
| Car charger | Start after (minutes) | `ev_start_min` | Solar: the car starts after this long with enough spare sun. |
| Car charger | Pause after (minutes) | `ev_pause_min` | Solar: with too little sun the car holds 6 A this long, then pauses. |
+27 -9
View File
@@ -895,14 +895,23 @@ class SolarWriter(ManualWriter):
and sun is not None
and now - before[3] >= sun.pause_s)
def _seq_want(self, clamp):
"""The current that ends a phase change: for the new phases, or for
the old ones when the select did not happen."""
def _seq_want(self, clamp, n_reported):
"""The current that ends a phase change. No select went out (EV-28's
cap): the old current, on the old phases. A select went out, taken
or not (its read-back may be late): the lower of the current for the
new phases and for the phases the charger reports, so nothing meant
for 1 phase is ever written on 3 (review round 1, Major 1)."""
def want(q):
before = self.plan._before
if q.get("failed") and before is not None:
if q.get("failed") and not q.get("sel") and before is not None:
return before[0] if before[0] >= CH.MIN_A else CH.MIN_A
return self.amps_out(clamp) or CH.MIN_A
a = self.amps_out(clamp) or CH.MIN_A
tgt = self.plan.target_w
for n in (q.get("n"), n_reported):
b = amps_for(tgt, n, clamp) if n in (1, 3) else None
if b is not None:
a = min(a, max(b, CH.MIN_A))
return a
return want
async def _begin_solar(self, drv, r, cur, n, now, tracker) -> None:
@@ -1059,12 +1068,21 @@ class SolarWriter(ManualWriter):
self.plan.end_switch(False)
self.plan.pause()
return
n_log = len(self.log)
await self._advance(drv, r, cur, now, tracker,
self._seq_want(clamp), clamp, None)
self._seq_want(clamp, r.phases_allowed),
clamp, None)
if any(x[0] == "phases" for x in self.log[n_log:]):
q["sel"] = True # a select went out, taken or not
if self.seq is None:
# Done when the phases were selected and the current is back;
# otherwise the plan returns to its old phases.
self.plan.end_switch(not q.get("failed"))
# Back on the old phases only when no select went out; after
# one the plan keeps the current it wrote (the lower one) and
# takes the phases the charger reports from the next cycle.
done = not q.get("failed") or bool(q.get("sel"))
if done and q.get("sel") and self.sent_a is not None \
and self.sent_a >= CH.MIN_A:
self.plan.a = min(self.plan.a, self.sent_a)
self.plan.end_switch(done)
return
self._plan_step(sun, now, clamp, n_now, gap)
want = self.amps_out(clamp)
+1 -1
View File
@@ -618,7 +618,7 @@ class UnavailableCharger(ChargerDriver):
async def read(self) -> ChargerReading:
return ChargerReading(why=self.why)
async def write_current(self, a):
async def write_current(self, a, took_s=TOOK_S):
return False
async def write_phases(self, n):
+1 -1
View File
@@ -291,7 +291,7 @@
"solar_batt": "Eerst de batterijen. De auto krijgt de {kw} zon die ze niet opnemen.",
"solar_car": "Eerst de auto: die neemt {kw} zonne-overschot. De batterijen krijgen de rest.",
"solar_paused": "Te weinig zonne-overschot voor 6 A. De auto start na {s} minuten genoeg zon.",
"solar_hold": "Te weinig zonne-overschot, dus de auto houdt 6 A. Ze pauzeert na {s} minuten.",
"solar_hold": "Te weinig zonne-overschot, dus de auto houdt 6 A. Hij pauzeert na {s} minuten.",
"solar_start": "Er is nu genoeg zonne-overschot. De auto start na {s} minuten daarvan.",
"solar_unknown": "Het zonne-overschot is nu niet te meten. De auto pauzeert als dit duurt.",
"solar_would": "Schaduwmodus: de add-on zou de auto gepauzeerd houden.",
+42
View File
@@ -686,6 +686,48 @@ for pmin, back in ((10, 6.0), (5, 0.0)):
and (nth(w19f, 1)[1] == 6.0 if back else len(w19f) == 1)
and not [a for t, a in w19f if a > 6.0])
nevers(r19f, f"T19 (failed, {pmin} min)")
# Review round 1, Major 1: Solar's own 1 -> 3 change (the T7 shape) where the
# select went out but (i) the settle current write is refused once, or (ii)
# the select's read-back comes later than 10 s. Every current written after the
# select is floor(car_w / (230 x the phases the charger reports)): 10 A, never
# the 1-phase 16 A on 3 phases.
class LateSel(SimCharger):
"""The phases select shows in the read-back 12 s late (HA took it)."""
def request_phases(self, n):
keep, self.lag_s = self.lag_s, 12.0
try:
return super().request_phases(n)
finally:
self.lag_s = keep
r7b = S.drive(const(900.0), const(7900.0), dur=500, first="car",
socs={"a": 71.0, "b": 100.0})
ts7 = [x[0] for x in r7b["sim"].log if x[1] == "current"
and x[2] not in (0.0, 16.0)]
for how, sim_ in (("settle write refused once",
TSim(setpoint_a=0, windows=[(nth(ts7, 0) - 1,
nth(ts7, 0) + 1, "error")])),
("settle write ignored once",
TSim(setpoint_a=0, windows=[(nth(ts7, 0) - 1,
nth(ts7, 0) + 2, "ignore")])),
("select confirmed late", LateSel(setpoint_a=0))):
rm1 = S.drive(const(900.0), const(7900.0), dur=600, first="car",
socs={"a": 71.0, "b": 100.0}, sim=sim_)
over = [(x["t"], x["sp"]) for x in rm1["trace"]
if x["ph"] == 3 and x["sp"] > 10.0]
after = [a for t, e, a in rm1["plant"].sets
if e == SET and t > 290.0]
check(f"T19/T33 [{how}]: after the select every current is 10 A for 3 "
f"phases, never 1-phase 16 A on 3 ({len(over)} s over 10 A on 3: "
f"{over[:3]}; currents tried after 290 s {after})",
present(nth(ts7, 0)) and not over and 16.0 not in after
and rm1["sim"].phases_allowed == 3
and rm1["sim"].setpoint_a == 10.0)
nevers(rm1, f"T19/T33 [{how}]")
r19a = std(1800, sun=const(600.0 + 6900.0), opts={"ev_phases": "1"})
check(f"T19: fixed 1 with 6.9 kW for 30 min: no select, 16 A "
f"({cur_writes(r19a)})", selects(r19a) == []
+28
View File
@@ -551,6 +551,34 @@ for name, (t0, ev, opts) in PATHS.items():
and "charger_refused" in [x["id"] for x in blk.get("rows", [])]
and "paused" not in blk.get("b", {}).get("why", "paused"))
# Review round 1, Major 2 (mutant mE): an exit after a given-up non-zero write.
# Solar at 10 A; 13 A refused at 200, 260 and 320 s (given up); Off at 340 s:
# its 0 A has its own tries and goes out at once (N9).
simE = TSim(setpoint_a=0, windows=[(195.0, 330.0, "error")])
rE = std(600, sim=simE, sun=step_fn((200, 3600.0), base=2900.0),
events={340: act("car_mode", "off")})
aE = attempts(rE)
eo = [(t, v) for t, v in aE if t >= 340]
check(f"T36 [exit after a given-up write]: 13 A refused three times, then "
f"Off: the 0 A at once (340 s) and the charger at 0 A ({aE})",
[v for t, v in aE if 195 <= t < 340] == [13.0, 13.0, 13.0]
and present(nth(eo, 0)) and nth(eo, 0)[1] == 0.0
and nth(eo, 0)[0] <= 342 and simE.setpoint_a == 0.0)
# Review round 1, Major 4 (mutant mC): shutdown in Off while the exit 0 A is
# still owed: tried before the inverters' 0 W (E9, D3, N9).
simC = TSim(setpoint_a=0, windows=[(299.0, 1e9, "error")])
rC = std(330, sim=simC, events={300: act("car_mode", "off")},
finale=_shutdown)
oC = sets_order(rC)
zC = [i for i, (t, e, v) in enumerate(oC) if e == SET and v == 0.0
and t >= 329]
iC = [i for i, (t, e, v) in enumerate(oC)
if e.startswith("number.sp_") and v == 0.0 and t >= 329]
check(f"T23/T36 [shutdown in Off, the 0 A still owed]: tried (3 times) "
f"before the inverters' 0 W ({[x for x in oC if x[0] >= 329][:6]})",
len(zC) == 3 and present(nth(iC, 0)) and nth(zC, 0) < nth(iC, 0))
# T37: shutdown while a start write waits for its read-back.
+12
View File
@@ -119,6 +119,18 @@ for name, fn in EXITS.items():
not [x for x in attempts(rr) if x[0] >= 600]
and rr["sim"].setpoint_a == 16.0)
# Review round 1, Major 3 (mutant mF): Solar watches another writer while it
# does not write. Stop at 300 s (shadow_mode off), its 0 A refused 299-305 s;
# another writer sets 16 A at 310 s: nothing written over it (N10, N16).
simF = TSim(setpoint_a=0, windows=[(299.0, 305.0, "error")])
rF = std(600, sim=simF, opts={"shadow_mode": "off"},
events={300: lambda p, c: setattr(c, "auto", False),
310: lambda p, c: p.ch.set_current(16)})
lateF = [(t, v) for t, v in attempts(rF) if t >= 310]
check(f"T40/T42 [Stop, its 0 A refused, another writer]: nothing written "
f"over the 16 A, which stands ({attempts(rF)})",
not lateF and simF.setpoint_a == 16.0 and rF["c"].car_solar.hold)
# T41: the user changes Manual's values while Solar holds.
r41 = std(1000, sun=const(600.0 + 2070.0),
events={600: lambda p, c: p.ch.set_current(16),
+1 -1
View File
@@ -300,7 +300,7 @@ configuration:
description: "While the car charges. On: the batteries cover it down to the peak reserve. Off: the peak guard leaves the car out, so the car alone can set the peak."
ev_mode_start:
name: "Car charger · Mode after a restart"
description: "Keep the last mode, or start in Off. A restart in Solar sets the charger to 0 A first, other modes leave its current."
description: "Keep the last mode, or start in Off. A restart sets 0 A first in Solar, and in Off when a 0 A was pending."
ev_margin_w:
name: "Car charger · Sun kept back (W)"
description: "Solar: this much spare sun is never given to the car."
+1 -1
View File
@@ -281,7 +281,7 @@ configuration:
description: "Terwijl de auto laadt. Aan: de batterijen dekken ze tot de piekreserve. Uit: de piekbewaking laat de auto buiten beschouwing, dus de auto alleen kan de piek bepalen."
ev_mode_start:
name: "Laadpaal · Modus na een herstart"
description: "De laatste modus houden, of starten in Uit. Een herstart in Zon zet de laadpaal eerst op 0 A, andere modi laten haar stroom."
description: "De laatste modus houden, of starten in Uit. Een herstart zet eerst 0 A in Zon, en in Uit als een 0 A openstond."
ev_margin_w:
name: "Laadpaal · Zon achtergehouden (W)"
description: "Zon: zoveel zonne-overschot krijgt de auto nooit."