Compare commits

...
29 Commits
Author SHA1 Message Date
admin 10ee2baf91 Merge pull request 'Release 0.22.0: release/1.0 -> master' (#251) from release/1.0 into master
Reviewed-on: #251
2026-11-14 15:58:33 +01:00
admin b700c0be92 Merge pull request 'Release 0.22.0' (#250) from release-0.22.0 into release/1.0
infra-pin / fresh (push) Successful in 2s
checks / unit (pull_request) Successful in 26m8s
infra-pin / fresh (pull_request) Successful in 1s
Release 0.22.0 (#250)
2026-11-14 13:21:22 +01:00
glenn schrooyenandClaude Opus 5.5 e79d403560 Release 0.22.0: CHANGELOG wording (SAFETY-136 row, SAFETY-111, MAINT-28, MAINT-26)
checks / unit (pull_request) Successful in 26m33s
infra-pin / fresh (pull_request) Successful in 2s
- SAFETY-136 row: the gain is at 10 s late; at 15 s a rig test sent more.
- SAFETY-111: the cycle needs more than 4 nights; the 36 h limit ends it.
- MAINT-28: rig counts were 393-468 flips per 45 min, not one figure.
- MAINT-26 / MAINT-25: the next try is the first start hour after the wait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 12:54:18 +01:00
glenn schrooyenandClaude 634001cb26 Release 0.22.0: CHANGELOG fixes (duplicate Known issues heading, missing full stop)
checks / unit (pull_request) Successful in 27m4s
infra-pin / fresh (pull_request) Successful in 1s
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bdqr7PiaHcBnzPituu2yTC
2026-11-14 11:52:41 +01:00
glenn schrooyenandClaude 94214d609e Release 0.22.0: version and CHANGELOG
checks / unit (pull_request) Successful in 36m47s
infra-pin / fresh (pull_request) Successful in 1s
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bdqr7PiaHcBnzPituu2yTC
2026-11-14 10:44:36 +01:00
admin 4c0122a8b6 Merge pull request 'Revert MAINT-28 (PR #247) from release/1.0' (#249) from MAINT-28-revert into release/1.0
infra-pin / fresh (push) Successful in 2s
2026-11-14 02:35:34 +01:00
glenn schrooyenandClaude 7bc8ad264b Revert "MAINT-28: during a real peak the maintenance charge stays paused (#247)"
checks / unit (pull_request) Successful in 27m32s
infra-pin / fresh (pull_request) Successful in 2s
Takes PR #247 (f3f9483) out of release/1.0 so the 19 Nov release ships
MAINT-24 + MAINT-25 without MAINT-28. The rig failed f3f9483
(reports/MAINT-28-test-report.md) and the fix-forward PR #248 review found
a High regression (reports/MAINT-28-fix-review-report.md). MAINT-28
continues on PR #248 after the release.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-14 01:33:24 +01:00
admin f3f9483d9c Merge pull request 'MAINT-28: during a real peak the maintenance charge stays paused' (#247) from MAINT-28 into release/1.0
infra-pin / fresh (push) Successful in 2s
2026-11-13 06:23:12 +01:00
glenn schrooyenandClaude e7706150e8 MAINT-28: DECISIONS gives the measured reason for the uncapped give (review M-1); ctl_cycle comment one line + pointer (L-1)
checks / unit (pull_request) Successful in 27m38s
infra-pin / fresh (pull_request) Successful in 2s
Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-13 05:53:55 +01:00
glenn schrooyenandClaude 7edf8484d1 MAINT-28: test_maint28 reads the replay clock directly (main_files.live parsed every app file per cycle): 269 s -> 28 s, same numbers
checks / unit (pull_request) Successful in 42m47s
infra-pin / fresh (pull_request) Successful in 2s
Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-13 03:57:31 +01:00
glenn schrooyenandClaude 29a8a05f30 MAINT-28: shorter test_maint28 runs (892 s -> ~280 s), digests re-pinned on 1b5f7c9; hold kept through the two short holds (documented); DECISIONS duplicate removed
checks / unit (pull_request) Successful in 40m7s
infra-pin / fresh (pull_request) Successful in 2s
Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-13 02:29:27 +01:00
glenn schrooyenandClaude f5bd2a3520 MAINT-28: re-pin test_safety84 n2_charge_banked (the charge no longer restarts in the 5000 W load)
checks / unit (pull_request) Successful in 43m17s
infra-pin / fresh (pull_request) Successful in 2s
Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-13 00:59:41 +01:00
glenn schrooyenandClaude bc5be4964e MAINT-28: N=1 digest test with a banked peak (so the N=1 gate is tested)
checks / unit (pull_request) Successful in 34m0s
infra-pin / fresh (pull_request) Successful in 2s
Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-13 00:20:21 +01:00
glenn schrooyenandClaude edf30f345a MAINT-28: keep the single shaping_suspended(.., maint_aim) call site (test_peak_margin pin); shaping_held takes its answer
checks / unit (pull_request) Successful in 32m46s
infra-pin / fresh (pull_request) Successful in 1s
Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-12 23:58:19 +01:00
glenn schrooyenandClaude 23359a047d MAINT-28: test_maint28 points at MUTATION.md (test_bytecode)
checks / unit (pull_request) Failing after 34m49s
infra-pin / fresh (pull_request) Successful in 1s
Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-12 23:29:13 +01:00
glenn schrooyenandClaude 8640bfcbc1 MAINT-28: hold only where MAINT-24 moved the aim (banked peak above the cap); test_safety119 pins stay
checks / unit (pull_request) Failing after 34m27s
infra-pin / fresh (pull_request) Successful in 2s
Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-12 23:13:57 +01:00
glenn schrooyenandClaude 92f0387415 MAINT-28: reset the hold every cycle, test it; digests vs 1b5f7c9; DECISIONS numbers and mutants
checks / unit (pull_request) Failing after 36m49s
infra-pin / fresh (pull_request) Successful in 2s
Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-12 22:44:32 +01:00
glenn schrooyenandClaude 4f9aa5223f MAINT-28: the hold is for N=2 and up (SAFETY-87 N=1 pins), N=1 peak digest test
checks / unit (pull_request) Failing after 36m51s
infra-pin / fresh (pull_request) Successful in 2s
Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-12 22:28:01 +01:00
glenn schrooyenandClaude 8cd10ee6aa MAINT-28: during a real peak the maintenance charge stays paused until the house is clear of the aim
infra-pin / fresh (pull_request) Successful in 2s
checks / unit (pull_request) Failing after 1h10m11s
Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-12 21:51:56 +01:00
admin 1b5f7c9ccb Merge pull request 'MAINT-24 + MAINT-25: a started maintenance charge gets the cheap night; the plan honours the back-off' (#246) from MAINT-24 into release/1.0
infra-pin / fresh (push) Successful in 3s
2026-11-12 16:09:32 +01:00
glenn schrooyenandClaude 33cfc733d3 MAINT-25: clean test_maint25.py, split its DECISIONS note
checks / unit (pull_request) Successful in 26m39s
infra-pin / fresh (pull_request) Successful in 1s
Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-12 11:08:30 +01:00
glenn schrooyenandClaude de0790e62d MAINT-25: the Home plan shows no cycle during the 7-day back-off
checks / unit (pull_request) Successful in 27m21s
infra-pin / fresh (pull_request) Successful in 1s
homeview.maintenance_runs() ignored backoff_until(); it drew a cycle every
night of the wait. Now no run and a plain line (EN, NL). test_maint25.py.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-12 09:57:56 +01:00
glenn schrooyenandClaude b80cfa969f MAINT-24: test_peak_margin pins the maintenance checks to the guard's aim
checks / unit (pull_request) Successful in 29m32s
infra-pin / fresh (pull_request) Successful in 1s
Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-12 08:22:13 +01:00
glenn schrooyenandClaude 6004bfad9a MAINT-24: read the last row without a bare index (test_named_absence)
checks / unit (pull_request) Successful in 26m37s
infra-pin / fresh (pull_request) Successful in 1s
Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-12 08:15:01 +01:00
glenn schrooyenandClaude b44a648cab MAINT-24: test_maint24.py points at MUTATION.md
checks / unit (pull_request) Successful in 28m32s
infra-pin / fresh (pull_request) Successful in 1s
Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-12 07:51:28 +01:00
glenn schrooyenandClaude 0f5e513f1d MAINT-24: keep the refusal probe beside a maintenance charge
checks / unit (pull_request) Failing after 45m44s
infra-pin / fresh (pull_request) Successful in 2s
The mode trade still lets a SAFETY-73 probe (PROBE_W alone) go on while a pack
is in its maintenance CHARGE phase; test_opt20.py g7 pins it. ch_ch_maint
digest moved (B no longer grid-charges beside A's charge).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-12 07:33:04 +01:00
glenn schrooyenandClaude 54a738dd87 MAINT-24: a started maintenance charge gets the cheap night
checks / unit (pull_request) Failing after 41m45s
infra-pin / fresh (pull_request) Successful in 2s
While a pack is in its maintenance CHARGE phase the mode trade files no grid
charge for the other packs (why "cycle", mirror of SAFETY-78). The maintenance
shaping check and charge floor aim at peakguard.quarter_target_w, month peak
included (SAFETY-80). Tests through cycle(): test_maint24.py.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-12 07:07:44 +01:00
admin 02eac3b84e Merge pull request #245: SAFETY-135 one guard stop does not cost the night charge the whole period
infra-pin / fresh (push) Successful in 2s
2026-11-11 20:55:30 +01:00
admin 5e00cbbd79 Merge pull request 'Release 0.21.0: release/1.0 -> master' (#242) from release/1.0 into master
Reviewed-on: #242
2026-11-08 17:27:32 +01:00
14 changed files with 674 additions and 14 deletions
+121
View File
@@ -1,5 +1,126 @@
# Changelog
## 0.22.0
**A minor bump: a battery's monthly charge now gets the cheap night, the plan knows about the 7-day wait, a slow meter is followed more gently, and one peak-guard stop no longer costs a night charge its whole period. No option changes.**
No option was added, removed or renamed, and no default changed (86 options). **Existing installs need no option change:** options that start 0.21.0 also start 0.22.0, and the Supervisor form is the same. It is a minor bump because control acts differently in the cases below; every saved setting still starts.
**A battery's monthly charge gets the cheap night.** While one battery is in the charge part of its monthly cycle, the other battery no longer grid-charges ahead of it, and the charge aims at this month's highest peak, as the peak guard does, not at the lower limit. In a rig test with the live setup (two batteries, one in its monthly charge), the cycling battery charged at about 1.5 kW in every cheap quarter (13.3 kWh in a night) and the other battery bought nothing; before, it charged at about 225 W or not at all. The peak limit was kept. At the start of a month, before a peak above the limit has been seen, this charge is much slower ([[SAFETY-111]]).
**The plan knows about the 7-day wait.** After a failed monthly cycle, Home no longer shows a cycle every night. It says the cycle waits, and shows the day the wait ends. The cycle tries again at the first start hour after the wait ([[MAINT-26]]). In a rig test no cycle was drawn during the wait, and none started.
**One peak-guard stop no longer costs the night charge its period.** With battery modes on, a night grid charge that the peak guard stops early in a 15-minute period used to stay stopped until the period ended. It may now start again after a minute, once per period, and not in the last minute. A real overload is cut as fast as before. In a rig test of the 01:00 case the night's charge was 0.45 to 0.46 kWh, against 0.42 to 0.44 kWh before. The status says "grid charge paused, it tries again in a minute" while it waits.
**A slow meter is followed more gently.** With a meter whose readings come about 4 s or more apart, such as a 5 s meter, control now takes smaller steps after a big change until the meter shows it. With Home Assistant readings 10 s late, less power goes to the grid when loads switch on and off: 44 % less in a simulation and 29 % less in a rig test. Meters of 1 or 2 s are left alone by design (the same commands in 63 simulation runs). With readings 15 s late the gain is smaller (19 % in a simulation), and a rig test sent more to the grid than before; see the known issues.
**No change in behaviour:** the comments in the main program file are shorter, and the file is split into smaller files by job. A rig test saw the same start-up, stops and commands.
Contents of this release, in merge order since 0.21.0 (`5e00cbb`):
| | |
|---|---|
| `56fc41f` | The comments in the main program file are shorter and clearer. There is no change in behaviour ([[MAINT-20]], #224) |
| `8508ac3` | The main program file is split into smaller files by job. There is no change in behaviour; a rig test saw the same start-up, stops and commands ([[MAINT-21]], #243) |
| `a8ecf17` | With a 5 s meter, control follows the meter more gently after a change. With Home Assistant readings 10 s late, less power goes to the grid when loads switch on and off. Meters of 1 or 2 s are left alone ([[SAFETY-136]], #244) |
| `02eac3b` | A night grid charge that the peak guard stops early in a 15-minute period may start again after a minute, once per period, instead of staying stopped until the period ends. A real overload is cut as fast as before. Battery modes only ([[SAFETY-135]], #245) |
| `1b5f7c9` | While a battery's monthly cycle charges, the other battery no longer grid-charges ahead of it, and the charge aims at this month's highest peak, so it gets the cheap night. After a failed cycle, the plan no longer shows a cycle every night and says the cycle waits ([[MAINT-24]], [[MAINT-25]], #246) |
| `f3f9483`, `4c0122a` | History only: MAINT-28 was merged (#247) and then taken out again (#249). The two cancel out and the code is the same as at `1b5f7c9`. MAINT-28 is not in this release ([[MAINT-28]]) |
### Known issues
- A false "Battery is not keeping up" can still show when the peak guard pauses a maintenance charge ([[SAFETY-92]]).
- A battery capped at a low limit with a perfectly flat reading can still trip the stale check ([[SAFETY-74]]).
- A battery whose reading at rest is beyond about ±175 W is still not caught when it refuses ([[SAFETY-97]]).
- The peak guard can still back off near the end of a 15-minute period when a meter reading is late, by less than 30 s. This is about the guard's discharge only; a grid charge is cut back since 0.19.2 ([[SAFETY-99]]).
- Two inverters: the maintenance charge can switch on and off while the house is above the peak aim ([[SAFETY-88]]).
- Two inverters: the "circulating" figure counts a battery's reading at rest ([[SAFETY-98]]).
- Two inverters: a drain that starts during a big step in house use can send the other battery to full power, and about 1 kW goes to the grid for about 10 s ([[SAFETY-104]]).
- Two inverters: when a battery comes back during a maintenance charge, the grid can step by several kW at once ([[SAFETY-101]]).
- Two inverters: when a battery drops out during a solar surplus, the others can swing by up to 1.5 kW in a simulation ([[SAFETY-105]]).
- Two inverters: after a drain ends, a change in house use can go unanswered for about 9 s, because some readings are old ([[SAFETY-106]]).
- Two inverters: when one battery's level is missing, both batteries are held at 0 W, and for about 15 s the last command stays on ([[SAFETY-108]]).
- Two inverters: if one battery's level stays missing for 12 h, the other battery's cycle can be marked failed, with a 7-day wait and a notice, though it is healthy. This comes from reading the code; it has not been seen on a site ([[MAINT-17]]).
- When the 15-minute demand forecast sensor counts the battery's own charge, the maintenance charge runs at about half the power the peak limit leaves, so it takes about twice as long (seen on a site: about 1.2 kW instead of 2.5 kW; the peak limit was kept). At the start of a month, before a peak above the limit, that is about 2 kWh a night in a rig test: the cycle can reach its 36 h limit after about 4 nights and fail, and since 0.22.0 the other battery gets no grid charge on those nights ([[SAFETY-111]]).
- One inverter: after a link drop, the battery's own safety stop to 0 W can be taken as a refusal, and the site stays at 0 W for up to 15 min ([[SAFETY-102]]).
- After a Home Assistant restart, control still waits until Home Assistant has finished starting, which can take several minutes, though the readings are already there ([[SAFETY-115]]).
- While Home Assistant is not answering, the page can list inverters as refusing commands and sensors as missing, and send you to Developer Tools, though they are fine ([[UX-37]]).
- If Home Assistant hangs or stops, the page keeps saying "Waiting for Home Assistant" and never turns into an alarm ([[SAFETY-113]]).
- Right after Home Assistant has started, the page can say for about 4 s that an inverter cannot be controlled, and the first command can come late ([[SAFETY-114]]).
- After a Home Assistant restart, the controller status sensor can still say "running" while the add-on cannot control. It was seen once, and the cause is not known ([[SAFETY-116]]).
- Battery modes on: after a planned top-up from the grid, the Batteries screen can say "Enough sun is forecast" ([[UX-32]]).
- Battery modes on: the forecast line "we count on" can show more sun than the plan counts, because the plan takes house use off first ([[UX-33]]).
- Battery modes on: before a planned top-up, the Today list shows a smaller "gives" amount than the plan will use; it grows as the charge happens ([[UX-34]]).
- Two inverters, battery modes on: while the other battery is in its maintenance charge, a battery's card can say it charges from the grid while it stays at 0 W ([[OPT-18]]).
- Two inverters, battery modes on: while a battery refuses to charge in a cheap run, the action log on the page gets about 8 lines an hour for its retries, and the page hint says "waiting for a better price" ([[UX-38]]).
- A battery in a safety stop, or one the add-on cannot reach, can still be started for a cycle, and its drain then waits about 12 h and ends in a failed-cycle notice. This comes from reading the code; it has not been seen on a site ([[MAINT-19]]).
- On the Settings page, the rows of the solar forecast lists are labelled "Phase 1", "Phase 2" instead of "Sensor 1", "Sensor 2" ([[UX-27]]).
- In the solar forecast list, a blank or repeated row makes "source 2 of 2" count differently from the rows on the Settings page ([[UX-28]]).
- The solar forecast message says "has no reading" also when the sensor shows a number that is too old or in the wrong unit ([[UX-29]]).
- If you use only the forecast lists, two Settings notes sit on the single-sensor field, and one of them tells you to set that field ([[UX-30]]).
- After a restart during a price outage, the "No prices" message can say "yet" when prices did come in earlier ([[UX-39]]).
- On the new settings page, you cannot see whether a price service token is set. Check the Configuration tab ([[UX-41]]).
- On the classic settings page, the first click on Save after editing a field can do nothing. Click again ([[UX-42]]).
- A steady overload on a 1 s meter can warn, and send the Home Assistant notification, 2 or 3 times at the start of each 15-minute period instead of once. The peak limit is still kept ([[SAFETY-122]]).
- A fixed tariff is priced once per hour, so a price window that starts or ends at :15, :30 or :45 gets the wrong price for part of that hour. Windows that start and end on the hour are right ([[TARIFF-23]]).
- Step 6 of the setup wizard stays empty because of an error in the page, in English and in Dutch ([[UX-51]]).
- On Dutch pages, refusal texts, the last-event line under the Home buttons, the installer details and the trading status sentences are still English, and a few Dutch texts read badly, such as "1 metingen geweigerd" ([[UX-52]]).
- Some price texts say "hour" where the add-on acts on a 15-minute period, such as "cheapest hour" ([[UX-47]]).
- After the add-on restarts, the Home price chart shows no price for the earlier part of today, and the setup check can say "12 of 24 hours", though the prices are known ([[UX-48]]).
- With battery modes on and only batteries on "Leftover solar", the Home price chart can mark a cheap period where no battery charges ([[UX-49]]).
- On a phone, the bars of the Home price chart are too thin to tap one 15-minute period. The arrow keys work ([[UX-50]]).
- In the last second of a 15-minute period, being a few watts over the aim can make the peak guard ask a battery for full power for one second. When a charge ends on a period edge, the last-second give can fade out over about 10 s, and a rig test exported up to 7.4 kW for about 8 s ([[SAFETY-124]]).
- During the night grid charge, a 15-minute period can end 6 to 14 W over the peak aim, because the battery charges harder than asked. This was seen in simulation; a rig test saw 2 to 8 W ([[OPT-35]]).
- The test rig could not bring back the false peak alarm that [[SAFETY-126]] fixes, so that fix is shown in simulation only. Watch the notifications for a few nights ([[TEST-35]]).
- The night cheap run is sized for the batteries' full charging power, not for what the peak limit leaves. Under a tight limit the run can end before the batteries reach their level, and Home can show a level they do not reach (79.9 % against a shown 95 % in a rig test) ([[OPT-25]]).
- By day, a Leftover solar plan that has only a daily forecast figure counts the sun from now, not from when the figure was read. It counts about 22 % too much for a figure one hour old; the night plan is not affected ([[OPT-30]]).
- The night charge can buy too much in a house that uses more at night than by day, such as one with a car charger or heat pump, and on a sunny day, because spare sun in one expensive hour does not count for the later ones ([[OPT-31]]).
- A cheap run that has already started can overlap a new give run after a re-plan, so a battery can charge from the grid at the dearest price for part of an hour. This was seen in a test case, not on a site. Also in 0.19.2 ([[OPT-32]]).
- If the solar forecast sensors stop updating before 17:00, as in winter or further north, there is no forecast from three hours after their last update until 20:00 ([[OPT-33]]).
- With a forecast that gives only a daily total, the sun is spread an hour off on the two clock-change days after the change. The day's total is right ([[OPT-24]]).
- The add-on learns the house's use only once a solar forecast is set, so a site that adds a forecast later waits one more day for its first plan ([[OPT-26]]).
- Home says "No trading on price yet: no prices have arrived" when every battery is on Solar first, though the prices are shown ([[UX-55]]).
- The Home plan header can say "Charges in the cheapest hour, gives power in the dearest" when Home draws no charge, and it says "hour" for 15-minute prices ([[UX-56]]).
- While the peak guard holds back charging, Home hides the rest of the cheap run and gives no reason. The charge starts again when the guard lets go ([[UX-57]]).
- With battery modes on and selling on, Home can draw a "Sells up to" block when the add-on judges the trade not worth it, and then it will not sell ([[UX-58]]).
- Home, the plan and the Forecast tab stop drawing a battery's give at the trading floor, though control goes on giving down to the battery's cut-out ([[UX-59]]).
- During a price outage, the Batteries screen says "Prices differ too little" and Home says "The price gap is too small" ([[UX-60]]).
- With battery modes on and no meter, or a meter that is a Home Assistant entity, a grid charge is not possible and nothing says so ([[UX-61]]).
- On the Batteries screen, a charge the add-on refused in a cheap run reads as "Saves its power for ...", for up to 15 minutes ([[UX-62]]).
- A Leftover solar battery with no capacity set never charges from the grid when a solar forecast is set, and nothing warns about it ([[UX-63]]).
- The "How the modes work" box on the Batteries screen does not describe Cheap hours only ([[UX-64]]).
- With battery modes on, Settings still shows "Trade on the price spread", which the modes ignore. A site with modes on and no price source starts, and the Batteries screen says "No prices, so it follows the house" without pointing to Settings ([[UX-65]]).
- With battery modes off and several equal prices in a row, Home and the Forecast tab draw one price quarter, while the add-on trades every quarter of the run ([[UX-67]]).
- Late in the day, the Forecast tab's "now" line and last bars sit over the axis labels at the right edge ([[UX-68]]).
- The Forecast tab's level curve charges at each battery's full rating. Under a peak limit the levels it draws are too high and a charge block can end early (54.6 % shown against 39.7 % in a rig test) ([[UX-70]]).
- The peak forecast check says maintenance charging is not kept under the peak limit when no peak forecast is set, but since 0.19.2 it is ([[UX-73]]).
- The peak guard row can show the same figure twice, such as "at this rate 3 500 W, over 3 500 W". Also in 0.19.2 ([[UX-74]]).
- If the inverter's setpoint entity appears in Home Assistant after the add-on has started, the page keeps saying "Inverter control: not found in Home Assistant" and the batteries say "An alarm stopped control" until a restart, though control runs ([[UX-75]]).
- In the last minute of a 15-minute period, with Home Assistant readings 30 s late, the period can end about 80 W over the peak aim and over the limit: 3 530 W against a 3 450 W aim and a 3 500 W limit in a rig test with a 2 kW load added 45 s before the end. The peak guard sees the load too late to hold it back ([[SAFETY-133]]).
- With Home Assistant readings 10 s late, the grid charge in a cheap run can swing by several kW. In a test the add-on asked for an 8.7 kW charge (9.6 kW on 0.20.0) ([[SAFETY-132]]).
- A plan rebuilt while the battery levels are missing for a moment can drop a cheap run that has not started yet, so the battery does not charge that day. Seen in a replay of real prices, where it cost about EUR 0.40 of extra grid use; the Leftover solar change in 0.20.1 no longer triggers it in those replays, but the cause stays ([[OPT-37]]).
- On a 5 s meter, Home Assistant readings 10 s late are still not caught, and readings 15 s late only after about 4 minutes. Control now follows the meter more gently, so less goes to the grid: in a simulation with a changing load, 340 Wh became 189 Wh at 10 s late and 363 Wh became 296 Wh at 15 s late. In a rig test, 15 s late exported 13 to 19 % more than before ([[SAFETY-136]], [[SAFETY-134]]).
- With readings 10 to 15 s late, the hold can end in the middle of the delay and the swing can come back. Seen in rig tests with a 2 s and a 5 s meter ([[SAFETY-134]]).
- With readings 10 s late on a 1 s meter, the grid can still move between -422 and +340 W while the batteries are held. With a very long delay (30 to 90 s) the request can swing by about 900 W every few seconds. Seen in review tests ([[SAFETY-130]]).
- A battery that answers very slowly (10 s or more) can be taken for late Home Assistant readings and held, and the page then blames Home Assistant. A GoodWe battery settles in about 6 s and this has not been seen on one ([[SAFETY-131]]).
- The page row for late readings reads awkwardly in English ("Home Assistant readings show requests about N seconds late, so control holds the batteries"), and the Dutch text misses a word ([[UX-78]]).
- When the add-on stops, a write that takes more than 2 s can still land after the 0 W, and the 30 s safety timer on the ESPHome board then sets 0 W. After the Stop button, a cycle that had already decided can send its share (560 to 670 W) just after the 0 W; the next cycle sends 0 W again ([[SAFETY-138]]).
- In the last hour of a cheap run, Home can draw a battery's grid charge up to an hour past the time control stops charging it. It only draws too much, never too little ([[UX-79]]).
- A tomorrow solar forecast sensor that reports just after midnight with yesterday's value can be used as the new day's forecast for up to 12 hours. This has not been seen on a site ([[OPT-39]]).
- During a cheap-hours charge, at some 15-minute boundaries the add-on sends 0 W for one tick ("no trade (headroom)") and then goes on. Seen in a rig test, in 5 of 8 cases; once, with a frozen battery reading, it left a battery at 0 W until 23:45 ([[OPT-40]]).
- During a real peak, a battery in its maintenance charge can switch between charging and giving, about 400 times in 45 minutes in rig tests. That means more wear, but no higher peak ([[MAINT-28]]).
- While one battery's monthly cycle charges, the other battery's card on Home says "Saves its power for higher prices", and the plan still shows its grid charge in the cheap hours, though it will not charge ([[UX-80]]).
- After a failed monthly cycle, the plan line shows the day the wait ends, such as 18 November, not when the cycle tries again, such as 19 November at 19:00 ([[MAINT-26]]).
- At the start of a cheap window the peak guard can step once although the period is under the aim, and the step can land on a battery in its monthly charge. In a rig test it gave 1.7 to 2.3 kW for 6 s ([[SAFETY-140]]).
- A grid charge at full power in the last seconds of a 15-minute period can run into the next period, where the peak guard cuts it back ([[SAFETY-139]]).
### If you are crossing from a version older than 0.10.0
`## 0.10.0` below can refuse an old config: `slew_w` above its limit, and the
withdrawn `price_provider` ids `engie_dynamic`, `totalenergies_dynamic` and
`eneco_eddy`. Read it before you update. Run `tools/predeploy_check.py` with the
bare options (`jq '.data.options'`) first.
## 0.21.0
**A minor bump: control now holds the batteries when Home Assistant readings come late, Home draws the whole night's grid charge, and the shutdown 0 W is sent last. No option changes.**
@@ -0,0 +1,72 @@
# MAINT-24 - a started maintenance charge gets the cheap night
**Status: for review.** Tests: `test_maint24.py` (`test_opt20.py`'s `ch_ch_maint` digest moved with it). No option added; the MAINT-13
timeout numbers are unchanged. Folds in SAFETY-80. SAFETY-111 stays on its card (section 3).
**What happened (live 0.21.0, A, 2026-11-08..11).** A sat in its maintenance
CHARGE phase for more than 75 h and stalled at 49-50 %. At night B's battery-mode
grid charge took the cheap run: A is not idle, so `modetrade.chargers()` never
lists it, B is the only charger, and the allocator hands the whole negative
target to B. A's own shaping then paused or shrank (the check compared the peak
forecast with `cap - margin` = 3450 W, while B's trade and the guard aim at this
month's peak, about 4.9 kW), and A gave power back on guard stops against a peak
that B's own charge made. The timeout (MAINT-13) counted that starved time as
charging time and ended the cycle. Report: `reports/MAINT-24-investigation-report.md`.
## 1. The maintenance charge goes first in the cheap run
`modetrade.decide(maint_charging=)`, set in `_mode_roles()` when any pack is in
its maintenance CHARGE phase. It is the mirror of `draining` (SAFETY-78): no
grid-charge trade for the other packs, why `cycle`, the same Tick. The other
packs keep their solar roles, so they may still take spare solar. A refusal probe
(SAFETY-73, PROBE_W alone, OPT-20) still goes on: it places no charge on the
pack in maintenance, and `test_opt20.py` g7 pins it. The drain still blocks it. B's night
charge waits for the nights A needs. At N=1 the only pack is the one in
maintenance, so nothing changes.
## 2. The shaping aims where the guard aims (SAFETY-80)
The pause (`shaping_suspended()`) and the floor (`maintenance_charge_floor()`)
get `peakguard.quarter_target_w(cap, margin, month reading)` instead of
`peak_cap_w - peak_margin_w`. With no banked peak above the cap that is the same
number. SAFETY-63 (no forecast: no pause, configured rate) and SAFETY-125 (late
reading: `charge_room_w`) are untouched. `peak_aim_w()` stays for the day plan.
## 3. SAFETY-111 is not folded in
`peak_fc` holds the pack's own charge, so the floor `aim - peak_fc` settles at
(aim - house) / 2, here 1475 W instead of 2000 W. Taking the own charge off the
forecast was tried: it lifts A to 2000 W, but it changes the N=1 charge that
`test_safety119.py` pins (a static 800 W forecast then no longer shapes the
charge), so it is a change of its own. 1475 W fills a 10 kWh pack inside the
night (sim below). It stays on its card.
## 4. A gives nothing while no real peak exists
With 1 and 2 no grid charge of B makes a peak against the lower aim, and the pause
comes only when the forecast is over the month aim, so A is not made the only
battery that gives while B charges. A guard stop on a real peak
still lands on A (SAFETY-07 / MAINT-02, unchanged).
## Numbers (sim, house 3000 W, cap 3500, margin 50, month peak 6000 W)
| | base 02eac3b | MAINT-24 |
|---|---|---|
| A charge | 0 W (B charges 2500 W) | 1475 W = (5950 - 3000) / 2 |
| B grid trade | yes, quarters 5500 W | none, why `cycle` |
| quarter peak | 5500 W | 4475 W (aim 5950 W) |
| A at house 3800 W | 0 W | 1075 W, quarters 4876 W |
Whole night (sim, `tools`-style replay, N=2, cheap 21:00-06:00, A from 10 %, B
from 30 %, 9 h): base A takes 1.41 kWh (10 -> 23 %), B takes 6.84 kWh by grid
trade; MAINT-24 A takes 9.47 kWh and is full (100 %) inside the night, B takes
no grid charge. Worst 15-minute average 5500 W on base, 4475 W now, A never
gives.
## Not changed
The MAINT-13 timeout, the peak aim itself, the month peak, `P_MAINT_SHAPE` and
`P_ARBITRAGE`. The Home card for B does not say "the other battery is cycling"
for a CHARGE phase (`other_cycle` reads "emptying"); that is a wording card.
MAINT-25 (the Home plan and the back-off) has its own note: `MAINT-25-plan-backoff.md`.
@@ -0,0 +1,10 @@
# MAINT-25 - the Home plan honours the 7-day back-off
**Status: for review.** Added to the MAINT-24 PR by the owner (2026-11-12).
Tests: `test_maint25.py`. After a failed cycle `wants_start()` waits 7 days
(MAINT-13, `backoff_until()`), but `homeview.maintenance_runs()` only asked
`due()`, so the plan drew a cycle at the start hour every night of the wait.
During the back-off it now draws no run for that battery and shows one line
instead: "Battery A: the monthly cycle waits until 19 November." (Dutch: "...
wacht tot 19 november."). A cycle completed after the failure ends it, as in
`backoff_until()`. The other battery is planned as before.
+7 -2
View File
@@ -559,8 +559,13 @@ class CycleMixin:
# peakguard.shaping_suspended(), NOT HERE. One suspension flag
# per SITE (`arbitrate()` allows one pack in CHARGE).
# (DECISIONS/MAIN-orchestration-archive.md)
# MAINT-24: the guard's aim, month peak included (SAFETY-80).
# DECISIONS/MAINT-24-charge-first.md
maint_aim = peakguard.quarter_target_w(
float(self.o.get("peak_cap_w", 3500)),
self.peak_margin_w, _reading)
if peakguard.shaping_suspended(
self.peak_guard, self.peak_fc, self.peak_aim_w()):
self.peak_guard, self.peak_fc, maint_aim):
# Edge-logged: level-logging here would write one line per
# cycle for as long as the event lasts and flush the 40-line
# action log of the very context that explains it.
@@ -582,7 +587,7 @@ class CycleMixin:
# (DECISIONS/MAIN-orchestration-archive.md)
floor = maintenance_charge_floor(
self.maint.cfg.charge_w,
self.peak_fc, self.peak_aim_w())
self.peak_fc, maint_aim)
floor = self._charge_headroom(floor, claims)
if floor > 0:
hi, reason = -floor, "cheap-window charge"
+3 -1
View File
@@ -422,7 +422,9 @@ class TradeMixin:
blocked=self._charge_blocked_q == quarter,
done_charge=done_c, done_sell=done_s, targets=targets,
draining=any(r.phase == DRAIN for r in maint_results or ()),
wait=wait)
wait=wait,
maint_charging=any(r.phase == CHARGE
for r in maint_results or ()))
self._latch_charge(now, runs, targets, packs)
# A charge the guard or the headroom stopped stays off this period.
# OPT-15: only a MEASURED stop latches; the first unmeasured headroom
+14
View File
@@ -630,6 +630,11 @@ def maintenance_runs(c, day0, day1, now, shadow):
run_cycle_why(shadow),
run_cycle_amount(hours)))
continue
until = m.backoff_until(now)
if until is not None:
# MAINT-25: a failed cycle waits (MAINT-13); no run is planned.
lines.append(line_cycle_backoff(inv.name, until))
continue
if not m.due(now) and (m.next_due(now) is None
or m.next_due(now) >= day1):
continue
@@ -1529,6 +1534,13 @@ def line_cycle_waits(name) -> str:
return _t("cycle_waits", name=name)
def line_cycle_backoff(name, until) -> str:
"""MAINT-25: the failed cycle waits until `until` (MAINT-13)."""
local = brussels(until)
return _t("cycle_backoff", name=name, day=local.day,
month=month_name(local))
def line_no_prices(since, now) -> str:
"""PRICE-01: no price covers now. `since` is an instant or None."""
if since is None:
@@ -1669,6 +1681,8 @@ def _samples() -> list:
("plan", run_house_why()), ("plan", run_house_why(True)),
("plan", run_house_amount()),
("plan", line_cycle_waits("Battery B")),
("plan", line_cycle_backoff("Battery B", datetime(
2026, 11, 19, 12, 0, tzinfo=timezone.utc))),
("plan", line_no_prices(None, datetime(2026, 10, 14, 9, 0,
tzinfo=timezone.utc))),
("plan", line_no_prices(datetime(2026, 10, 14, 0, 0,
+13 -3
View File
@@ -56,7 +56,9 @@ Rules that keep this safe (tests: test_modes_p3.py, test_price_run_fixes.py):
the probe (none: PROBE_W alone), so a probe never places charge on a
battery in a maintenance phase or on one that rests;
* no grid charge while another battery drains for its monthly cycle
(`draining`, SAFETY-78): it would charge against the drain.
(`draining`, SAFETY-78): it would charge against the drain; nor while
one is in its maintenance CHARGE (`maint_charging`, MAINT-24): the cheap
night's room is that pack's.
"""
from dataclasses import dataclass
@@ -180,7 +182,8 @@ def energy(packs, floor_pct, ceiling_pct, done_charge=(), done_sell=(),
def decide(runs, now, packs, *, charge_ok, sell_ok, trade_why, price_now,
headroom_w, floor_pct, ceiling_pct, house_w, charging_now=False,
blocked=False, done_charge=(), done_sell=(),
targets=None, draining=False, wait=None) -> Tick:
targets=None, draining=False, wait=None,
maint_charging=False) -> Tick:
"""This tick's ranges, roles and site ask.
`runs` is the kept `priceruns.RunPlan` or None (no fresh prices).
@@ -194,7 +197,10 @@ def decide(runs, now, packs, *, charge_ok, sell_ok, trade_why, price_now,
this 15-minute period. `targets` is the day plan (`charge_to()`).
`draining` says a battery drains for its monthly cycle, so none may
charge from the grid (why "cycle"). `wait` ("wait" or "settle", the
why) says no charge may start yet (SAFETY-135).
why) says no charge may start yet (SAFETY-135). `maint_charging` says a
battery is in its maintenance CHARGE phase: no grid charge for the others
either, same why, but a refusal probe goes on (MAINT-24,
DECISIONS/MAINT-24-charge-first.md).
"""
plan_on = runs is not None and runs.on
in_cheap = plan_on and runs.cheap.holds(now) and runs.charge_useful()
@@ -206,6 +212,10 @@ def decide(runs, now, packs, *, charge_ok, sell_ok, trade_why, price_now,
if in_cheap else []
if ch and draining:
ch, why = [], "cycle"
elif ch and maint_charging:
# MAINT-24: a refusal probe (PROBE_W alone, OPT-20) may go on.
ch = [p for p in ch if p.refused < 0]
why = None if ch else "cycle"
charging = False
if ch:
need = 0.0 if charging_now else START_W
+1
View File
@@ -430,6 +430,7 @@
"give": "Tomorrow: gives power at {at}, {eur} per kWh.",
"give_would": "Tomorrow: would give power at {at}, {eur} per kWh."
},
"cycle_backoff": "{name}: the monthly cycle waits until {day} {month}.",
"cycle_waits": "{name} waits its turn for the monthly cycle.",
"no_prices_yet": "No prices yet, maintenance waits.",
"no_prices_since": "No prices since {at}, maintenance waits.",
+1
View File
@@ -365,6 +365,7 @@
"no_level": "Nu geen handel op prijs: een laadniveau is onbekend."
},
"tomorrow_trade": {"grid": "Morgen: laadt om {at}, {eur} per kWh.", "grid_would": "Morgen: zou laden om {at}, {eur} per kWh.", "give": "Morgen: levert stroom om {at}, {eur} per kWh.", "give_would": "Morgen: zou stroom leveren om {at}, {eur} per kWh."},
"cycle_backoff": "{name}: de maandelijkse cyclus wacht tot {day} {month}.",
"cycle_waits": "{name} wacht zijn beurt af voor de maandelijkse cyclus.",
"no_prices_yet": "Nog geen prijzen, onderhoud wacht.",
"no_prices_since": "Geen prijzen sinds {at}, onderhoud wacht.",
+1 -1
View File
@@ -1,5 +1,5 @@
name: GoodWe RS485 Controller
version: "0.21.0"
version: "0.22.0"
slug: goodwe_controller
description: >-
Drives a GoodWe ES/BP battery inverter over its RS485 EMS port by sending it a
+257
View File
@@ -0,0 +1,257 @@
"""Runnable check for MAINT-24. `python3 test_maint24.py`
A started maintenance charge at N=2 must get the cheap night. On the live site
(2026-11-08..11) battery B's grid charge (battery modes) took the night, and
A's own charge was switched off or sized at 200-450 W: its pause and its floor
compared the peak forecast with `cap - margin`, not with this month's peak
that the guard and B's trade aim at (SAFETY-80), and its floor counted its own
charge in the forecast (SAFETY-111).
All on the real Controller through `cycle()` (the lagged N=2 replay, tools/
opt20_scen.py): cheap window, house 3000 W, cap 3500 / margin 50, a month peak
of 6000 W banked (aim 5950 W), a peak forecast that follows the grid.
1. A in maintenance CHARGE, B a Cheap hours charger: A charges at the room under
the month aim (half of it: the forecast holds A's own charge, SAFETY-111
stays on its card), B files no grid trade, B's why is "cycle", every quarter is at or
under the month aim.
2. Forecast above 3450 W but under the month aim: shaping is not paused and A
gives nothing. A real peak (house over the month aim) still pauses it.
3. The mirror: B in maintenance CHARGE, A the charger.
4. modetrade.decide(): `maint_charging` files no charge, why "cycle"; solar
roles stay.
5. Unchanged: N=1 with no forecast entity, the SAFETY-78 drain, battery modes
off (digests printed on release/1.0 02eac3b).
Mutations: DECISIONS/MAINT-24-charge-first.md.
Read MUTATION.md before you report a survivor.
"""
import logging
import os
import sys
from types import SimpleNamespace
HERE = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, HERE)
sys.path.insert(0, os.path.join(HERE, "tools"))
logging.disable(logging.WARNING)
import opt11p3_replay as rp # noqa: E402
import opt20_scen as sc # noqa: E402
from app import modetrade, packmode, tariff # noqa: E402
from app.maintenance import DRAIN, MaintResult # noqa: E402
fails = []
def check(name, cond):
print(f" {'ok ' if cond else 'FAIL'} {name}")
if not cond:
fails.append(name)
A, B = sc.A, sc.B
MONTH_PEAK = 6000.0
AIM = MONTH_PEAK - 50.0 # the guard's aim this month
DRAIN_R = MaintResult(DRAIN, True, 2000.0, False, [])
def scen(*, a=None, b=None, soc=(49.0, 30.0), house_w=3000.0, peak=MONTH_PEAK,
fc=True, n=2, variant="p3_ch_sell", choice=None, hours=0.75):
"""`a` / `b`: that pack's forced maintenance result (or None). `peak`: the
banked month peak or None. `fc`: a peak forecast entity that follows the
grid. Returns (rows, stats, controller)."""
rows = []
extra = {"cycle_cost_threshold_eur": 0.10}
def patch(c):
for i, res in enumerate((a, b)):
if res is not None and i < len(c.maints):
c.maints[i].tick = (
lambda now, soc_, blocked_by=None, gate_open=True,
res=res: res)
if peak is not None:
orig_peak = c.peak.peak
def peak_(now):
r = orig_peak(now)
return tariff.PeakReading(tariff.OBSERVED,
getattr(r, "month", ""), peak)
c.peak.peak = peak_
orig = c.cycle
susp = []
c._m24_susp = susp
async def cyc():
c.cheap = True
if fc and c.grid is not None:
c.peak_fc = float(c.grid)
await orig()
susp.append(bool(c._maint_shape_suspended))
c.cycle = cyc
def cb(c, h, now, pr):
sh = dict(c.allocation.shares) if c.allocation is not None \
and c.allocation.shares else {}
rows.append(dict(
now=now, grid=h.grid(), shares=sh,
action=getattr(c.arb, "action", None),
reason=getattr(c.arb, "reason", None) or "",
roles=dict(c.mode_tick.roles) if c.mode_tick else {},
why=c.mode_tick.why if c.mode_tick else None,
p={u: p.p for u, p in h.plants.items()}))
stats, c = rp.run(variant, [(sc.UTC0.timestamp() - 10, house_w)], sc.WPTS,
sc.at(2.0), 3600 * hours, check=cb, lag=sc.LAG, n=n,
soc0={"a": soc[0], "b": soc[1]},
choice=choice or sc.CH_CH, refuse=(), patch=patch,
extra=extra)
return rows, stats, c
def mean(rows, u):
r = rows[len(rows) // 6:]
return sum(x["p"][u] for x in r) / len(r)
def worst_quarter(stats):
return max(a[0] / a[1] for a in stats["quarters"].values())
CH = sc.MAINT_CHARGE
# ============================================================================ #
print("1. A in maintenance CHARGE, B a charger in the cheap window")
rows, st, c = scen(a=CH)
ma, mb = mean(rows, "a"), mean(rows, "b")
last = rows[-1] if rows else {}
print(f" A {ma:+.0f} W, B {mb:+.0f} W, worst quarter {worst_quarter(st):.0f}"
f" W, why {last.get('why')}, roles {last.get('roles')}")
check("A charges at (5950 - 3000) / 2 = 1475 W, not 0 or a few hundred W",
-1500.0 <= ma <= -1440.0)
check("B files no grid trade: no trade action in the run, B near 0 W",
all("CHARGE" not in str(r["action"]) for r in rows) and mb > -50.0)
check("roles: B does not charge, and the why is 'cycle'",
all(r["roles"].get(B) != "charge" for r in rows)
and last.get("why") == "cycle")
check("every quarter at or under the month aim",
worst_quarter(st) <= AIM + 1.0)
check("A never gives back while there is no real peak",
max(r["p"]["a"] for r in rows) <= 0.0)
check("the shaping was never paused", not any(c._m24_susp))
# ============================================================================ #
print("\n2. forecast between 3450 W and the month aim; a real peak")
rows2, st2, c2 = scen(a=CH, house_w=3800.0)
ma2 = mean(rows2, "a")
print(f" house 3800: A {ma2:+.0f} W, worst quarter "
f"{worst_quarter(st2):.0f} W")
check("forecast 4900 W (over 3450, under 5950): no pause, A charges "
"(5950 - 3800) / 2 = 1075 W and gives nothing",
not any(c2._m24_susp) and -1100.0 <= ma2 <= -1040.0
and max(r["p"]["a"] for r in rows2) <= 0.0
and worst_quarter(st2) <= AIM + 1.0)
rows3, st3, c3 = scen(a=CH, house_w=6500.0)
print(f" house 6500: paused {sum(c3._m24_susp)}/{len(c3._m24_susp)} "
f"cycles, A max {max(r['p']['a'] for r in rows3):+.0f} W")
check("a real peak (house over the month aim) still pauses the shaping "
"(SAFETY-07)", sum(c3._m24_susp) > len(c3._m24_susp) // 2)
rows4, st4, c4 = scen(a=CH, house_w=3000.0, peak=None)
print(f" no banked peak: A {mean(rows4, 'a'):+.0f} W, worst quarter "
f"{worst_quarter(st4):.0f} W")
check("no banked peak: the aim is cap - margin (3450 W) as before, so A "
"charges (3450 - 3000) / 2 = 225 W, B does not trade, the quarter "
"stays under 3450 W",
-240.0 <= mean(rows4, "a") <= -210.0 and not any(c4._m24_susp)
and all("CHARGE" not in str(r["action"]) for r in rows4)
and worst_quarter(st4) <= 3450.0 + 1.0)
# ============================================================================ #
print("\n3. the mirror: B in maintenance CHARGE, A the charger")
rowsm, stm, cm = scen(b=CH, soc=(30.0, 49.0))
mam, mbm = mean(rowsm, "a"), mean(rowsm, "b")
lastm = rowsm[-1] if rowsm else {}
print(f" A {mam:+.0f} W, B {mbm:+.0f} W, worst quarter "
f"{worst_quarter(stm):.0f} W, why {lastm.get('why')}")
check("B charges at 1475 W, A files no grid trade, why 'cycle'",
-1500.0 <= mbm <= -1440.0 and mam > -50.0
and all("CHARGE" not in str(r["action"]) for r in rowsm)
and lastm.get("why") == "cycle"
and all(r["roles"].get(A) != "charge" for r in rowsm))
check("...every quarter at or under the month aim",
worst_quarter(stm) <= AIM + 1.0)
# ============================================================================ #
print("\n4. modetrade.decide(maint_charging=)")
_runs = SimpleNamespace(on=True, cheap=SimpleNamespace(holds=lambda n: True),
charge_useful=lambda: True, give_at=lambda n: None,
sell=None)
def _dec(packs, **kw):
args = dict(charge_ok=True, sell_ok=True, trade_why=None, price_now=0.1,
headroom_w=3000.0, floor_pct=20.0, ceiling_pct=95.0,
house_w=800.0)
args.update(kw)
return modetrade.decide(_runs, sc.UTC0, packs, **args)
_pa = modetrade.Pack(A, True, packmode.CHEAP_HOURS, False, 2500.0, 50.0, 10.0,
idle=False)
_pb = modetrade.Pack(B, True, packmode.CHEAP_HOURS, False, 2500.0, 30.0, 10.0)
_off = _dec([_pa, _pb])
_on = _dec([_pa, _pb], maint_charging=True)
_dr = _dec([_pa, _pb], draining=True)
check("without it B is the charger (as before)",
_off.action == modetrade.CHARGE and _off.roles[B] == modetrade.CHARGE)
check("with it: no charge, why 'cycle', B keeps a hold role, no ask",
_on.action is None and _on.why == "cycle" and _on.ask_w == 0.0
and _on.roles[B] == modetrade.HOLD)
check("same answer as the SAFETY-78 drain", _on == _dr)
_pr = modetrade.Pack(B, True, packmode.CHEAP_HOURS, False, 2500.0, 30.0, 10.0,
refused=-1, probing=True)
_tp = _dec([_pa, _pr], maint_charging=True)
check("a refusal probe beside the maintenance charge goes on: PROBE_W alone "
"(OPT-20); beside a drain it does not",
_tp.action == modetrade.CHARGE and _tp.ask_w == -modetrade.PROBE_W
and _dec([_pa, _pr], draining=True).action is None)
check("a probe does not carry a normal charger along",
_dec([_pa, _pr, modetrade.Pack("inverter-c", True, packmode.CHEAP_HOURS,
False, 2500.0, 30.0, 10.0)],
maint_charging=True).ask_w == -modetrade.PROBE_W)
check("it files nothing outside a cheap run (why None)",
_dec([_pa, _pb], maint_charging=True,
).why == "cycle" and modetrade.decide(
SimpleNamespace(on=False), sc.UTC0, [_pa, _pb], charge_ok=True,
sell_ok=True, trade_why=None, price_now=0.1, headroom_w=3000.0,
floor_pct=20.0, ceiling_pct=95.0, house_w=800.0,
maint_charging=True).why is None)
# ============================================================================ #
print("\n5. unchanged: N=1 (no forecast entity), the drain, modes off")
d1 = sc.digest(scen(a=CH, n=1, fc=False, peak=None, soc=(49.0, 30.0))[0])
dd = sc.digest(scen(a=DRAIN_R, soc=(60.0, 30.0), peak=None, fc=False)[0])
dm = sc.digest(scen(a=CH, variant="modes_off", peak=None, fc=False)[0])
AT_BASE = {
"n1": "44816d132984ecd64d5a2510223debe102f29decd1d5127ae2b255b45dbf8bd4",
"drain": "8fd86d0816626ee5ae86bc973cb0121b1b5108e56c3b0fdd4b4be6c1f403f748",
"off": "a007f962793611bce15b11f576a76aa52063adcfde82b2a2dc0b0c075b60e60b",
}
got = {"n1": d1, "drain": dd, "off": dm}
for k in AT_BASE:
print(f" {k} {'same' if got[k] == AT_BASE[k] else 'DIFFERS'} "
f"{got[k][:16]}")
check("N=1 with A in maintenance charge and no forecast entity: shares, "
"grid, trade, roles and plant powers equal release/1.0 02eac3b",
got["n1"] == AT_BASE["n1"])
check("the SAFETY-78 drain beside a charger: equal to 02eac3b",
got["drain"] == AT_BASE["drain"])
check("battery modes off: equal to 02eac3b", got["off"] == AT_BASE["off"])
print()
if fails:
print(f"{len(fails)} FAILED:")
for f in fails:
print(f" - {f}")
sys.exit(1)
print("all checks passed")
+162
View File
@@ -0,0 +1,162 @@
"""Runnable check for MAINT-25. `python3 test_maint25.py`
After a failed monthly cycle the add-on waits 7 days (MAINT-13, `backoff_until`).
The Home plan ignored that and drew a cycle at the start hour every night of
the wait. Through the plan builder (`status()` as in test_home.py), N=1 and N=2:
during the back-off no cycle run is drawn and a short line says when it waits
until, in English and Dutch; after 7 days the run is drawn again; a cycle
completed after the failure ends the back-off.
Read MUTATION.md before you report a survivor.
"""
import asyncio
import os
import sys
from datetime import datetime, timedelta, timezone
HERE = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, HERE)
from app import homeview # noqa: E402
from app.main import Controller # noqa: E402
fails = []
def check(name, cond):
print(f" {'ok ' if cond else 'FAIL'} {name}")
if not cond:
fails.append(name)
class _Store:
def __init__(self):
self.data = {}
def set(self, k, v):
self.data[k] = v
def get(self, k, d=None):
return self.data.get(k, d)
def set_time(self, k, v):
self.data[k] = v.isoformat()
def get_time(self, k):
v = self.data.get(k)
return None if v is None else datetime.fromisoformat(v)
class _Pub:
enabled = False
def publish(self, _v):
pass
def close(self):
pass
class _Hass:
session = None
token = ""
async def limits(self, _e):
return (-5000.0, 5000.0, 1.0)
async def number(self, _e, invert=False):
return None
async def state(self, _e):
return None
async def set_number(self, _e, _v):
return True
async def call(self, *_a):
return True
async def states(self):
return []
NOW = datetime(2026, 9, 27, 9, 40, tzinfo=timezone.utc)
ONE = {"setpoint_entity": "number.sp", "meter_entity": "sensor.grid",
"soc_entity": "sensor.soc", "batt_entity": "sensor.batt",
"meter_source": "off", "max_w": 5000, "shadow_mode": "off",
"maintenance_enabled": True, "maintenance_start_hour": 12}
TWO = dict(ONE, inverters=[
{"name": "Battery A", "setpoint_entity": "number.a", "soc_entity":
"sensor.soc_a", "batt_entity": "sensor.batt_a", "max_w": 2500,
"capacity_kwh": 9.6},
{"name": "Battery B", "setpoint_entity": "number.b", "soc_entity":
"sensor.soc_b", "batt_entity": "sensor.batt_b", "max_w": 2500,
"capacity_kwh": 5.4}])
def make(opts, failed=None, done=None):
c = Controller(dict(opts), _Hass(), _Store(), _Pub(), stop=asyncio.Event())
c.auto = True
for inv in c.inverters:
inv.soc, inv.batt, inv.last_write = 50.0, 0.0, 0.0
inv.dev_min, inv.dev_max = -5000.0, 5000.0
c.grid = 10.0
m = c.maints[0]
if failed is not None:
m.store.set_time("last_failed", failed)
if done is not None:
m.store.set_time("last_completed", done)
return c
def plan(c, lang=None):
s = c.status_payload()
s.update(homeview.build(c, level=s["level"], checks=s["checks"], now=NOW,
**({} if lang is None else {"lang": lang})))
p = s["plan"]
return [r for r in p["runs"] if r["kind"] == "cycle"], p["lines"]
D = timedelta(days=1)
print("1. a cycle failed 1 day ago (N=2: Battery A failed, B never ran)")
runs, lines = plan(make(TWO, failed=NOW - D))
print(" ", [r["from"] for r in runs], lines)
check("the run tonight is B's, not A's (A waits out the back-off)",
len(runs) == 1 and not any("Battery A waits its turn" in x for x in lines))
check("a plain line says Battery A waits until 3 October",
any("Battery A: the monthly cycle waits until 3 October." == x
for x in lines))
print("\n2. N=1")
runs1, lines1 = plan(make(ONE, failed=NOW - D))
check("no cycle run is drawn, one line says when it waits until",
runs1 == [] and any("waits until 3 October" in x for x in lines1))
runs1b, lines1b = plan(make(ONE))
check("without a failure the run is drawn (non-vacuous)",
len(runs1b) == 1 and not any("waits until" in x for x in lines1b))
print("\n3. after the 7 days, and after a cycle that completed")
runs2, lines2 = plan(make(ONE, failed=NOW - timedelta(days=7, hours=1)))
check("7 days and an hour after the failure the run is drawn again, no line",
len(runs2) == 1 and not any("waits until" in x for x in lines2))
runs3, lines3 = plan(make(ONE, failed=NOW - D, done=NOW - D / 2))
check("a cycle completed after the failure ends the back-off (the run is "
"not drawn only if it is no longer due)",
not any("waits until" in x for x in lines3))
runs3b, lines3b = plan(make(ONE, failed=NOW - 2 * D, done=NOW - 3 * D))
check("a completion BEFORE the failure does not end it",
runs3b == [] and any("waits until" in x for x in lines3b))
print("\n4. Dutch")
_, lnl = plan(make(ONE, failed=NOW - D), lang="nl")
print(" ", lnl)
check("the Dutch line says it plainly",
any("de maandelijkse cyclus wacht tot 3 oktober" in x for x in lnl))
print()
if fails:
print(f"{len(fails)} FAILED:")
for f in fails:
print(f" - {f}")
sys.exit(1)
print("all checks passed")
+6 -3
View File
@@ -248,11 +248,14 @@ print("\n4. battery modes on, no probe: byte-identical to release/1.0 bf9019e")
# now counts those seconds, so ch_ch's quarters land on 3450.0 W where they
# landed 1.3-1.4 W over it (bf9019e: 15fc25dd...), and ch_ch_maint's first,
# partial quarter charges a little less at its end (bf9019e: e46e3c66...).
# MAINT-24 moved ch_ch_maint again: B no longer grid-charges beside A's
# maintenance charge, and A's charge is no longer paused (release/1.0 02eac3b:
# e56eddab...).
AT_BASE = {
"sf_ch": "422d6578a7decf1ae3749edd1898ff3cd0541d904c95f636cdd9b1de8c1a07c9",
"ch_ch": "2b5879ec95810c39a5f0f82c04b9f8e358ea03ddce4ba187cc2b7e0885dfcbfa",
"ch_ch_maint":
"e56eddabdb785f81793e7afa525f8e6da237b0b2165860aa8e0f8a6499b275a9",
"df86a451a3b2d365ca5d35b772cd1eb8502d164e6b63e6844b5cfb82f15aeb46",
}
_got = sc.no_probe_digests()
for _k in AT_BASE:
@@ -260,8 +263,8 @@ for _k in AT_BASE:
f"{_got[_k][:16]}")
check("with no refusal every share, grid, trade sentence, role and plant "
"power of a scripted cheap run equals bf9019e's (A Solar first, A "
"charging, A in maintenance charge; the last two as SAFETY-125 moved "
"them)", _got == AT_BASE)
"charging, A in maintenance charge; the last two as SAFETY-125 and "
"MAINT-24 moved them)", _got == AT_BASE)
print()
if fails:
+6 -4
View File
@@ -245,14 +245,16 @@ print(f" decide(cap_w={kw(_d, 'cap_w')}, margin_w={kw(_d, 'margin_w')})")
print(f" shaping_suspended(..., {arg(_s, 2)})")
print(f" maintenance_charge_floor(..., {arg(_m, 2)})")
print(f" PeakTracker(cap_w={kw(_t, 'cap_w')})")
# MAINT-24: the maintenance forecast checks get the guard's own aim, cap -
# margin with this month's peak in (`maint_aim`), not the plain cap - margin.
check("test_call_sites: the guard gets the real cap AND the margin; the "
"forecast checks get cap - margin; the month-peak tracker gets the "
"real cap",
"forecast checks get the guard's aim, cap - margin and the month "
"peak (MAINT-24); the month-peak tracker gets the real cap",
len(_dec) == 1 and "peak_cap_w" in kw(_d, "cap_w")
and kw(_d, "margin_w") == "self.peak_margin_w"
and len(_shape) == 1 and len(_maint) == 1
and arg(_s, 2) == "self.peak_aim_w()"
and arg(_m, 2) == "self.peak_aim_w()"
and arg(_s, 2) == "maint_aim" and arg(_m, 2) == "maint_aim"
and "maint_aim = peakguard.quarter_target_w(" in _src
and len(_tracker) == 1
and kw(_t, "cap_w") == 'float(opts.get("peak_cap_w", 3500))')
check("test_aim_w: `peak_aim_w()` is cap - margin, and the forecast sizing "