Skip to content

feat(octopus): add switch to trust Intelligent dispatches in the PV10 scenario - #5632

Open
thewhale21 wants to merge 26 commits into
springfall2008:mainfrom
thewhale21:main
Open

thewhale21 wants to merge 26 commits into
springfall2008:mainfrom
thewhale21:main

Conversation

@thewhale21

Copy link
Copy Markdown
Contributor

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.

  • On (default): behaviour unchanged. In PV10, io_adjusted minutes more than 30 minutes ahead are priced at max(rate_max, import_rate).
  • Off: neither engine assumes a dispatch is gone in PV10, so a dispatch window plans like the same rate from the tariff or manual rates. pv_metric10_weight then hedges only solar/load.

This is Option A from the issue. It separates the two roles pv_metric10_weight has 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 other octopus_intelligent_* switches; defaults to True.
  • prediction.py: Prediction copies the switch from the base. With it Off, run_prediction uses an empty local view of io_adjusted, so dispatch_gone is never set.
  • prediction_kernel.py: io_flag is 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_adjusted itself is never modified, so rate replication, the IOG charge skew (_io_rate_adjustment) and dynamic_load_car_strip_feed_rates() behave as before.

Tests

  • test_pv90.py: new test_pv10_dispatch_gone_switch. With the switch On, PV10 costs more than nominal on identical series. With it Off, PV10 equals nominal. In both cases io_adjusted is unchanged.
  • test_kernel_parity.py: a switch-Off PV10 case on the pv90_import profile (load-dominated, so the withdrawn dispatch moves the metric). I checked it fails if only the Python side is gated.
  • Existing dispatch-gone tests (test_dispatch_gone_priced_at_tariff_max, the kernel-parity car_dispatch_gone* cases, test_pv10_dispatch_gone_never_cheaper_than_the_slot) are unchanged and pass. The default keeps today's behaviour, so the random baseline and debug_cases are unchanged.

Docs

  • docs/customisation.md: switch added to the car-charging entity list.
  • docs/car-charging.md: explains why a high pv_metric10_weight can 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.

thewhale21 and others added 2 commits October 19, 2026 08:55
…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…
@github-actions github-actions Bot added the BOT_REVIEW Trigger an autotriage label Oct 19, 2026

@springfall2008 springfall2008 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 new pv90_import_scenario_pv10_dispatch_gone_off parity case, where dual_run compares python vs kernel and kernel vs dispatch-glue, so gating one engine only would fail the test.
  • io_adjusted itself is untouched — the emptied view is a local in run_prediction with exactly one consumer (prediction.py:744, PV10-only), so rate replication, the _io_rate_adjustment skew and dynamic_load_car_strip_feed_rates keep 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 the CONFIG_ITEMS default 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 in finally and are registered (run_pv90_tests, run_edge_case_tests via run_kernel_parity_tests).
  • Docs — docs/customisation.md:314 and docs/car-charging.md:710 follow 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. No APPS_SCHEMA entry is needed — the sibling switches aren't apps.yaml args either.

@springfall2008 springfall2008 removed the BOT_REVIEW Trigger an autotriage label Oct 19, 2026
@thewhale21

Copy link
Copy Markdown
Contributor Author

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Metric 10 weighting on IOG Dispatches Plan fails to schedule house battery to charge at same time as car since 9.3.4 (overnight or IOG extra slots)

2 participants