EV-28: never select the phases while the car still draws
Stage zero counted mode3 B as quiet whatever the power and selected at the 20 s timeout under load. A power reading now decides (under 100 W); mode3 (not C, not D) only without one. Still drawing at 20 s: no select, the current comes back at once, one failed try, next try PHASE_GAP_S later. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -15,8 +15,9 @@ THE RULES, each tested in test_ev04.py:
|
||||
reports, the entity's own range)`. The driver refuses anything above it; this
|
||||
module never asks for more.
|
||||
* Phases change only through the SAFE SEQUENCE: 0 A, wait until the charger
|
||||
reports under `QUIET_W` or mode3 leaves C (at most `ZERO_WAIT_S`), select the
|
||||
phases, wait `SETTLE_S`, write the current again. At most one switch per
|
||||
reports under `QUIET_W` (mode3 leaving C only without a power reading; at
|
||||
most `ZERO_WAIT_S`, then the current comes back and it counts as a failed
|
||||
try), select the phases, wait `SETTLE_S`, write the current again. At most one switch per
|
||||
`PHASE_GAP_S`. A sequence that has begun is always finished, because it
|
||||
leaves the car at 0 A otherwise.
|
||||
* A read-back that differs from the add-on's own last write for `WRITER_S` is
|
||||
@@ -333,11 +334,29 @@ class ManualWriter:
|
||||
"phase change, so the phases were not touched.")
|
||||
return
|
||||
if q["stage"] == "zero":
|
||||
quiet = ((r.power_w is not None and r.power_w < QUIET_W)
|
||||
or (r.state is not None and r.state != "C"))
|
||||
if not quiet and now - q["t0"] < ZERO_WAIT_S:
|
||||
return
|
||||
q["stage"] = "select"
|
||||
# A power reading decides; only without one does mode3 (not C,
|
||||
# not D) say the car is quiet. Still drawing at the timeout: no
|
||||
# select, the current comes back (EV-28).
|
||||
if r.power_w is not None:
|
||||
quiet = r.power_w < QUIET_W
|
||||
else:
|
||||
quiet = r.state is not None and r.state not in ("C", "D")
|
||||
if not quiet:
|
||||
if now - q["t0"] < ZERO_WAIT_S:
|
||||
return
|
||||
self.last_switch = now
|
||||
self.phase_fails += 1
|
||||
q["failed"] = True # EV-15: no grace for the alarm
|
||||
q["stage"], q["t1"] = "settle", now - SETTLE_S # restore now
|
||||
_LOG.warning("The car kept drawing, so the phases were not "
|
||||
"changed.")
|
||||
if self.phase_fails >= MAX_TRIES:
|
||||
self.phases_gave_up = True
|
||||
_LOG.warning("The charger did not take the phases, so the "
|
||||
"add-on stops trying until you change "
|
||||
"something: CHARGER_PHASES.")
|
||||
else:
|
||||
q["stage"] = "select"
|
||||
if q["stage"] == "select":
|
||||
ok = await drv.write_phases(q["n"])
|
||||
self._stamp(now)
|
||||
|
||||
Reference in New Issue
Block a user