Skip to content

Octopus saving sessions: auto-join toggle and Axle conflict avoidance (#4120)#4128

Merged
springfall2008 merged 2 commits into
mainfrom
feat/overlap_axle
Jun 26, 2026
Merged

Octopus saving sessions: auto-join toggle and Axle conflict avoidance (#4120)#4128
springfall2008 merged 2 commits into
mainfrom
feat/overlap_axle

Conversation

@springfall2008

Copy link
Copy Markdown
Owner

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_session entry from apps.yaml entirely — which also throws away battery planning for sessions you do want to join.

This PR adds two complementary controls:

  1. 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.
  2. Axle conflict avoidance — when auto-join is On, Predbat skips any available saving session that overlaps (any time overlap) an Axle VPP session, so it never commits to two conflicting events for the same period. The Axle session takes priority.

Changes

  • config.py — new octopus_saving_auto_join switch config item (default True).
  • fetch.py — fetch Axle sessions before Octopus sessions and pass the list into fetch_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 — new test_saving_session_axle_conflict and test_saving_session_auto_join_toggle, registered in unit_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

…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>
Copilot AI review requested due to automatic review settings June 25, 2026 07:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread apps/predbat/octopus.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@springfall2008 springfall2008 merged commit 4fc0ebc into main Jun 26, 2026
1 check passed
@springfall2008 springfall2008 deleted the feat/overlap_axle branch June 26, 2026 11:05
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.

2 participants