Skip to content

feat(octopus): configurable minimum-reward threshold for saving-session auto-join - #4595

Open
chalfontchubby wants to merge 2 commits into
mainfrom
fix/saving-session-zero-rate-join-guard
Open

feat(octopus): configurable minimum-reward threshold for saving-session auto-join#4595
chalfontchubby wants to merge 2 commits into
mainfrom
fix/saving-session-zero-rate-join-guard

Conversation

@chalfontchubby

@chalfontchubby chalfontchubby commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #4593, per gcoan's review
(now tracked as #4595).

The saving-session auto-join loop reads octopoints_per_kwh only to compute a display rate, never
to decide whether the event is worth joining, so a zero-point event is join-attempted exactly like
a real one. This matters today because the Octopus integration currently puts national Power Up
(free electricity) events into the Power Down available_events set at 0 p/kWh - described in
#4548 point 5 and BottlecapDave/HomeAssistant-OctopusEnergy#1820.
Predbat tries to join each one and the integration rejects it, and since the join result isn't
checked (#4548 point 8, separate issue, not touched here) each rejected attempt still fires a false
"joined" notification.

An earlier version of this PR added a fixed octopoints_kwh <= 0 guard. gcoan pushed back: the
real root cause is the integration miscategorising events, and a hardcoded skip is the wrong shape

  • a user may also want to skip a genuine, low-value Power Down session they don't consider worth
    the disruption, not just the zero-reward ones. He suggested a configurable minimum-value threshold
    instead, defaulting to today's unfiltered-at-zero behaviour.

Fix

Adds octopus_saving_session_min_octopoints_per_kwh (apps.yaml, default 0). An available
event is only auto-joined when its octopoints_per_kwh exceeds this threshold - the default of
0 reproduces the exact behaviour of the original fixed guard (skips <= 0), while raising it lets
a user also filter out genuine but low-value sessions. null keeps its existing meaning (rate not
reported, default rate applies) and is never checked against the threshold - only an explicit
reported rate is gated.

This mirrors an invariant that already existed on the planning side: the joined_events loop that
builds octopus_saving_slots already requires saving_rate > 0. The guard was simply missing (and,
at the fixed value, insufficiently flexible) on the join side.

Documented in docs/energy-rates.md, and added (commented or not, matching each template's existing
octopus_saving_session_octopoints_per_penny state) to every inverter's apps.yaml template.

Test plan

  • test_saving_session_zero_rate_skip (test_saving_session.py) - unaffected, still covers
    zero/negative/positive/null rates against the default threshold
  • New test_saving_session_min_octopoints_threshold - four sub-cases: default threshold still
    allows a moderate reward, a raised threshold blocks a lower reward, a raised threshold still
    allows a reward that exceeds it, and a reward exactly equal to the threshold is skipped
    (exceeds, not meets)
  • ./run_all --quick passes (743 tests)
  • ./run_pre_commit passes

🤖 Generated with Claude Code

… joining (#4593)

The auto-join loop read octopoints_per_kwh only to compute a display rate,
never to decide whether the event was worth joining, so a zero-point event
was join-attempted exactly like a real one. This matters now because the
Octopus integration puts national Power Up (free electricity) events into
the Power Down available_events set at 0 p/kWh (#4548 point 5), so each one
gets joined, rejected, and still fires a false "joined" notification.

Adds a guard matching the existing Axle-conflict skip in the same loop:
octopoints_kwh <= 0 skips with a log line and continue, before the join
attempt. null keeps its existing meaning (rate not reported, default
applies) - only an explicit non-positive rate is skipped. Mirrors the
planning side's own saving_rate > 0 requirement in the joined_events loop
that builds octopus_saving_slots - that check already existed, it just
wasn't shared with the join side.

New test_saving_session_zero_rate_skip covers zero, negative, positive and
null rates.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@gcoan

gcoan commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

@chalfontchubby see my comment on the original issue.

I don't think a guard on octopoints rate being zero is correct and the premise for it causing session join rejections is incorrect.

I proposed a better more flexible solution

@chalfontchubby

Copy link
Copy Markdown
Collaborator Author

@chalfontchubby see my comment on the original issue.

I don't think a guard on octopoints rate being zero is correct and the premise for it causing session join rejections is incorrect.

I proposed a better more flexible solution

Ok - happy to leave it to you

@gcoan

gcoan commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Hi Rik @chalfontchubby I'm more than happy for you to make the code changes, I could make them, but I'm nowhere near as familiar with the automated test framework so I'd struggle with that part

My suggestion on #4593 was to deliver the filter the OP suggested by a configurable 'min saving session amount'. Perhaps in the future Octopus will do zero value saving sessions; the Eclipse saving session was almost that !; and by having a configurable threshold then predbat users can choose what S/S to autojoin based on battery cycle cost, charge/discharge losses, etc.

…le threshold

Per gcoan's #4593 review (now tracked as #4595): a fixed octopoints_kwh <= 0
guard correctly stops the integration's mis-categorised zero-reward Power Up
events from being join-attempted, but a user may also want to skip genuine,
low-value Power Down sessions they don't consider worth the disruption.

Adds octopus_saving_session_min_octopoints_per_kwh (apps.yaml, default 0),
join proceeds only when octopoints_per_kwh exceeds it. Default 0 reproduces
the exact prior behaviour (skip <=0). None still means "rate not reported,
default rate applies" and is never checked against the threshold.

Documented in energy-rates.md and added to every inverter template's
apps.yaml alongside the existing octopoints_per_penny setting, matching
each template's own commented/uncommented state (kostal.yaml and sofar.yaml
edited in binary mode to preserve their CRLF line endings).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@chalfontchubby chalfontchubby changed the title fix(octopus): skip a zero/negative reward saving-session event before joining feat(octopus): configurable minimum-reward threshold for saving-session auto-join Aug 20, 2026
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.

Saving-session auto-join has no rate guard, so zero-point events are join-attempted and rejected

2 participants