OPT-11 P3, owner option A: selling off, Leftover solar takes solar only
Owner decision 2026-09-29. Selling is off until it can be judged on the price
the grid pays: packmode.SELLING_ENABLED = False makes read() answer
sell=False whatever the store holds, pack_sell is refused ("Selling is off
for now."), and the page has no selling switch; the sell code stays. Until
the P4 forecast, only Cheap hours only charges from the grid
(packmode.GRID_CHARGE_MODES); Leftover solar holds and gives in the
expensive runs. Help, Today and plan lines, DOCS and DECISIONS follow.
Replay, 16 days: Solar first + Leftover solar 19.44 EUR net (P2 19.33).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,11 +19,13 @@ time. DECISIONS/OPT-11-battery-modes.md has the record.
|
||||
alone never trades.
|
||||
7. A run edge reseeds the loop (handover measured with and without).
|
||||
8. The site Why row: a limit that pushes power up does not "hold it back" (F2).
|
||||
9. The selling switch (`pack_sell`).
|
||||
9. Selling is off (owner, 2026-09-29): `pack_sell` refused, read as false.
|
||||
10. The Batteries screen: Why and Today lines from the roles and runs.
|
||||
11. Review additions: modes on ignore the site trade switch, a battery in
|
||||
maintenance takes no part, the headroom stop latches for the period.
|
||||
|
||||
12. Option A: no sale in a day; Leftover solar never grid-charges (P4).
|
||||
|
||||
Mutations (MUTATION.md, purged copies, graded over this file and the named
|
||||
tests) are listed in the pull request.
|
||||
"""
|
||||
@@ -272,7 +274,7 @@ for _ in range(20000):
|
||||
_bad.append(("range without 0", name, lo, hi))
|
||||
for name, role in tk.roles.items():
|
||||
p = by[name]
|
||||
if role == modetrade.CHARGE and (p.mode == packmode.SOLAR_FIRST
|
||||
if role == modetrade.CHARGE and (p.mode != packmode.CHEAP_HOURS
|
||||
or p.refused < 0 or not p.use
|
||||
or p.soc is None or p.soc >= 95.0):
|
||||
_bad.append(("bad charger", p))
|
||||
@@ -359,6 +361,11 @@ def run_day(variant, *, house_w=2600.0, start_h=0.75, hours=21.0,
|
||||
return rows, st, c
|
||||
|
||||
|
||||
# Selling is off (owner, 2026-09-29, option A). Its code is kept behind
|
||||
# packmode.SELLING_ENABLED, and these checks turn it on to hold that code to
|
||||
# its invariants; part 12 checks it is unreachable with the flag as shipped.
|
||||
_SELL_SHIPPED = packmode.SELLING_ENABLED
|
||||
packmode.SELLING_ENABLED = True
|
||||
ROWS, ST, _c4 = run_day("p3_ch_sell", soc0={"a": 60.0, "b": 30.0})
|
||||
charge = [r for r in ROWS if r["action"] == arbitrage.CHARGE]
|
||||
sell = [r for r in ROWS if r["action"] == arbitrage.DISCHARGE]
|
||||
@@ -455,6 +462,7 @@ print(f" from 24 %: sold {len(_sf)} cycles, B ends at "
|
||||
check("the sale stops at arbitrage_soc_floor and does not re-arm in the run",
|
||||
_sf and _after and all(r["action"] != arbitrage.DISCHARGE
|
||||
for r in _after))
|
||||
packmode.SELLING_ENABLED = _SELL_SHIPPED
|
||||
|
||||
# N=1: one Cheap hours battery.
|
||||
ROWS1, _, _ = run_day("p3_ch_sell", n=1, soc0={"a": 30.0},
|
||||
@@ -551,32 +559,24 @@ check("...and a trade the peak floor raised reads the same way",
|
||||
[Claim.set("arbitrage", P_ARBITRAGE, -1000.0)]) is True)
|
||||
|
||||
# ============================================================================ #
|
||||
print("\n9. the selling switch")
|
||||
print("\n9. the selling switch is off (owner decision 2026-09-29, option A)")
|
||||
_st = rp._Store()
|
||||
_st.data[unit_key(B, packmode.SELL_KEY)] = True # an old stored "on"
|
||||
_st.data[unit_key(B, packmode.MODE_KEY)] = packmode.CHEAP_HOURS
|
||||
_ctl = Controller(dict(rp.options(True, False)), rp.Hass(("a", "b"),
|
||||
lambda t: 0.0), _st, rp._Pub(), stop=asyncio.Event())
|
||||
_r1 = asyncio.run(_ctl.handle_action("pack_sell", unit=B, value=True))
|
||||
_bad9 = [asyncio.run(_ctl.handle_action("pack_sell", unit=B, value=v))
|
||||
for v in ("yes", 1, 0, None)]
|
||||
_bad9.append(asyncio.run(_ctl.handle_action("pack_sell", unit="x",
|
||||
value=True)))
|
||||
check("pack_sell stores true/false per battery, logs it, and returns it",
|
||||
_r1 == {"unit": B, "use": True, "mode": packmode.SOLAR_FIRST,
|
||||
"sell": True}
|
||||
_r9 = [asyncio.run(_ctl.handle_action("pack_sell", unit=B, value=v))
|
||||
for v in (True, False, "yes")]
|
||||
check("pack_sell is refused with the plain reason 'Selling is off for now.' "
|
||||
"and stores nothing",
|
||||
all(x == {"error": messages.pack_refused("sell_off")} for x in _r9)
|
||||
and _st.data[unit_key(B, packmode.SELL_KEY)] is True
|
||||
and any("selling switched on" in str(e) for e in _ctl.events))
|
||||
check("...anything else (1, 0, 'yes', None, an unknown battery) is refused "
|
||||
"with a plain reason and stores nothing",
|
||||
all(set(x) == {"error"} for x in _bad9)
|
||||
and _st.data[unit_key(B, packmode.SELL_KEY)] is True)
|
||||
check("...Solar first never sells, even with the switch on",
|
||||
packmode.read(_st.data, B).sell is True
|
||||
and packmode.read(_st.data, B).can_sell is False)
|
||||
_off_ctl = Controller(dict(rp.options(False, False)), rp.Hass(
|
||||
("a", "b"), lambda t: 0.0), rp._Store(), rp._Pub(), stop=asyncio.Event())
|
||||
check("...and with battery modes off it is refused like the others",
|
||||
"error" in asyncio.run(_off_ctl.handle_action("pack_sell", unit=B,
|
||||
value=True)))
|
||||
and not any("selling switched" in str(e) for e in _ctl.events))
|
||||
check("...a stored 'on' reads as false: no battery sells or can, whatever "
|
||||
"the store holds", packmode.SELLING_ENABLED is False
|
||||
and packmode.read(_st.data, B).sell is False
|
||||
and packmode.read(_st.data, B).can_sell is False
|
||||
and all(p.sell is False for p in _ctl._mode_packs()))
|
||||
|
||||
# ============================================================================ #
|
||||
print("\n10. the Batteries screen")
|
||||
@@ -587,11 +587,13 @@ check("every role's Why line has words in English and Dutch, and they differ",
|
||||
all(k in _en["home_words"]["why"] and k in _nl["home_words"]["why"]
|
||||
and _en["home_words"]["why"][k] != _nl["home_words"]["why"][k]
|
||||
for k in _keys))
|
||||
packmode.SELLING_ENABLED = True # the kept sell code, as in part 4
|
||||
_c10 = run_day("p3_ch_sell", start_h=18.0, hours=0.5,
|
||||
soc0={"a": 60.0, "b": 80.0})[2]
|
||||
_now10 = D0 + timedelta(hours=18, minutes=30)
|
||||
_plan = homeview.mode_runs(_c10, *homeview.local_day(_now10.astimezone(
|
||||
timezone.utc)), _now10.astimezone(timezone.utc), False)
|
||||
packmode.SELLING_ENABLED = _SELL_SHIPPED
|
||||
print(f" plan blocks for B at 18:30: "
|
||||
f"{[(r['from'], r['to'], r['kind'], r['what']) for r in _plan[0]]}")
|
||||
check("the plan draws B's expensive run, the sale inside it, and nothing "
|
||||
@@ -657,6 +659,60 @@ if _nm is not None and _cm2.mode_tick is not None \
|
||||
check("a charge the headroom stopped stays off for the rest of the period, "
|
||||
"even when the headroom comes back, and may start in the next one", _ok8)
|
||||
|
||||
# ============================================================================ #
|
||||
print("\n12. option A: no sale, and Leftover solar takes solar only (P4)")
|
||||
ROWS_A, _, _ = run_day("p3_ch_sell", soc0={"a": 60.0, "b": 30.0},
|
||||
choice={"a": (True, "solar_first", False),
|
||||
"b": (True, "cheap_hours", True)})
|
||||
print(f" Cheap hours B with a stored sell 'on': "
|
||||
f"{sum(r['action'] == arbitrage.CHARGE for r in ROWS_A)} charging, "
|
||||
f"{sum(r['action'] == arbitrage.DISCHARGE for r in ROWS_A)} selling")
|
||||
check("with selling on in the store, a whole day has no sale and no sell "
|
||||
"role, while Cheap hours only still charges from the grid",
|
||||
all(r["action"] != arbitrage.DISCHARGE for r in ROWS_A)
|
||||
and all(modetrade.SELL not in r["roles"].values() for r in ROWS_A)
|
||||
and any(r["action"] == arbitrage.CHARGE for r in ROWS_A))
|
||||
ROWS_L, _, _c12 = run_day("p3_ch_sell", soc0={"a": 60.0, "b": 30.0},
|
||||
choice={"a": (True, "solar_first", False),
|
||||
"b": (True, "leftover_solar", True)})
|
||||
_lh = [r for r in ROWS_L if r["roles"].get(B) == modetrade.HOLD]
|
||||
_lg = [r for r in ROWS_L if r["roles"].get(B) == modetrade.GIVE]
|
||||
print(f" Leftover solar B: {len(_lh)} holding, {len(_lg)} giving, "
|
||||
f"grid trades {sorted({str(r['action']) for r in ROWS_L})}")
|
||||
check("Leftover solar never charges from the grid before the forecast: no "
|
||||
"grid trade and no charge role all day, in the same cheap run",
|
||||
all(r["action"] is None for r in ROWS_L)
|
||||
and all(r["roles"].get(B) != modetrade.CHARGE for r in ROWS_L))
|
||||
check("...it still saves its power and gives it in the expensive hours",
|
||||
_lh and _lg and all(r["now"].astimezone(L).hour == 19 for r in _lg))
|
||||
_pk = [modetrade.Pack("x", True, m, False, 2500.0, 30.0, 10.0)
|
||||
for m in packmode.MODES]
|
||||
check("...only Cheap hours only is a grid charger (packmode.GRID_CHARGE_MODES)",
|
||||
[p.mode for p in modetrade.chargers(_pk, 95.0)]
|
||||
== [packmode.CHEAP_HOURS])
|
||||
_c12b = run_day("p3_ch_sell", start_h=0.75, hours=0.25,
|
||||
soc0={"a": 60.0, "b": 30.0},
|
||||
choice={"a": (True, "solar_first", False),
|
||||
"b": (True, "leftover_solar", True)})[2]
|
||||
_n12 = UTC0 + timedelta(hours=1)
|
||||
_plan12 = homeview.mode_runs(_c12b, *homeview.local_day(_n12), _n12,
|
||||
False)[0]
|
||||
print(f" Leftover solar plan at 01:00: "
|
||||
f"{[(r['from'], r['to'], r['kind']) for r in _plan12]}")
|
||||
check("...and the plan draws no grid block for it, only its expensive run",
|
||||
_plan12 and all(r["kind"] != "grid" for r in _plan12))
|
||||
_enw, _nlw = homeview.uitext.words("en"), homeview.uitext.words("nl")
|
||||
check("...and its help text promises no grid charging (EN and NL)",
|
||||
all("cheap" not in t.lower() and "goedkop" not in t.lower()
|
||||
for t in (_enw["home"]["batteries"]["choice"]["leftover_solar"]
|
||||
["description"],
|
||||
_nlw["home"]["batteries"]["choice"]["leftover_solar"]
|
||||
["description"],
|
||||
_enw["home"]["batteries"]["how"]["leftover_solar"]
|
||||
["description"],
|
||||
_nlw["home"]["batteries"]["how"]["leftover_solar"]
|
||||
["description"])))
|
||||
|
||||
print()
|
||||
if fails:
|
||||
print(f"{len(fails)} FAILED:")
|
||||
|
||||
Reference in New Issue
Block a user