EV-04: car Manual mode, never throttled for the peak, no false guard alarms #257

Merged
admin merged 4 commits from EV-04 into release/1.0 2026-11-16 09:21:05 +01:00
Owner

EV-04: the car's Manual mode (first card that writes to a charger).

  • Off and Manual as runtime state; current (6 A to the clamp) and phases (1/3) written once per change, read back in 10 s, clamped (a value above the clamp is never sent), phases only through the safe sequence, one switch per 10 minutes.
  • Shadow mode and a stopped control write nothing. Another writer: grey row, no write over it.
  • The car's fresh power goes to the peak guard's alarm path: no false "Load too high" / "Battery stopped limiting the peak"; one grey notice per session. A stale or stuck car figure never hides a house overload.
  • Options ev_batt_cover, ev_mode_start; peak line "set by the car"; HA entities select.goodwe_car_mode, number.goodwe_car_current, select.goodwe_car_phases.
  • Sim writes, DOCS, CHANGELOG, DECISIONS/EV-04-manual-mode.md, test_ev04.py.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Bdqr7PiaHcBnzPituu2yTC

EV-04: the car's Manual mode (first card that writes to a charger). - Off and Manual as runtime state; current (6 A to the clamp) and phases (1/3) written once per change, read back in 10 s, clamped (a value above the clamp is never sent), phases only through the safe sequence, one switch per 10 minutes. - Shadow mode and a stopped control write nothing. Another writer: grey row, no write over it. - The car's fresh power goes to the peak guard's alarm path: no false "Load too high" / "Battery stopped limiting the peak"; one grey notice per session. A stale or stuck car figure never hides a house overload. - Options `ev_batt_cover`, `ev_mode_start`; peak line "set by the car"; HA entities select.goodwe_car_mode, number.goodwe_car_current, select.goodwe_car_phases. - Sim writes, DOCS, CHANGELOG, DECISIONS/EV-04-manual-mode.md, test_ev04.py. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Bdqr7PiaHcBnzPituu2yTC
admin added 1 commit 2026-11-16 05:24:44 +01:00
EV-04: car Manual mode, never throttled for the peak, no false guard alarms
checks / unit (pull_request) Successful in 21m48s
infra-pin / fresh (pull_request) Successful in 2s
0c92239a63
Off and Manual (runtime state, Home and Home Assistant): the current (6 A to
the clamp) and the phases (1 or 3) are written once per user change through
the safe phase sequence, read back within 10 s, clamped to
min(ev_max_a, station limit, entity range). Shadow mode gates the writes.
The car's fresh power goes to the peak guard's alarm path: no false "Load too
high" or "Battery stopped limiting the peak", one grey notice per session.
ev_batt_cover and ev_mode_start options, peak line "set by the car", HA
entities, sim writes, DOCS, CHANGELOG, test_ev04.py.

Co-Authored-By: Claude <noreply@anthropic.com>
Author
Owner

EV-04 review (full tier): changes requested

Head reviewed: 0c92239a63b9116f1ea00191407e9303c1e0b692. release/1.0 is b656091. CI run 1698 checks / unit (pull_request) is green.
The structure is sound: one write seam, a clamp in the driver, Off writes nothing, and the alarm path uses only trusted figures. But a probe found 3 Medium behaviour bugs, all in the phase sequence and the stuck-reading rule, plus 1 Medium on the named hole. These go back to the dev. Not merged.

Probe: scratch/EV-04/review/probe.py. It uses the test_ev04 harness in goodwe-addon-checks:1 with --network none.

Medium (back to the dev)

M1. A phase change can leave the car at 0 A for good, with a false "Something else changed the charger" row. app/carmode.py:263-274

  • In production the writer task runs alongside the cycles. It can finish (0 A confirmed) after a cycle has read the charger but before that cycle's car_kick().
  • The next step() then sees the old read-back (for example 10 A) while stage == "zero". _advance treats this as another writer raising the current. It drops the sequence, sets hold, and clears last_a.
  • The result: the car stays at 0 A, the info row says another writer did it, and nothing is written until the user changes something.
  • Probe A runs the cycle in the order read -> task finishes -> kick. The writes are [('current', 0.0)] only. The read-back is still 0 A after 600 s, and the charger_other row is shown. Probe A2, with a 3 s read-back lag, gives the same result.
  • test_ev04's World.step always waits for the task before the next read, so it can never show this.
  • Fix (dev's choice): only judge "raised" on a reading newer than the confirmed 0 A, for example a reading timestamp after seq["t0"], or the raise must stand for a few seconds. Then add a test that runs the read -> settle -> cycle order.

M2. A phase select the charger never takes pauses the car every 10 minutes, forever, with no row. app/carmode.py:281-286, 183-189

  • The result of write_phases is ignored. A successful current write afterwards resets fails and rev_applied, so after PHASE_GAP_S a new sequence starts.
  • Probe B: HA accepts the select but the charger never moves. Over 1 h that gave 7 selects, 7 pauses at 0 A, gave_up False and no row.
  • Fix: count failed selects as failed tries (3, then give up with the amber row, as for the current) and add a test.

M3. Off, shadow mode or a stopped control in the middle of a sequence still selects the phases. app/carmode.py:147-149

  • Once seq is set, _advance runs whatever mode and writing say. Probe C turns shadow on mid-sequence and gets [('phases', 3), ('current', 10.0)]. Probe C2, choosing Off mid-sequence (the rollback in the cut-over steps), gets the same.
  • "Not at 0 A" is right, but the new contactor switch is not needed for that.
  • Fix: when writing is False or the mode is no longer Manual, and the phases were not yet selected, undo the way abandon() does (give back prev, no select). Only a sequence whose select has already gone out writes its last current. Change the fuzz exemption ("and not seq") to match, and add a test.

M4. The restore on shutdown can exceed the clamp, which leaves the car at 0 A and logs a false software fault. app/carmode.py:252-259

  • abandon() writes prev, the read-back before the sequence. That value may have been set by another writer, or the station limit may have dropped since.
  • Probe D: ev_max_a 10, read-back 16 (set by another writer), the user picks 3 phases, then shutdown. The driver refuses 16 A (CHARGER_CLAMP at ERROR, clamp_faults [(16.0, 10.0)]) and the read-back stays at 0 A.
  • Fix: restore min(prev, clamp) and add a test.

M5 (the named hole). The stuck-reading rule misses nearly every real freeze, and the read-back does not bound it. app/chargers.py:698-743

  • The rule arms only on our own writes, and Manual writes once per user change. Once the reading moves after that write, the rule is disarmed until the next write.
  • So a power sensor that freezes at any time later in a session is never caught, not only one frozen from the start.
  • The read-back bound is 16 A x 253 V x 3 = 12.1 kW, which is the car's full power, so it limits nothing.
  • Probe E: Manual at 16 A on 3 phases is already in place (no write). The sensor freezes at 11 040 W and the car then really stops. After 900 s car_w_trusted is still 11040.0 and stuck is False. A real house overload of up to about 11 kW would then show a grey "Car over the peak limit" note instead of SAFETY-81/24/87.
  • What limits the harm: the guard's claim, floor and commands are unchanged, so control is safe and only the alarm text is wrong. Most HA integrations mark entities unavailable rather than freezing them, and that path is covered.
  • Against that: the card's acceptance asks that "a stuck charger reading ... must not hide a house overload".
  • Suggested fix (cheap, same shape as SAFETY-37, needs no write): for the alarm path, trust car_w only while the charger's energy meter moves at a rate consistent with it (at 1 kW or more, the meter must advance within 60 s), and only while mode3 is C. Test: freeze power only, and freeze everything.

Low (fold into the same round)

  • L1. test_ev04.py:736: the fuzz's "another writer" branch (elif r < 0.103) can never run, because r < 0.105 above it catches that range. The fuzz claims other writers but never makes any. Reorder the branches.
  • L2. app/ui_text/en.json:543-544: "Something else changes the charger" (Off) and "Something else changed the charger" (Manual) are two wordings for one thing. Use one.
  • L3. DOCS.md:3334 and en.json:328 manual_nocover ("The batteries keep their charge"):
    • With ev_batt_cover off, only the guard leaves the car out. The zero-grid loop still discharges the batteries for the car, and a grid charge of the batteries uses the room under the aim, so the period can reach the peak limit plus the car.
    • DOCS should say that in one plain sentence, and manual_nocover should not promise "keep their charge".
    • The behaviour matches the design wording ("goes over by the car alone") and is bounded by the aim. It is not a safety issue.

Checks that passed

  1. Write paths: write_current has one caller (_write, used by step, _begin, _advance, abandon), and write_phases has one (_advance). release() is a no-op. MQTT and the page only change store state through handle_action, and retained commands are dropped. There is no other set_number or select_option on charger entities. Off writes nothing (EV-03's no-write test passes).
  2. Clamp: the driver refuses anything above min(ev_max_a, station, entity max). An unknown station limit is still bounded by ev_max_a, which is checked against the station limit at save and at start. M4 is the only path found that asks above it.
  3. The alarm path for stale figures: the EV-03 freshness rule (15 s) and a stuck figure after a write both fire the normal alarms (tests in section 9, plus the dev's mutant). car_avg_w >= excess means the house's own excess is never hidden by a fresh car figure.
  4. "Guard test on period averages" deviation: accepted. It matches design section 3's intent ("car_w >= projected excess" in the projection's own unit), it is the same as the instantaneous form for a steady car, and it does not drift late in the period.
  5. Text: EN and NL, short and plain, as in the screenshots (Car card at both moments, Settings, 360 px and desktop). There is one CHANGELOG line, and DOCS covers the cut-over and the never-two-writers warning. Only L2 and L3 above.
  6. Tests: test_ev04 and test_ev03 pass locally, as do safety81, safety87, safety126, mqtt, messages, ui_text and docs. Two mutants of my own both went red and were reverted:
    • drop the writing gate in step(): 3 red (fuzz, shadow, control stopped)
    • drop the station limit from clamp_a(): 1 red (clamp property)
  7. CI 1698 is green on 0c92239.

Not fixed by me: a behaviour finding is open, so the Lows go to the dev too, keeping one writer per round.

## EV-04 review (full tier): changes requested Head reviewed: `0c92239a63b9116f1ea00191407e9303c1e0b692`. `release/1.0` is `b656091`. CI run 1698 `checks / unit (pull_request)` is green. The structure is sound: one write seam, a clamp in the driver, Off writes nothing, and the alarm path uses only trusted figures. But a probe found 3 Medium behaviour bugs, all in the phase sequence and the stuck-reading rule, plus 1 Medium on the named hole. These go back to the dev. **Not merged.** Probe: `scratch/EV-04/review/probe.py`. It uses the test_ev04 harness in `goodwe-addon-checks:1` with `--network none`. ### Medium (back to the dev) **M1. A phase change can leave the car at 0 A for good, with a false "Something else changed the charger" row.** `app/carmode.py:263-274` - In production the writer task runs alongside the cycles. It can finish (0 A confirmed) after a cycle has read the charger but before that cycle's `car_kick()`. - The next `step()` then sees the old read-back (for example 10 A) while `stage == "zero"`. `_advance` treats this as another writer raising the current. It drops the sequence, sets `hold`, and clears `last_a`. - The result: the car stays at 0 A, the info row says another writer did it, and nothing is written until the user changes something. - Probe A runs the cycle in the order read -> task finishes -> kick. The writes are `[('current', 0.0)]` only. The read-back is still 0 A after 600 s, and the `charger_other` row is shown. Probe A2, with a 3 s read-back lag, gives the same result. - `test_ev04`'s `World.step` always waits for the task before the next read, so it can never show this. - Fix (dev's choice): only judge "raised" on a reading newer than the confirmed 0 A, for example a reading timestamp after `seq["t0"]`, or the raise must stand for a few seconds. Then add a test that runs the read -> settle -> cycle order. **M2. A phase select the charger never takes pauses the car every 10 minutes, forever, with no row.** `app/carmode.py:281-286`, `183-189` - The result of `write_phases` is ignored. A successful current write afterwards resets `fails` and `rev_applied`, so after `PHASE_GAP_S` a new sequence starts. - Probe B: HA accepts the select but the charger never moves. Over 1 h that gave 7 selects, 7 pauses at 0 A, `gave_up` False and no row. - Fix: count failed selects as failed tries (3, then give up with the amber row, as for the current) and add a test. **M3. Off, shadow mode or a stopped control in the middle of a sequence still selects the phases.** `app/carmode.py:147-149` - Once `seq` is set, `_advance` runs whatever `mode` and `writing` say. Probe C turns shadow on mid-sequence and gets `[('phases', 3), ('current', 10.0)]`. Probe C2, choosing Off mid-sequence (the rollback in the cut-over steps), gets the same. - "Not at 0 A" is right, but the new contactor switch is not needed for that. - Fix: when `writing` is False or the mode is no longer Manual, and the phases were not yet selected, undo the way `abandon()` does (give back `prev`, no select). Only a sequence whose select has already gone out writes its last current. Change the fuzz exemption ("and not seq") to match, and add a test. **M4. The restore on shutdown can exceed the clamp, which leaves the car at 0 A and logs a false software fault.** `app/carmode.py:252-259` - `abandon()` writes `prev`, the read-back before the sequence. That value may have been set by another writer, or the station limit may have dropped since. - Probe D: `ev_max_a` 10, read-back 16 (set by another writer), the user picks 3 phases, then shutdown. The driver refuses 16 A (`CHARGER_CLAMP` at ERROR, `clamp_faults [(16.0, 10.0)]`) and the read-back stays at 0 A. - Fix: restore `min(prev, clamp)` and add a test. **M5 (the named hole). The stuck-reading rule misses nearly every real freeze, and the read-back does not bound it.** `app/chargers.py:698-743` - The rule arms only on our own writes, and Manual writes once per user change. Once the reading moves after that write, the rule is disarmed until the next write. - So a power sensor that freezes at any time later in a session is never caught, not only one frozen from the start. - The read-back bound is 16 A x 253 V x 3 = 12.1 kW, which is the car's full power, so it limits nothing. - Probe E: Manual at 16 A on 3 phases is already in place (no write). The sensor freezes at 11 040 W and the car then really stops. After 900 s `car_w_trusted` is still 11040.0 and `stuck` is False. A real house overload of up to about 11 kW would then show a grey "Car over the peak limit" note instead of SAFETY-81/24/87. - What limits the harm: the guard's claim, floor and commands are unchanged, so control is safe and only the alarm text is wrong. Most HA integrations mark entities unavailable rather than freezing them, and that path is covered. - Against that: the card's acceptance asks that "a stuck charger reading ... must not hide a house overload". - Suggested fix (cheap, same shape as SAFETY-37, needs no write): for the alarm path, trust `car_w` only while the charger's energy meter moves at a rate consistent with it (at 1 kW or more, the meter must advance within 60 s), and only while mode3 is C. Test: freeze power only, and freeze everything. ### Low (fold into the same round) - L1. `test_ev04.py:736`: the fuzz's "another writer" branch (`elif r < 0.103`) can never run, because `r < 0.105` above it catches that range. The fuzz claims other writers but never makes any. Reorder the branches. - L2. `app/ui_text/en.json:543-544`: "Something else changes the charger" (Off) and "Something else changed the charger" (Manual) are two wordings for one thing. Use one. - L3. `DOCS.md:3334` and `en.json:328` `manual_nocover` ("The batteries keep their charge"): - With `ev_batt_cover` off, only the guard leaves the car out. The zero-grid loop still discharges the batteries for the car, and a grid charge of the batteries uses the room under the aim, so the period can reach the peak limit plus the car. - DOCS should say that in one plain sentence, and `manual_nocover` should not promise "keep their charge". - The behaviour matches the design wording ("goes over by the car alone") and is bounded by the aim. It is not a safety issue. ### Checks that passed 1. Write paths: `write_current` has one caller (`_write`, used by `step`, `_begin`, `_advance`, `abandon`), and `write_phases` has one (`_advance`). `release()` is a no-op. MQTT and the page only change store state through `handle_action`, and retained commands are dropped. There is no other `set_number` or `select_option` on charger entities. Off writes nothing (EV-03's no-write test passes). 2. Clamp: the driver refuses anything above `min(ev_max_a, station, entity max)`. An unknown station limit is still bounded by `ev_max_a`, which is checked against the station limit at save and at start. M4 is the only path found that asks above it. 3. The alarm path for stale figures: the EV-03 freshness rule (15 s) and a stuck figure after a write both fire the normal alarms (tests in section 9, plus the dev's mutant). `car_avg_w >= excess` means the house's own excess is never hidden by a fresh car figure. 4. "Guard test on period averages" deviation: accepted. It matches design section 3's intent ("car_w >= projected excess" in the projection's own unit), it is the same as the instantaneous form for a steady car, and it does not drift late in the period. 5. Text: EN and NL, short and plain, as in the screenshots (Car card at both moments, Settings, 360 px and desktop). There is one CHANGELOG line, and DOCS covers the cut-over and the never-two-writers warning. Only L2 and L3 above. 6. Tests: `test_ev04` and `test_ev03` pass locally, as do safety81, safety87, safety126, mqtt, messages, ui_text and docs. Two mutants of my own both went red and were reverted: - drop the `writing` gate in `step()`: 3 red (fuzz, shadow, control stopped) - drop the station limit from `clamp_a()`: 1 red (clamp property) 7. CI 1698 is green on 0c92239. Not fixed by me: a behaviour finding is open, so the Lows go to the dev too, keeping one writer per round.
admin added 1 commit 2026-11-16 06:51:19 +01:00
M1 the writer ignores a reading taken before its latest confirmed write.
M2 a refused phase select gives the current back and stops after 3 tries (amber row).
M3 Off, shadow mode or a control/safety stop before the select undoes the change.
M4 the restore on shutdown (and the undo) is clamped.
M5 the car's power reaches the alarm path only while the charger's energy meter agrees with it.
L1 fuzz other-writer branch reachable and shown to run. L2 one wording. L3 Batteries-help-off text.

Co-Authored-By: Claude <noreply@anthropic.com>
Author
Owner

EV-04 re-review, round 2 (full tier): changes requested

Head reviewed: 661a3b009a22eeabc419ef2441f3df400b80bfff. release/1.0 is b656091. CI run 1700 checks / unit (pull_request) is green (checked through the API).

M1-M5 and L1-L3 are fixed. My probe (scratch/EV-04/review/probe.py, log logs/probe_round2.txt) on the new head:

  • M1, the race: 0 A -> phases 3 -> 10 A. No hold and no false row, with a lag of 0 s and of 3 s.
  • M2: 3 selects in 1 h, then the amber row charger_phases.
  • M3: Off mid-sequence brings 10 A back with no phase switch.
  • M4: the car gets 10 A back, with no clamp fault.
  • M5: a frozen 11 kW figure is no longer trusted.

The dev's red-before log shows 19 checks red on 0c92239. Ignoring readings at or before our last confirmed write uses the same clock as obs_at (both freshness.monotonic). last_done only moves on our own writes, which are bounded, so a real other writer cannot be ignored forever.

Two new Medium findings go back to the dev. Not merged.

Medium

N1. With the shipped shadow_mode: auto, pressing Stop control during a phase change leaves the car at 0 A for as long as control is stopped. app/carmode.py:281

  • _undo gives nothing back in shadow mode, and "auto" means shadow is on whenever control is stopped.
  • Probe F (default config, Stop pressed after the 0 A step): no write afterwards. The read-back was 0 A and the power 0 W after 600 s.
  • The design's Manual column says "control stopped ... current stands". Here the add-on's own half-done 0 A stands instead.
  • The m3 "stop" test sets shadow_mode = "off" (test_ev04.py:787), which hides this.
  • Turning shadow on explicitly mid-sequence also leaves the car at 0 A (probe C).
  • Fix: the undo gives back the old current (clamped) in shadow mode too. It undoes the add-on's own write already in flight, as abandon() does on shutdown. Then test m3 "stop" with the shipped auto, and "shadow".

N2. The M5 rule passes any frozen figure up to about 1.8 kW, and DECISIONS says "about 0.5 kW". app/chargers.py:83-85, DECISIONS/EV-04-manual-mode.md:80

  • The threshold is 0.5 x P x 60/3600 - 15 Wh. That is 0 or less for P up to 1.8 kW, so a meter that never moves still counts as corroborated.
  • Probe G, everything frozen and the car really stopped, checked 300 s later:
    • 6 A on 1 phase (1380 W): still trusted.
    • 8 A (1840 W), 10 A and 16 A on 1 phase: not trusted (correct).
  • 6 A on 1 phase is the lowest and a common Manual setting.
  • The harm is limited to the alarm text (≤ 1.8 kW of house excess shown as "Car over the peak limit"), but it is the rule's own stated claim.
  • Fix (dev's choice): have the threshold demand at least one meter step at the minimum charge. For example, a smaller slack with a longer window, or grow the window until the expected energy is 40 Wh or more. Correct the DECISIONS figure. Add a test: 6 A on 1 phase, frozen, not trusted.

Low (same round)

  • L4. app/carmode.py:336: after a failed select the current comes back at once (t1 = now - SETTLE_S). A select that HA accepted but whose read-back was just late could still switch the contactors with the car drawing again. Keep the 10 s settle on this path too. It costs nothing.

Judged and accepted

  • M5 (a), the first minute is believed. Only a real return to mode3 C can reopen the window, and a fully frozen reading cannot. A power-only freeze on a car that pauses and resumes gets at most one believed minute per resume. Accepted.
  • M5 ratio for partial freezes. With power frozen at 11 kW and the car really drawing 5 kW or more, the figure still passes. The hidden excess is then bounded by about half the figure. Accepted.
  • M5 (b), no energy entity means never suppress. This errs on the safe side (the normal alarms fire), and DOCS says it plainly. The Alfen always has a meter. Accepted.
  • Control is unchanged. Claim, floor and commands are untouched: the diff changes only the writer, the tracker and car_writing, and the latch gate is read-only.
  • L1-L3 are fixed.
    • L1: the fuzz now makes other writers, and runs half its sites in the racing cycle order.
    • L2: one wording, EN and NL.
    • L3: the manual_nocover text and DOCS are honest now.
    • The new strings (charger_phases, its row) are EN + NL, short and plain.
  • Tests. test_ev04 and test_ev03 pass. My mutants were reverted, and the clone is clean:
    • no clamp in _restore_a: M4 red
    • corroborated always True: 6 M5 checks red
## EV-04 re-review, round 2 (full tier): changes requested Head reviewed: `661a3b009a22eeabc419ef2441f3df400b80bfff`. `release/1.0` is `b656091`. CI run 1700 `checks / unit (pull_request)` is green (checked through the API). **M1-M5 and L1-L3 are fixed.** My probe (`scratch/EV-04/review/probe.py`, log `logs/probe_round2.txt`) on the new head: - M1, the race: 0 A -> phases 3 -> 10 A. No hold and no false row, with a lag of 0 s and of 3 s. - M2: 3 selects in 1 h, then the amber row `charger_phases`. - M3: Off mid-sequence brings 10 A back with no phase switch. - M4: the car gets 10 A back, with no clamp fault. - M5: a frozen 11 kW figure is no longer trusted. The dev's red-before log shows 19 checks red on 0c92239. Ignoring readings at or before our last confirmed write uses the same clock as `obs_at` (both `freshness.monotonic`). `last_done` only moves on our own writes, which are bounded, so a real other writer cannot be ignored forever. Two new Medium findings go back to the dev. **Not merged.** ### Medium **N1. With the shipped `shadow_mode: auto`, pressing Stop control during a phase change leaves the car at 0 A for as long as control is stopped.** `app/carmode.py:281` - `_undo` gives nothing back in shadow mode, and "auto" means shadow is on whenever control is stopped. - Probe F (default config, Stop pressed after the 0 A step): no write afterwards. The read-back was 0 A and the power 0 W after 600 s. - The design's Manual column says "control stopped ... current stands". Here the add-on's own half-done 0 A stands instead. - The m3 "stop" test sets `shadow_mode = "off"` (`test_ev04.py:787`), which hides this. - Turning shadow on explicitly mid-sequence also leaves the car at 0 A (probe C). - Fix: the undo gives back the old current (clamped) in shadow mode too. It undoes the add-on's own write already in flight, as `abandon()` does on shutdown. Then test m3 "stop" with the shipped `auto`, and "shadow". **N2. The M5 rule passes any frozen figure up to about 1.8 kW, and DECISIONS says "about 0.5 kW".** `app/chargers.py:83-85`, `DECISIONS/EV-04-manual-mode.md:80` - The threshold is `0.5 x P x 60/3600 - 15 Wh`. That is 0 or less for P up to 1.8 kW, so a meter that never moves still counts as corroborated. - Probe G, everything frozen and the car really stopped, checked 300 s later: - 6 A on 1 phase (1380 W): **still trusted**. - 8 A (1840 W), 10 A and 16 A on 1 phase: not trusted (correct). - 6 A on 1 phase is the lowest and a common Manual setting. - The harm is limited to the alarm text (≤ 1.8 kW of house excess shown as "Car over the peak limit"), but it is the rule's own stated claim. - Fix (dev's choice): have the threshold demand at least one meter step at the minimum charge. For example, a smaller slack with a longer window, or grow the window until the expected energy is 40 Wh or more. Correct the DECISIONS figure. Add a test: 6 A on 1 phase, frozen, not trusted. ### Low (same round) - **L4.** `app/carmode.py:336`: after a failed select the current comes back at once (`t1 = now - SETTLE_S`). A select that HA accepted but whose read-back was just late could still switch the contactors with the car drawing again. Keep the 10 s settle on this path too. It costs nothing. ### Judged and accepted - **M5 (a), the first minute is believed.** Only a real return to mode3 C can reopen the window, and a fully frozen reading cannot. A power-only freeze on a car that pauses and resumes gets at most one believed minute per resume. Accepted. - **M5 ratio for partial freezes.** With power frozen at 11 kW and the car really drawing 5 kW or more, the figure still passes. The hidden excess is then bounded by about half the figure. Accepted. - **M5 (b), no energy entity means never suppress.** This errs on the safe side (the normal alarms fire), and DOCS says it plainly. The Alfen always has a meter. Accepted. - **Control is unchanged.** Claim, floor and commands are untouched: the diff changes only the writer, the tracker and `car_writing`, and the latch gate is read-only. - **L1-L3 are fixed.** - L1: the fuzz now makes other writers, and runs half its sites in the racing cycle order. - L2: one wording, EN and NL. - L3: the `manual_nocover` text and DOCS are honest now. - The new strings (`charger_phases`, its row) are EN + NL, short and plain. - **Tests.** `test_ev04` and `test_ev03` pass. My mutants were reverted, and the clone is clean: - no clamp in `_restore_a`: M4 red - `corroborated` always True: 6 M5 checks red
admin added 1 commit 2026-11-16 07:59:18 +01:00
EV-04 round 3: undo restores the current in shadow mode too, energy rule catches a frozen 6 A figure, settle after a refused select
checks / unit (pull_request) Failing after 21m10s
infra-pin / fresh (pull_request) Successful in 1s
f31dcb62b6
N1 the undo gives the old current back (clamped) in shadow mode; DECISIONS records it as the one write shadow mode allows.
N2 the corroboration looks back to a stretch with at least 40 Wh expected (60 s at 2.4 kW and up, 104 s at 1.38 kW).
L4 the current comes back 10 s after the phase select returned, also when it was refused.

Co-Authored-By: Claude <noreply@anthropic.com>
admin added 1 commit 2026-11-16 08:22:18 +01:00
EV-04 round 3: guard the L4 test's reads for test_named_absence
checks / unit (pull_request) Successful in 21m33s
infra-pin / fresh (pull_request) Successful in 2s
6e6344eb02
Co-Authored-By: Claude <noreply@anthropic.com>
Author
Owner

EV-04 re-review, round 3 (full tier): right, merging

Head reviewed: 6e6344eb028a13f9fee5817706431d52a51e61a2. release/1.0 is b656091. CI run 1704 checks / unit (pull_request) is green and run 1705 infra-pin / fresh is green (checked through the API). Run 1702 failed on f31dcb6 and was fixed by 6e6344e, which only changes the test; there was no rerun.

N1 is fixed.

  • Probe F (shipped shadow_mode: auto, Stop control after the 0 A step): one write, current 10.0, and nothing after it. 10 A and 2.3 kW after 600 s.
  • Probe C (shadow turned on by hand): the same single restore.
  • The restore goes through _restore_a, so it is clamped (probe D: 16 A becomes 10 A, no fault). self.seq is cleared before the write, so it cannot repeat.
  • _undo runs only when seq exists, and only _begin sets seq, behind the writing gate. So a write can only come from a sequence we started while writing was allowed.
  • Probe H: with shadow on from the start ("on", and "auto" with control never started), Manual, two current changes, a phase change and a shutdown give no write at all (sent == []).
  • This matches the coordinator's decision in DECISIONS, "The one write shadow mode allows".

N2 is fixed.

  • Probe G: a figure frozen at 1380 W, 1840 W, 2300 W or 3680 W (everything frozen, the car really stopped) is no longer trusted after 300 s.
  • I checked the bound by hand. At 40 Wh the threshold is 0.5 x 40 - 15 = 5 Wh, so at least one 10 Wh meter step is needed. The stretch is the shortest that is ≥ 55 s and ≥ 40 Wh. So a frozen P is caught after about max(55-60 s, 40 Wh / P): 104 s at 1.38 kW, plus the 10 s hold. Below about 0.8 kW it is believed (40 Wh in the 180 s kept).
  • No false alarms on an honest charge. Probe I: 1 h each of 6 A on 1 phase (with a read-back lag of 0 s and 3 s), 7 A on 1 phase, 6 A on 3 phases and 16 A on 3 phases, with 10 Wh meter steps: the figure was never dropped. An honest 6 A charge gains about 40 Wh over the stretch and needs only 5 Wh. The dev's unit test also covers 5, 10 and 20 Wh steps.
  • Residual, for the TEST-23 rig test: this assumes HA updates the meter entity about as often as the power entity, as it does in the Alfen integration. If a real meter updated much more slowly than every 90 s or so, an honest low-power charge could be dropped and the normal alarms would show. That errs on the safe side.

L4 is fixed. The settle counts from the select's return (t1 = last_done), also after a refusal (the l4_late test: the current comes back 10 s after the select returned). Probe B: 3 refused selects in 1 h, then the amber row.

M1-M5 still hold (probes A, A2, D and E unchanged from round 2). Claim, floor and commands are untouched: the diff changes only carmode.py, chargers.py, DECISIONS and the test.

Tests.

  • test_ev04, test_ev03, test_named_absence, safety81, safety87, docs and messages all pass.
  • My mutants were both red and both reverted; the clone is clean:
    • CORR_MIN_WH = 0: the N2 frozen-1380 W check goes red.
    • no restore in shadow (_undo): 2 checks go red (M3 shadow, M3 stop).

Findings: none. Fixed myself: nothing (no Low found). Merging into release/1.0, pinned to 6e6344e.

## EV-04 re-review, round 3 (full tier): right, merging Head reviewed: `6e6344eb028a13f9fee5817706431d52a51e61a2`. `release/1.0` is `b656091`. CI run 1704 `checks / unit (pull_request)` is green and run 1705 `infra-pin / fresh` is green (checked through the API). Run 1702 failed on f31dcb6 and was fixed by 6e6344e, which only changes the test; there was no rerun. **N1 is fixed.** - Probe F (shipped `shadow_mode: auto`, Stop control after the 0 A step): one write, `current 10.0`, and nothing after it. 10 A and 2.3 kW after 600 s. - Probe C (shadow turned on by hand): the same single restore. - The restore goes through `_restore_a`, so it is clamped (probe D: 16 A becomes 10 A, no fault). `self.seq` is cleared before the write, so it cannot repeat. - `_undo` runs only when `seq` exists, and only `_begin` sets `seq`, behind the `writing` gate. So a write can only come from a sequence we started while writing was allowed. - Probe H: with shadow on from the start ("on", and "auto" with control never started), Manual, two current changes, a phase change and a shutdown give **no write at all** (`sent == []`). - This matches the coordinator's decision in DECISIONS, "The one write shadow mode allows". **N2 is fixed.** - Probe G: a figure frozen at 1380 W, 1840 W, 2300 W or 3680 W (everything frozen, the car really stopped) is no longer trusted after 300 s. - I checked the bound by hand. At 40 Wh the threshold is 0.5 x 40 - 15 = 5 Wh, so at least one 10 Wh meter step is needed. The stretch is the shortest that is ≥ 55 s and ≥ 40 Wh. So a frozen P is caught after about max(55-60 s, 40 Wh / P): 104 s at 1.38 kW, plus the 10 s hold. Below about 0.8 kW it is believed (40 Wh in the 180 s kept). - No false alarms on an honest charge. Probe I: 1 h each of 6 A on 1 phase (with a read-back lag of 0 s and 3 s), 7 A on 1 phase, 6 A on 3 phases and 16 A on 3 phases, with 10 Wh meter steps: **the figure was never dropped**. An honest 6 A charge gains about 40 Wh over the stretch and needs only 5 Wh. The dev's unit test also covers 5, 10 and 20 Wh steps. - Residual, for the TEST-23 rig test: this assumes HA updates the meter entity about as often as the power entity, as it does in the Alfen integration. If a real meter updated much more slowly than every 90 s or so, an honest low-power charge could be dropped and the normal alarms would show. That errs on the safe side. **L4 is fixed.** The settle counts from the select's return (`t1 = last_done`), also after a refusal (the `l4_late` test: the current comes back 10 s after the select returned). Probe B: 3 refused selects in 1 h, then the amber row. **M1-M5 still hold** (probes A, A2, D and E unchanged from round 2). Claim, floor and commands are untouched: the diff changes only `carmode.py`, `chargers.py`, DECISIONS and the test. **Tests.** - `test_ev04`, `test_ev03`, `test_named_absence`, safety81, safety87, docs and messages all pass. - My mutants were both red and both reverted; the clone is clean: - `CORR_MIN_WH = 0`: the N2 frozen-1380 W check goes red. - no restore in shadow (`_undo`): 2 checks go red (M3 shadow, M3 stop). Findings: none. Fixed myself: nothing (no Low found). Merging into `release/1.0`, pinned to 6e6344e.
admin merged commit 75ebe22a4d into release/1.0 2026-11-16 09:21:05 +01:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: admin/goodwe-addon#257