Skip to content

fix(octopus): filter saving-session events by target region in Octopus Direct - #4613

Open
chalfontchubby wants to merge 1 commit into
mainfrom
fix/octopus-direct-saving-session-region-filter
Open

fix(octopus): filter saving-session events by target region in Octopus Direct#4613
chalfontchubby wants to merge 1 commit into
mainfrom
fix/octopus-direct-saving-session-region-filter

Conversation

@chalfontchubby

Copy link
Copy Markdown
Collaborator

Summary

Fixes #4612. Predbat's own "Octopus Energy Direct" GraphQL client (the direct-to-Octopus connection method, separate from BottleCapDave's HA integration) never requested or filtered on region eligibility for saving sessions, so it would attempt to auto-join events the account's own region doesn't qualify for. Some saving sessions are only valid for specific NESO grid regions - Octopus's API still lists them as "available" to every account regardless of region - so joining one triggers OE-1308: Account's region is outside of the target regions for this event.

This is the same root cause BottleCapDave hit and fixed in their integration back in v18.3.0 (BottlecapDave/HomeAssistant-OctopusEnergy#1737) - their fix never reached Predbat's Direct client since it's a fully separate, independent code path.

  • Added targetRegion { regionId } to the saving-session events query and signedUpMeterPoint { regionId } to the account query (both confirmed against Octopus's live GraphQL schema via introspection, not guessed).
  • get_saving_session_data() now skips any available event whose targetRegion is non-empty and doesn't include the account's own region.
  • An unknown account region (signedUpMeterPoint missing/null) excludes region-restricted events rather than assuming eligibility - a wasted/rejected join attempt is exactly the failure mode this is meant to avoid. Nationwide events (no targetRegion at all) are never affected either way.

Test plan

  • ./run_all --test octopus_url - two new scenarios in the existing get_saving_session_data coverage: region-mismatch excluded / matching-region and nationwide kept, and the unknown-account-region edge case (region-restricted events excluded, nationwide kept)
  • ./run_all --quick passes
  • ./run_pre_commit passes

🤖 Generated with Claude Code

…s Direct

Predbat's own Direct GraphQL client (as opposed to BottleCapDave's HA
integration) never requested or filtered on region eligibility, so it
would attempt to auto-join saving-session events the account's own
region doesn't qualify for - the same OE-1308 "Account's region is
outside of the target regions for this event" rejection BottleCapDave
hit and fixed in v18.3.0 (BottlecapDave/HomeAssistant-OctopusEnergy#1737).

Adds targetRegion to the events query and signedUpMeterPoint.regionId
to the account query, then skips any available event whose
targetRegion is non-empty and doesn't include the account's own
region. An unknown account region (signedUpMeterPoint missing/null)
excludes region-restricted events rather than assuming eligibility,
since a wasted/rejected join attempt is the exact failure mode this
is meant to avoid; nationwide events (no targetRegion at all) are
never affected.

Fixes #4612

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.

Octopus Direct: saving-session join doesn't filter events by target region (same cause as BCD's #1737)

1 participant