feat(octopus): configurable minimum-reward threshold for saving-session auto-join - #4595
feat(octopus): configurable minimum-reward threshold for saving-session auto-join#4595chalfontchubby wants to merge 2 commits into
Conversation
… 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>
|
@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 |
|
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>
Summary
Fixes #4593, per gcoan's review
(now tracked as #4595).
The saving-session auto-join loop reads
octopoints_per_kwhonly to compute a display rate, neverto 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_eventsset 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 <= 0guard. gcoan pushed back: thereal root cause is the integration miscategorising events, and a hardcoded skip is the wrong shape
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, default0). An availableevent is only auto-joined when its
octopoints_per_kwhexceeds this threshold - the default of0reproduces the exact behaviour of the original fixed guard (skips<= 0), while raising it letsa user also filter out genuine but low-value sessions.
nullkeeps its existing meaning (rate notreported, 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_eventsloop thatbuilds
octopus_saving_slotsalready requiressaving_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 existingoctopus_saving_session_octopoints_per_pennystate) to every inverter'sapps.yamltemplate.Test plan
test_saving_session_zero_rate_skip(test_saving_session.py) - unaffected, still coverszero/negative/positive/null rates against the default threshold
test_saving_session_min_octopoints_threshold- four sub-cases: default threshold stillallows 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 --quickpasses (743 tests)./run_pre_commitpasses🤖 Generated with Claude Code