fix(octopus): filter saving-session events by target region in Octopus Direct - #4613
Open
chalfontchubby wants to merge 1 commit into
Open
fix(octopus): filter saving-session events by target region in Octopus Direct#4613chalfontchubby wants to merge 1 commit into
chalfontchubby wants to merge 1 commit into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
targetRegion { regionId }to the saving-session events query andsignedUpMeterPoint { 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 whosetargetRegionis non-empty and doesn't include the account's own region.signedUpMeterPointmissing/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 (notargetRegionat all) are never affected either way.Test plan
./run_all --test octopus_url- two new scenarios in the existingget_saving_session_datacoverage: region-mismatch excluded / matching-region and nationwide kept, and the unknown-account-region edge case (region-restricted events excluded, nationwide kept)./run_all --quickpasses./run_pre_commitpasses🤖 Generated with Claude Code