diff --git a/goodwe_controller/app/carmode.py b/goodwe_controller/app/carmode.py index 653cc5c..f4cbcb5 100644 --- a/goodwe_controller/app/carmode.py +++ b/goodwe_controller/app/carmode.py @@ -160,6 +160,7 @@ class ManualWriter: self.fails, self.fail_at, self.gave_up = 0, None, False self.phase_fails, self.phases_gave_up = 0, False self.attempted_a = self.prior_a = None + self._late = None # EV-52: that request is not current now # ------------------------------------------------------------------ step async def step(self, drv, r, *, mode, want_a, want_phases, rev, clamp, @@ -194,6 +195,7 @@ class ManualWriter: return self.would = None if mode != MANUAL: + self._late = None # EV-52: another mode: that try is history return if clamp is None or clamp < CH.MIN_A: return @@ -1059,6 +1061,7 @@ class SolarWriter(ManualWriter): def _leave(self) -> None: """Solar is no longer the mode and owes nothing.""" self.engaged, self.seq, self.would = False, None, None + self._late = None # EV-52: no late accept after leaving self.start_owed = False self.out, self.fault = False, None self.restart = True diff --git a/goodwe_controller/test_ev52.py b/goodwe_controller/test_ev52.py index f89b438..ced9874 100644 --- a/goodwe_controller/test_ev52.py +++ b/goodwe_controller/test_ev52.py @@ -613,6 +613,44 @@ check(f"T23 Manual (Q2): three tries not taken give the existing Manual " len(mid) == 1 and mid[0].endswith("CHARGER_REFUSED.") and end[1:] == ["Car: set from 10 A to 6 A on 1 phase (Manual)."]) + +async def stale(shape): + """Review round 2: a refused Manual try is not a request any more once + the user changed something or another mode ran. Another source then + shows the same value; Manual's adopt must log nothing.""" + w = carmode.ManualWriter() + w.boot = False + drv, tr = Drv(ok=False), tracker() + + async def step(a, now, mode=carmode.MANUAL, rev=1): + await w.step(drv, reading(state="C", allowed_a=a, setpoint_a=a, + phases_allowed=1), mode=mode, + want_a=6.0, want_phases=1, rev=rev, clamp=16.0, now=now, + tracker=tr, writing=True, status="charging") + n0 = LOG.mark() + await step(10.0, 100.0) # refused + if shape == "solar": # the user picks Solar, then Manual + w.user_changed() + await step(10.0, 200.0, mode=carmode.SOLAR, rev=2) + await step(6.0, 300.0, mode=carmode.SOLAR, rev=2) # Solar's own 6 A + w.user_changed() + await step(6.0, 500.0, rev=3) + elif shape == "off": # Off, the wallbox app sets 6 A + await step(10.0, 150.0, mode=carmode.OFF) + await step(6.0, 400.0, mode=carmode.OFF) + await step(6.0, 500.0) + else: # the user changed the value + w.user_changed() + await step(6.0, 500.0, rev=2) + return [m for lv, m, _x in LOG.rec[n0:] + if lv != "DEBUG" and m.startswith(SETP)] + + +for shape in ("solar", "off", "user"): + check(f"T23 Manual (review round 2, N2) [{shape}]: a refused try is not " + f"logged later when the same value comes from another source", + go(stale(shape)) == []) + # T33: shutdown, the charger refuses all 3 release tries.