UX-54 round 2: tomorrow's blocks where control will act, trust as the plan counts it, strings
checks / unit (pull_request) Successful in 48m25s
infra-pin / fresh (pull_request) Successful in 1s

F1: tomorrow's blocks no longer depend on the battery's level now. Home sizes
a block from the level now (`room()`, `plan_need()` in mode_runs, the leg
sizing in trade_runs) and draws none when there is no room or energy. For a
day that has not started the builders take `ahead=True` (Home never passes
it): a charge is read from the floor, a give from the ceiling. A grid block is
then kept only where `modetrade.chargers()` would charge at the curve's level
when the run starts. The UX-53 gate is unchanged. Today still equals Home; a
give run in the plan with no block (empty battery) has its own sentence
instead of "No charge or give blocks planned".

F2: test_ux54.py part 7 walks the real `_mode_roles()` every 15 minutes
through tomorrow and compares the roles with the tab's blocks (modes on, the
peak gate, part-full batteries), and the control cycle's verdict at 07:00
(modes off).

F3: the curve counts spare solar as trust x max(0, sun - house), stored at
EFF, as `dayplan.plan()` does (10 kWh sun, 2 kWh house, 70 %: 5.32 kWh).

Strings: cycle, no_tomorrow, ahead, no_level, measured; new give_later.

No decision, command, timing or option key changes.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bdqr7PiaHcBnzPituu2yTC
This commit is contained in:
glenn schrooyen
2026-10-26 22:48:48 +01:00
co-authored by Claude
parent b6b2d1b184
commit 75195f7073
7 changed files with 388 additions and 85 deletions
@@ -13,6 +13,17 @@ battery's expected level with its blocks. It follows the add-on, as Home does
(grid, give, monthly cycle). Tomorrow's come from the same builders
(`homeview.runs_for()`). The words are the plan lines'. A block is on the tab
exactly where Home has one, so the UX-53 gate is followed too.
- **Tomorrow is read ahead.** Home sizes a block from the battery's level now
and draws none when there is no room or energy (`room()` and `plan_need()`
in `homeview.mode_runs()`, the leg sizing in `trade_runs()`). For a day that
has not started that level says nothing, so tomorrow's blocks are built with
`ahead=True` (Home never passes it): a charge is read from the floor, a give
from the ceiling, and a block is drawn wherever the plan and the gate have a
run. A grid block is then dropped where control will not take it: the curve's
level when the run starts is asked of `modetrade.chargers()`, the cycle's own
test. The gate (`mode_gate`, UX-53) is not bypassed. Control, checked every
15 minutes through tomorrow (`test_ux54.py` part 7), gives and charges where
the tab has a block.
- **The sun** is what `solarfc` reads. An hourly split (Solcast
`detailedForecast`, Open-Meteo `wh_period`) is used as given. A daily total
(Forecast.Solar, and any other state-only sensor, the owner's three "today
@@ -25,8 +36,11 @@ battery's expected level with its blocks. It follows the add-on, as Home does
gives (follow the house, hold, give, charge from the grid, rest), spare solar
goes to Solar first batteries first, a shortfall is met by those that may
give, both at `dayplan.EFF`, inside the plan's floor and ceiling, from the
level now. It counts on `solar_trust_pct` of the sun, as the plan does, and
says so. Grid charging goes to `modetrade.charge_to()`. It is an estimate.
level now. Spare solar is `trust x max(0, sun - house)` and what is stored
loses `EFF`, the plan's own `trust x EFF x max(0, sun - house)` (10 kWh of
sun, 2 kWh of house, 70 %: 5.32 kWh stored). A shortfall is not scaled by
trust. The tab says it counts on `solar_trust_pct`. Grid charging goes to
`modetrade.charge_to()`. It is an estimate.
- **Measured solar** is kept per local hour in memory (`SolarToday`), from the
reading the control cycle already takes; nothing is read back.
- **On request.** `GET forecast` builds the tab (`Controller.forecast_payload()`
@@ -44,10 +58,14 @@ is `SolarToday.add()` after the solar read, in a `try`, in memory.
## Limits
- Prices are planned about a day ahead (`priceruns.HORIZON`), so tomorrow's
blocks appear as the day comes near. The tab says so.
- A give run drawn on a battery that is empty now has no block on Home (no
energy to give), but the curve gives in it if the sun fills it first.
- Prices are planned about a day ahead (`priceruns.HORIZON`), so a block of
tomorrow later than 24 h from now, or one that needs prices not yet
published, appears as the day comes near. The tab says so. Control may also
charge longer than a block when a slower battery is still short at its end.
- Today, a give run in the plan on a battery that is empty now has no block on
Home (no energy to give). The tab equals Home, and says so: "The add-on plans
to give power. No block shows while the battery has no energy to give." The
curve gives in that run if the sun fills the battery first.
- Tomorrow shows price blocks only. A monthly cycle is drawn today, where the
curve then stops for that battery.
- The curve uses the arbitrage floor and ceiling, as the plan does, not the