Repository navigation
feat(octopus): add switch to trust Intelligent dispatches in the PV10 scenario - #5632
thewhale21 wants to merge 26 commits into
Conversation
…nario The PV10 scenario assumes every Intelligent dispatch minute more than 30 minutes ahead is withdrawn and prices it at the tariff maximum. That rule has no setting of its own, so pv_metric10_weight carries both the solar hedge and the dispatch-withdrawal risk (GH#5540). A high PV10 weight stops Predbat cycling the battery in a cheap dispatch window that it cycles when the same rate comes from the tariff or manual rates. Add switch.predbat_octopus_intelligent_pv10_dispatch_gone (expert mode, default On, so behaviour is unchanged). Off, neither engine assumes a dispatch is gone in PV10. io_adjusted itself is untouched, as the rate replication, the IOG charge skew and the dynamic dispatch check still need it. The kernel sees the switch through io_flag, so no kernel rebuild or ABI change is needed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UK7LNGFfiNxzmmDLaJ7DkU
…switch feat(octopus): switch to trust Intelligent dispatches in the PV10 sce…
springfall2008
left a comment
There was a problem hiding this comment.
Automated comment from the triage bot.
Reviewed at head commit 48dd132c — a static review of the PR head (cross-repo PR, code read and cross-checked against main, not executed). No findings. What the review verified, since this change gates a rule inside both prediction engines:
- Engine lockstep —
io_flag's only consumer is the PV10 dispatch-gone rule (prediction_kernel.cpp:777), so gating the flag where the array is built (prediction_kernel.py:663-664) is a complete kernel-side gate with no.cpp/ABI/rebuild change, as the PR claims; and lockstep is pinned by the newpv90_import_scenario_pv10_dispatch_gone_offparity case, wheredual_runcompares python vs kernel and kernel vs dispatch-glue, so gating one engine only would fail the test. io_adjusteditself is untouched — the emptied view is a local inrun_predictionwith exactly one consumer (prediction.py:744, PV10-only), so rate replication, the_io_rate_adjustmentskew anddynamic_load_car_strip_feed_rateskeep reading the real dict.- Default On is behaviour-preserving — with the switch On both gate expressions are no-ops, so the existing dispatch-gone tests and the random sweep baseline are unchanged; and
get_ha_config(userinterface.py:549) substitutes theCONFIG_ITEMSdefault when the item is hidden behind expert mode or its value is not yet set, so the default also holds while the entity is unavailable. - Tests fail without the fix —
test_pv10_dispatch_gone_switch's switch-off branch asserts PV10 == nominal on identical series, which only holds with the gating (without it the attribute is undefined and the fallback keeps re-pricing); the switch-On branch has ~9p of headroom at the 10p/50p rates, so it is not a noise assertion. Both new tests restore the switch infinallyand are registered (run_pv90_tests,run_edge_case_testsviarun_kernel_parity_tests). - Docs —
docs/customisation.md:314anddocs/car-charging.md:710follow the sibling switch pattern (entity list + car-charging detail + cross-link) and accurately describe the behaviour; the debug-journal row now points at the switch. NoAPPS_SCHEMAentry is needed — the sibling switches aren't apps.yaml args either.
|
The CI failure is in octopus_url → day_night_rates (“Expected 16 rate entries, got 15”), which this PR doesn’t touch. The test sets my_predbat.now_utc_exact to a fixed 2024 date, but OctopusAPI reads now_utc_exact from ComponentBase, which returns the real clock. The generated night windows span today −2 to +6 days, and that range currently crosses the 25 Oct BST→GMT change. So it should fail on main too until roughly 28 Oct. The tests that ran before it all passed, including kernel_parity, pv90 (with the new switch test), model_kernel and compute_metric. |
Brings springfall2008#5632 up to date. The debug journal entry is re-applied in the compacted format from springfall2008#5988. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closes #5540
What
Adds
switch.predbat_octopus_intelligent_pv10_dispatch_gone(expert mode, default On), which controls the "dispatch assumed gone" rule that #5304 added to the PV10 scenario.io_adjustedminutes more than 30 minutes ahead are priced atmax(rate_max, import_rate).pv_metric10_weightthen hedges only solar/load.This is Option A from the issue. It separates the two roles
pv_metric10_weighthas had since #5304, without removing the hedge that fixed #5392 for anyone who wants it.How
config.py/fetch.py/predbat.py: new switch, read next to the otheroctopus_intelligent_*switches; defaults toTrue.prediction.py:Predictioncopies the switch from the base. With it Off,run_predictionuses an empty local view ofio_adjusted, sodispatch_goneis never set.prediction_kernel.py:io_flagis gated by the same switch when it is populated, so both engines change in lockstep (the trap flagged in triage).io_flag's only consumer is the dispatch-gone rule, so there is no C++ change, ABI bump or kernel rebuild.self.io_adjusteditself is never modified, so rate replication, the IOG charge skew (_io_rate_adjustment) anddynamic_load_car_strip_feed_rates()behave as before.Tests
test_pv90.py: newtest_pv10_dispatch_gone_switch. With the switch On, PV10 costs more than nominal on identical series. With it Off, PV10 equals nominal. In both casesio_adjustedis unchanged.test_kernel_parity.py: a switch-Off PV10 case on thepv90_importprofile (load-dominated, so the withdrawn dispatch moves the metric). I checked it fails if only the Python side is gated.test_dispatch_gone_priced_at_tariff_max, the kernel-paritycar_dispatch_gone*cases,test_pv10_dispatch_gone_never_cheaper_than_the_slot) are unchanged and pass. The default keeps today's behaviour, so therandombaseline anddebug_casesare unchanged.Docs
docs/customisation.md: switch added to the car-charging entity list.docs/car-charging.md: explains why a highpv_metric10_weightcan block cycling in dispatch windows, and what the switch does.tools/debug-journal.md: GH#5540 entry updated to point at the switch.Not included
Option B (not assuming a dispatch is gone once the car is confirmed charging in it) is left as a possible follow-up. It changes default behaviour, so it seemed better as a separate discussion.