Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Energy Dashboard), and opt-in **Home Assistant notifications** with companion-ap

Every change ships through the test suite, and a guard that a plausible refactor could silently
disarm is held by a committed mutation harness: **158 harnesses** holding
**6679 anchor-asserted mutants**. The harness, mutant, test and reference counts, the engine
**6720 anchor-asserted mutants**. The harness, mutant, test and reference counts, the engine
floor and group counts, and every engine-index row's code anchor are checked against the tree in
CI ([Quality & accuracy](#quality--accuracy)).

Expand Down Expand Up @@ -449,7 +449,7 @@ want to do, and the add-on's Configuration tab shows each one's help text.
## Development

```bash
cd server && npm install && npm test # 7,123 tests
cd server && npm install && npm test # 7,160 tests
cd server && ./node_modules/.bin/tsc --noEmit -p tsconfig.json # src
cd server && ./node_modules/.bin/tsc --noEmit -p tsconfig.test.json # src + tests
cd web && npm install && npm run build
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/15-1-night-charge-planning.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/reference/15-2-night-charge-writes.md
Original file line number Diff line number Diff line change
Expand Up @@ -810,10 +810,11 @@ Until the mid-day switch the add-on arms the overnight cycle only, and computes

- **When.** A minute tick (`runMiddayShadowTick`, single-flight) runs once the evening job has latched the day, inside the evening job's window (21:30–23:00 on the preset). It asks the chooser with the mid-day window and the configured objective and cost ceiling (`shadowCycleConfig`). A cycle that is not mid-day — Friday, Saturday, a holiday eve, summer, the season grace, a configuration without a cost objective or with `ARB_COST_MAX_SOC_PCT` at or below 50 — is recorded with its reason and nothing is sized.
- **The legs** (`runMiddayShadowEvening`). The backup leg is sized first on option A (`backupLegSizing`): its walk runs from its close to the next overnight open, and it arms when that walk dips under reserve + cushion (chapter 15 part 1, "The leg"). The cost leg is then sized from the pool the backup protects — the backup's hold only when the backup would arm — with C_mid under the Cores' charge taper and its PV surplus from the close to the on-peak start (`costLegSizing`). Both use the planner the live plan uses (`recomputeNightChargePlan` with a shadow leg), which for a shadow leg returns the plan only: it sets no plan holder, writes no plan snapshot and logs no calibration change, so the night-charge entities, the card and the status keep the live overnight plan.
- **The solar basis** (`panelPvSelection.ts shadowPvBasis`, opted into by `sizeShadowLeg` alone). Each leg the shadow sizes (both evening legs, option B, the morning refresh) selects its own band as the evening job's own call does: the Cores' band when it passes and covers every connected slot; else the panel-measured band as of the evening that owns the leg's window, when every clause holds; else the Cores' band, refused where it leaves a slot out (M2). It reads no latch and not the live night's cancel, and takes the install's write mode whatever the leg's role (a backup leg in a write mode is no advisory leg). One rule of its own, for the daylight the mid-day legs read: a band hour is a fitted solar figure only where it is modelled (the slope of its clock hour, fitted on at least two daylight pairs, times the forecast GHI); the typical-day fallback while the sun may be up (GHI unknown or above 20 W/m², `unfittedDaylightHourTs`) is not, and reads 0 W on a clock hour with no rows. A leg takes the panel band only when no hour from the plan instant to its horizon end falls on a clock hour the band lacks or reads that way (an hour past the 24-hour band is judged by the band hour of its clock hour: the slope is per clock hour). A refusal is said in the leg's disposition after the gate's own words ("…; the panel's own solar readings are not used: …"), and the leg sizes nothing; a leg the panel band sized says so on the row (chapter 15 part 3). A transient report, a report that does not list its unfitted hours, a span of hours that is not finite or ends at or before the plan instant, or the Cores' band passing, leaves the leg exactly as before. The live morning refresh selects nothing and stays on the published band.
- **Would it arm** (`shadowArmProbe`): `armCycle` against the cycle record in place, on the backup alone and then on both legs, the way the evening job would arm them. `armCycle` is pure and its cycle is dropped; only the verdict leaves (which legs armed, and the refusal words of those that did not). In `advisory` mode nothing is armed, and the record says so. A cost leg the planner held on the re-entry line (chapter 15 part 1, "The leg") is recorded as held for it, with its level and the line.
- **What a held reserve sends to the grid** (v1.192.0, `heldImportEstimate`). The SHP2 does not discharge the pool below its backup reserve, so while a leg's write holds it — from the write at the window open to the restore (`heldSpan`: the close, or the on-peak guard when that is sooner) — house load the pool would have carried down to the owner's reserve comes from the grid, at that hour's rate. Each sized leg is walked twice over its hold on the median load and PV of the band it was planned on, the way the planner's grid-present carry walks the pool (PV into the pack, load out of it over the discharge efficiency, clamped to the floor and to full): once held at the reserve it would write (lifted to it at the open), once at the owner's reserve, from the pool expected at the open. The load the held pool's floor turns away beyond the other's is the held import, in house kWh; the lift itself is the leg's own draw and is not in it. It is priced hour by hour at the tariff's rates, and credited with what the next charge no longer buys: the energy the pool kept (not what a full pool spilled), over the charge leg's efficiency, at the cycle's cost window rate. Their difference is what the hold adds to the bill. On the overnight-only cycle the hold and the charge share one cheap window and the difference is small; on the mid-day cycle option A's backup (written 50, held 23:00–05:00) puts house load on the 12.59¢ overnight rate that the 8.2¢ mid-day charge would otherwise have bought back — on the 2026-10-14 fixture about 9.3 kWh and $0.30 a weeknight, against about 0.6 kWh and $0.02 for option B (written 40), while the mid-day leg's own hold under the sun sends nothing. The figure is an estimate on the median forecast and nothing measures it yet: on a shadow night no hold is written (the live overnight leg runs instead), so the night's metered import cannot grade it until a hold is actually written. A leg that writes nothing, or a hold the band does not cover hour for hour, has none, and with rates not confirmed the energy is stated and nothing is priced.
- **Option B beside A** (v1.192.0): the backup is sized a second time on option B (`backupLegSizing` with the cost window's open as its horizon), after both legs, so the backup-horizon choice is made on real nights: its reserve, its draw, its walk and its held import. It is never probed, armed or announced, it anchors nothing (the cost leg is sized from option A's hold), and a planner that has nothing for it leaves it null rather than deferring the evening.
- **The morning refresh, computed** (`refreshLeg`): from 30 minutes before the cost window opens, on a fresh panel reading, the cost leg is sized again. What the evening announced is the consent ceiling of every written value, the level and the reserve held from the open: the refresh may lower or cancel, never raise — a refreshed level or reserve above the announced level, or a refreshed T_mid above the announced one, is recorded `capped` with every figure as announced (the worst case too: the re-plan's was sized on a level or reserve that will not be written) and no expected draw (the rule the live refresh uses, `refreshLeg` for both); otherwise the refreshed stop and T_mid, at most the announced ones (a figure the re-plan does not give stays as announced); a hold is `cancelled`. No refresh by 5 minutes before the open records `stood` (the evening plan stands). When the live overnight leg of the same evening wrote to the panel (its reserve raise applied, or its force-charge switched on: `liveOvernightWrote`), the 09:30 pool is not the one a mid-day cycle would have had — the live leg has filled it toward its own ceiling, often 30 points or more above a mid-day 10:00 open — so the refresh is not re-sized: it is recorded `not-comparable`, with no refreshed figures and that reason, and the entities and the card keep the evening's figures. Since v1.205.1 a cycle the evening would not arm (a write mode whose arm probe refused the cost leg, `shadowCycleRefusal` — the cycle whose 21:30 words say the add-on will not charge) is never re-sized, whatever the live leg did: from 30 minutes before the open its refresh is recorded `not-armed` (`notArmedRefresh`), with no push and the reason "the evening cycle would not arm (…), so there was nothing to refresh"; the record keeps the evening's figures, which the `shadow_refreshed_*` columns and the entities carry beside the `not-armed` disposition (`shadow_refresh_disposition`, `midday_charge_refresh`), but no word says they stand: they are the figures of a cycle that was not armed, so the log line states none and the card's row reads "Morning refresh 09:30: none — the evening cycle would not arm (…), so there was nothing to refresh"; before it, from the evening, the card's row reads "none" rather than "due" and `midday_charge_refresh` reads `not-armed` rather than `pending`, in either write mode; it used to be re-sized like any other, and could log "a live refresh would push this" beside a refresh push ending "Cancel from the charge card before 10:00 AM". A re-sized refresh records whether a live refresh would push (a cancel, a changed written value, a cap, or an expected draw moved by more than 25%), and pushes nothing. The record is re-read after the planner's await and persisted before it is logged. A re-sized refresh also records how old the weather it was sized on was (`weatherAgeS`, the ledger's `shadow_refresh_weather_age_s`): the shadow asks the analytics worker for no particular age, so it sees the worker's cache as it stands (weather up to 2 hours old), where the live refresh asks for at most 45 minutes (below).
- **The morning refresh, computed** (`refreshLeg`): from 30 minutes before the cost window opens, on a fresh panel reading, the cost leg is sized again. What the evening announced is the consent ceiling of every written value, the level and the reserve held from the open: the refresh may lower or cancel, never raise — a refreshed level or reserve above the announced level, or a refreshed T_mid above the announced one, is recorded `capped` with every figure as announced (the worst case too: the re-plan's was sized on a level or reserve that will not be written) and no expected draw (the rule the live refresh uses, `refreshLeg` for both); otherwise the refreshed stop and T_mid, at most the announced ones (a figure the re-plan does not give stays as announced); a hold is `cancelled`. No refresh by 5 minutes before the open records `stood` (the evening plan stands); so does a re-plan on another solar band than the evening's (`refreshFromSized`: the panel-measured band on one, the Cores' on the other), its reason naming both bands and no figure of the re-plan recorded. When the live overnight leg of the same evening wrote to the panel (its reserve raise applied, or its force-charge switched on: `liveOvernightWrote`), the 09:30 pool is not the one a mid-day cycle would have had — the live leg has filled it toward its own ceiling, often 30 points or more above a mid-day 10:00 open — so the refresh is not re-sized: it is recorded `not-comparable`, with no refreshed figures and that reason, and the entities and the card keep the evening's figures. Since v1.205.1 a cycle the evening would not arm (a write mode whose arm probe refused the cost leg, `shadowCycleRefusal` — the cycle whose 21:30 words say the add-on will not charge) is never re-sized, whatever the live leg did: from 30 minutes before the open its refresh is recorded `not-armed` (`notArmedRefresh`), with no push and the reason "the evening cycle would not arm (…), so there was nothing to refresh"; the record keeps the evening's figures, which the `shadow_refreshed_*` columns and the entities carry beside the `not-armed` disposition (`shadow_refresh_disposition`, `midday_charge_refresh`), but no word says they stand: they are the figures of a cycle that was not armed, so the log line states none and the card's row reads "Morning refresh 09:30: none — the evening cycle would not arm (…), so there was nothing to refresh"; before it, from the evening, the card's row reads "none" rather than "due" and `midday_charge_refresh` reads `not-armed` rather than `pending`, in either write mode; it used to be re-sized like any other, and could log "a live refresh would push this" beside a refresh push ending "Cancel from the charge card before 10:00 AM". A re-sized refresh records whether a live refresh would push (a cancel, a changed written value, a cap, or an expected draw moved by more than 25%), and pushes nothing. The record is re-read after the planner's await and persisted before it is logged. A re-sized refresh also records how old the weather it was sized on was (`weatherAgeS`, the ledger's `shadow_refresh_weather_age_s`): the shadow asks the analytics worker for no particular age, so it sees the worker's cache as it stands (weather up to 2 hours old), where the live refresh asks for at most 45 minutes (below).
- **The words it would say** (`middayShadowPreview`, chargeText.ts through chargeAnnounce.ts). The evening's record is turned into the 21:30 push and spoken notice the mid-day switch would send for it, and the refresh into the push a live refresh would send. Both are logged — "the 21:30 push would read (not sent)", "the notice would be spoken (not spoken; N of 560 characters)", "the refresh push would read (not sent)" — and the evening's is served on the status as `middayShadowPreview`, whose title the card's read-only section shows. None of them is sent or spoken.
- **Where it goes.** Its own file (`.night-charge-midday-shadow.json`, beside the database); the log, every line tagged `night-charge[midday-shadow]:` (each leg's line and the refresh's end "Shadow only", the preview lines say "not sent"); the evening's ledger row, as the `shadow_*` columns (only onto a row the evening job recorded — a shadow never creates one); the `ecoflow_midday_charge_*` entities (section 9); and the card's read-only section.

Expand Down
Loading