From 4a8939cd24138039b2232e859bbd1cd203fb7744 Mon Sep 17 00:00:00 2001 From: "Claude (dev)" Date: Sun, 6 Dec 2026 19:03:12 +0100 Subject: [PATCH] TARIFF-30: pin export during a trade (TARIFF-35), tight one-cycle bound, DECISIONS note Co-Authored-By: Claude --- .../TARIFF-30-per-unit-efficiency.md | 21 +++++++++++ goodwe_controller/test_tariff30.py | 35 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 goodwe_controller/DECISIONS/TARIFF-30-per-unit-efficiency.md diff --git a/goodwe_controller/DECISIONS/TARIFF-30-per-unit-efficiency.md b/goodwe_controller/DECISIONS/TARIFF-30-per-unit-efficiency.md new file mode 100644 index 0000000..c3d8cd6 --- /dev/null +++ b/goodwe_controller/DECISIONS/TARIFF-30-per-unit-efficiency.md @@ -0,0 +1,21 @@ +# TARIFF-30: per-unit round-trip efficiency + +`round_trip_eff` (optional, 0.5 to 1, per inverter entry) prices a unit's buy +leg at `price / eta`. Not set: nothing changes. The discharge split is +unchanged (the discharge order is TARIFF-34). + +## Known limit: export during a trade (TARIFF-35) + +While a grid charge is on, the buy is sized to the units whose own leg clears +(T1, ruled). The trade's claim fixes the site target, so a solar surplus above +that size is exported, where without an efficiency the trade is sized for every +unit and the other unit soaks it. PM ruling 2026-12-06: the sizing stays; +TARIFF-35 files the fix. The row `F4` in `test_tariff30.py` pins today's +behaviour so a fix shows up. + +## The wind-down hold + +A unit whose leg failed is held at 0 W charge while the site trades, and for +the trade's tail: until the site target is 0 or above, until the meter exports +(the loop is then soaking a surplus, not finishing the trade), or 120 s. The +release is seen one 5 s cycle after the export starts. diff --git a/goodwe_controller/test_tariff30.py b/goodwe_controller/test_tariff30.py index 9ffd0c4..ad47de5 100644 --- a/goodwe_controller/test_tariff30.py +++ b/goodwe_controller/test_tariff30.py @@ -380,6 +380,35 @@ def _grid_export_wh(rows, house_steps, base_load, tick=5.0): return out +def _export_w(r, house_steps, base_load): + load = base_load + for s, w in house_steps: + if r["t"] >= s: + load = w + return max(0.0, -(load - sum(r["plant"].values()))) + + +@guarded("F4") +def _f4(): + # TARIFF-35 (known limit, PM ruling 2026-12-06): with a trade on A, a + # surplus above A's rating is exported, because the trade fixes the site + # target at the size ruled in T1 (5000 W). Base sizes it for both units. + # This row pins today's behaviour; a fix will turn it red and must update + # it. + steps = [(10.0, -7000.0)] + r1, _c1 = drive(ETA, dur=60.0, house=steps) + r0, _c0 = drive(NONE2, dur=60.0, house=steps) + last1, last0 = settled(r1), settled(r0) + check("F4 (TARIFF-35) a trade on A plus a 7000 W surplus: the trade stays " + "5000 W and about 2000 W is exported, B charges nothing", + last1["action"] == arbitrage.CHARGE and last1["power"] == -5000.0 + and 1500.0 < _export_w(last1, steps, 500.0) < 2500.0 + and last1["plant"][B[-1]] > -50.0) + check("F4 (TARIFF-35) base sizes the trade for both units and exports " + "less", _export_w(last0, steps, 500.0) + < _export_w(last1, steps, 500.0) - 500.0) + + @guarded("F1") def _f1(): # After a trade on A ends (A reads full), a surplus must be soaked by B as @@ -398,6 +427,12 @@ def _f1(): check(f"F1 a {tag} surplus after the trade ends: export {e1:.1f} Wh " f"against base {e0:.1f} Wh (the hold does not block the soak)", len(r1) > 20 and e1 <= e0 + 1.0) + if tag == "3000 W": + ex = [r["t"] for r in r1 if _export_w(r, steps, 500.0) > 50.0 + and r["t"] >= 20] + check("F1 export only before the first post-trade read: at most " + f"one 5 s cycle ({len(ex)} cycle(s)), under 1 Wh in the " + f"probe case ({e1:.2f} Wh)", len(ex) <= 1 and e1 < 1.0) late = [r for r in r1 if r["t"] >= 60] check(f"F1 {tag}: B takes the surplus within a minute of it, as on " f"base", any(r["plant"][B[-1]] < -1000.0 for r in late)