Conversation
1cd055d to
e5a2717
Compare
|
|
There was a problem hiding this comment.
🟡 Changes recommended
The new lead-hours auto-join behavior needs unit test coverage (and there is also a small docs grammar fix to apply).
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds a new user-configurable “lead time” for Octopus Saving Session auto-join so Predbat can delay joining until closer to the event start, reducing the chance of later-announced conflicts (e.g., Axle short-notice events).
Changes:
- Introduces
octopus_saving_auto_join_lead_hoursconfiguration (0–12 hours) gated byoctopus_saving_auto_join. - Updates Octopus saving-session auto-join logic to skip joining until within the configured lead window.
- Documents the new option and its rationale in the energy rates documentation.
File summaries
| File | Description |
|---|---|
| docs/energy-rates.md | Documents the new lead-hours behavior for saving-session auto-join. |
| apps/predbat/octopus.py | Adds lead-time gating before attempting to auto-join available saving sessions. |
| apps/predbat/config.py | Adds a new input_number config item for lead hours, enabled when auto-join is on. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This will be used to configure how soon Predbat is allowed to join a saving session event before the start of the event (default 0 = join immediately).
Add a check to ensure that if the lead hours configuration has been set to non-zero, that we do not try to join a given saving session until we are within the specified number of hours of the session start.
1. Checks that auto-join proceeds when lead_hours is both unset and set to 0 to mimic current default behaviour 2. Checks that auto-join is skipped when we are more than lead_hours before the start of the event 2. Checks that auto-join proceeds when we are less than lead_hours before the start of the event
e5a2717 to
184de07
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The updated saving-session test mutates my_predbat.now_utc without restoring it, which can leak state across the shared test instance and cause order-dependent failures.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (1)
apps/predbat/tests/test_saving_session.py:1175
- The test sets a fixed my_predbat.now_utc earlier but never restores it, which can cause test-order dependence because the suite reuses the same PredBat instance. Restore now_utc alongside the other restored config state.
# Restore default state so we do not leak it to other tests
my_predbat.expose_config("octopus_saving_auto_join", True, quiet=True)
my_predbat.expose_config("octopus_saving_auto_join_lead_hours", 0, quiet=True)
my_predbat.octopus_last_joined_try = None
- Files reviewed: 5/5 changed files
- Comments generated: 2
- Review effort level: Lite
Backup at start and restore at end of test.
Copy-paste error not updated to match actual test.
Should always be the case regardless, but worth adding a test to make sure the lead hours doesn't accidentally cause a join when auto join is disabled.
|
This is ready for review. Doesn't give me the option to request another review from the bot. |


Adds a new configuration option "octopus_saving_auto_join_lead_hours" which allows the user to specify that Predbat should wait until the configured number of hours before the start of a given saving session event before trying to join it.
The default (0) maintains the existing behaviour of auto-joining as soon as an event becomes available.
Setting a positive integer allows specifying that predbat should delay joining the session until the set number of hours before the start of the event.
Fix for #4985.