Octopus saving sessions: auto-join toggle and Axle conflict avoidance (#4120)#4128
Merged
Conversation
…ance (#4120) Predbat previously auto-joined every available Octopus saving session unconditionally, with the only opt-out being to remove the octopus_saving_session entry entirely (which also disables battery planning for sessions you do want). - Add octopus_saving_auto_join switch (on by default) to gate auto-join while keeping battery planning for already-joined sessions. - Skip auto-joining any available saving session that overlaps an Axle VPP session, so Predbat never commits to two conflicting events for the same period (Axle takes priority). Axle sessions are now fetched before Octopus sessions and threaded into fetch_octopus_sessions. - Add unit tests for both behaviours and document the new switch. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds user control and safety logic around Octopus Saving Session auto-joining, preventing Predbat from re-enrolling users who have opted out and avoiding overlaps with Axle VPP events (addressing issue #4120). The changes fit into Predbat’s rate/session ingestion path (fetch_sensor_data() → fetch_octopus_sessions()) and the Home Assistant config UI system (CONFIG_ITEMS).
Changes:
- Add a new HA config switch
switch.predbat_octopus_saving_auto_join(default On) to gate Octopus Saving Session auto-joining. - Fetch Axle sessions before Octopus sessions and skip auto-joining any saving session that overlaps an Axle VPP session.
- Add unit tests covering the auto-join toggle and Axle overlap avoidance; document the new behaviour.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
apps/predbat/config.py |
Adds octopus_saving_auto_join switch config item (default True). |
apps/predbat/fetch.py |
Reorders fetching so Axle sessions are available to the Octopus session fetch/join logic. |
apps/predbat/octopus.py |
Implements the auto-join gate and Axle overlap avoidance for available saving sessions. |
apps/predbat/tests/test_saving_session.py |
Adds tests for Axle conflict avoidance and the new auto-join toggle. |
apps/predbat/unit_test.py |
Registers the new saving-session tests in the test runner. |
docs/energy-rates.md |
Documents the new switch and Axle-priority behaviour. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses #4120 — a user who had opted out of Octopus saving sessions was auto-joined back in, and the joined session conflicted with an Axle VPP event.
Previously Predbat auto-joined every available Octopus saving session unconditionally. The only opt-out was to remove the
octopus_saving_sessionentry fromapps.yamlentirely — which also throws away battery planning for sessions you do want to join.This PR adds two complementary controls:
switch.predbat_octopus_saving_auto_join(On by default) — gate auto-join. When Off, Predbat no longer joins available sessions on your behalf, but still plans battery activity for sessions you've already joined.Changes
config.py— newoctopus_saving_auto_joinswitch config item (defaultTrue).fetch.py— fetch Axle sessions before Octopus sessions and pass the list intofetch_octopus_sessions()(safe reorder; Axle fetch has no dependency on the Octopus fetch).octopus.py— gate the auto-join loop on the new switch; add_saving_event_conflicts_axle()half-open interval overlap test and skip conflicting events before joining (without stamping the 2h throttle, so a later cycle can still join if the Axle event disappears).tests/test_saving_session.py— newtest_saving_session_axle_conflictandtest_saving_session_auto_join_toggle, registered inunit_test.py.docs/energy-rates.md— document the new switch and the Axle-priority behaviour.Testing
./run_all -k saving_session— all saving session tests pass (including the two new ones)../run_all -k octopus_and-k axle— pass../run_pre_commit— ruff, black, cspell, markdownlint, and the quick test suite all pass.🤖 Generated with Claude Code