Skip to content

Octopus: move to the new API domain, api.oegb-kraken.energy (#5786) - #5799

Open
chalfontchubby wants to merge 12 commits into
mainfrom
fix/octopus-domain-5786
Open

chalfontchubby wants to merge 12 commits into
mainfrom
fix/octopus-domain-5786

Conversation

@chalfontchubby

@chalfontchubby chalfontchubby commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Opened by Claude on Rik's behalf.

Closes #5786

Octopus is moving its public API from api.octopus.energy to api.oegb-kraken.energy. Both are live now, and the old domain will be switched off "in a few months" (Octopus forum, 29 Sep). This PR moves Predbat to the new domain. It also keeps existing configs working after the switch-off, so users don't have to edit anything first.

What changes

  • Predbat's own calls go to the new domain through one constant, OCTOPUS_API_URL in const.py. That covers the Octopus Direct component (REST and GraphQL), the annual tariff catalogue and annual consumption.
  • Migration, as gcoan suggested on the issue. A rates_import_octopus_url / rates_export_octopus_url, compare tariff or annual tariff that still names api.octopus.energy is rewritten to the new domain when it is fetched (utils.migrate_octopus_url).
    • A Warn: line, given once per URL, asks the user to update apps.yaml.
    • Rates cached under the old URL carry over, so a failed first download after the upgrade still falls back to them.
    • Saved annual runs that name the old domain still match their catalogue entry.
    • Paginated downloads stay on the new host. Its responses still link page 2 onwards on api.octopus.energy, so each next link is rewritten as well. That covers the rate downloads, annual tariff and annual consumption.
  • Saving sessions stay on api.backend.octopus.energy. It has no new-domain equivalent: a savingSessions query returns 400 on api.oegb-kraken.energy, and api.backend.oegb-kraken.energy doesn't resolve.
  • Docs, examples and templates. energy-rates.md, compare.md, apps-yaml.md, the annual docs, the example apps.yaml and the templates now point at the new domain. The rates and compare pages say that old URLs keep working, and that users should change them anyway.

Evidence

Read-only checks with a real account key, run on 27 Oct:

  • /v1/accounts/ (basic auth), obtainKrakenToken and GraphQL viewer queries all work on the new domain.
  • A token minted on either domain is accepted by both, with or without the JWT prefix, so no new API key is needed.
  • A token minted on the new domain works for savingSessions on api.backend.octopus.energy.

Unauthenticated checks on 28 Oct, using the exact query strings in octopus.py:

  • REST rates, standing charges and products return the same results on both hosts.
  • The account, device, dispatch, settings and flexibility-campaign queries all pass schema validation on the new host and stop only at the auth check.
  • Paginated responses from the new host give next links on the old host.

Risk

  • Every Octopus fetch moves host in one go, with no fallback to the old domain. The live checks above showed the new host answering everything Predbat asks of it.
  • Changing the URL-derived cache keys costs one refetch. The old Octopus rate cache entries carry over, as described above.

Tests

  • New octopus_domain test covering:

    • the rewrite rules, including a port, a fragment, look-alike hosts, the backend host and non-strings;
    • the client hosts;
    • a download with an old URL: it fetches from the new domain, warns once and keeps the old cache entry as its fallback;
    • annual URL resolution with {dno_region};
    • catalogue matching in both directions;
    • a page-2 next link on the old host fetched from the new one. Existing pagination tests for the async, annual tariff and annual consumption downloads cover this too.

    It fails on main.

  • Existing fixtures were moved to the new domain.

  • ./run_all --quick and run_pre_commit pass.

🤖 Generated with Claude Code

chalfontchubby and others added 3 commits October 27, 2026 21:37
…5786)

Octopus is moving its public API from api.octopus.energy to
api.oegb-kraken.energy. Both are live now, and the old one will be
switched off in a few months.

- Predbat's own requests (the Octopus component, the annual tariff
  catalogue and annual consumption) now go to the new domain, through
  one constant in const.py.
- A rates_import/export_octopus_url, compare tariff or annual tariff
  that still names api.octopus.energy is rewritten to the new domain
  when it is fetched, with a log line asking for apps.yaml to be
  updated. Existing configs keep working after the switch-off.
- Saved annual runs naming the old domain still match their catalogue
  entry.
- Saving sessions stay on api.backend.octopus.energy. It has no new-
  domain equivalent: savingSessions returns 400 on the new domain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Update the Octopus product URLs in the docs, the example apps.yaml and
the templates to the new API domain. The rates and compare pages say
that old-domain URLs keep working, because Predbat rewrites them, and
that users should change them anyway.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ates (#5786)

- The "please update apps.yaml" notice is now a Warn, given once per
  URL rather than on every 5-minute cycle.
- Rates cached under the old address before the upgrade move to the
  new one, so a failed first download after the upgrade still falls
  back to them rather than raising.
- An old-domain URL with an explicit port or a fragment is rewritten
  too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chalfontchubby chalfontchubby added ExternalChange Something outside Predbat has changed Octopus labels Oct 27, 2026
@chalfontchubby chalfontchubby self-assigned this Oct 27, 2026
@github-actions github-actions Bot added the BOT_REVIEW Trigger an autotriage label Oct 27, 2026

@springfall2008 springfall2008 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated comment from the triage bot.

Review of head a5b6016 (Octopus domain move to api.oegb-kraken.energy, closes #5786): the change is sound. Traced every path a user-supplied Octopus URL can reach — fetch.py import/export rates (fetch.py:1500, fetch.py:1584), compare.py export entries (compare.py:258), the annual engine's _resolve_url (annual_tariff.py:117) and the catalogue matching on both sides (match_entry, tariff_catalogue.py:216-221, which migrates both the saved run and the catalogue entry, so a saved run naming the old address still re-selects its dropdown entry) — all funnel through migrate_octopus_url. Predbat's own URLs all build from OCTOPUS_API_URL; no live code path in apps/predbat still names the old host, and templates/docs/apps.yaml/coverage fixtures are URL-only swaps (scanned every changed line for smuggled-in changes). The cache carry-over plus warn-once in download_octopus_rates is covered by test_octopus_domain, registered in TEST_REGISTRY as a non-slow test, and the migration regex's edge cases (look-alike hosts, ports, embedded next= links, non-strings) are covered. Saving/free sessions stay on api.backend.octopus.energy as documented. 2 low findings inline, 0 in the body.

Comment thread apps/predbat/const.py Resolved
Comment thread docs/energy-rates.md Resolved
@springfall2008 springfall2008 removed the BOT_REVIEW Trigger an autotriage label Oct 27, 2026
chalfontchubby and others added 3 commits October 28, 2026 22:04
… URL

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The new host's paginated responses still link further pages on
api.octopus.energy, so page 2 onwards of a rate or consumption download
went back to the old host and would fail once it is retired. Run each
next link through migrate_octopus_url() in the four places that follow
one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…wnloads

150438d tested only the sync rate download. Point the existing
pagination fixtures for the async OctopusAPI download, the annual tariff
and the annual consumption download at the old host, and check page 2 is
fetched from the new one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chalfontchubby

Copy link
Copy Markdown
Collaborator Author

Posted by Claude on behalf of @chalfontchubby.

Two commits added since the bot review:

  • 150438d: paginated downloads now stay on the new host. Live checks show api.oegb-kraken.energy still returns next links on api.octopus.energy, so page 2 onwards of a rate download was going back to the old host. That works today but would fail once the old host is retired. Each next link is now passed through migrate_octopus_url() in the four places that follow one: the sync and async rate downloads, the annual tariff download and the annual consumption download.
  • a20ef0a: tests. A new case in octopus_domain covers the sync download. The existing pagination fixtures for the other three downloads now link page 2 on the old host and check it is fetched from the new one. Each check fails without 150438d.

I've updated the PR description to match.

chalfontchubby and others added 4 commits November 9, 2026 22:03
Conflicts in octopus.py only: kept main's session factory and imports
alongside this branch's OCTOPUS_API_URL constants.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
solis_local.yaml arrived on main (#6088) after this branch moved every other
template to the new Octopus API domain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main replaced requests with http_sync (#6153), so octopus.requests no longer exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chalfontchubby

Copy link
Copy Markdown
Collaborator Author

Posted by Claude on behalf of @chalfontchubby.

Live test on a real install: the new domain works for Octopus Direct, saving sessions and tariff comparison. The annual tariff path has not run yet.

Setup. The PR branch was merged with current main (it merges cleanly) and deployed to a Home Assistant install. That install uses Octopus Direct (account and API key) on Intelligent Octopus Go, joins saving sessions, and has a 12-entry compare_list whose rates_import_octopus_url / rates_export_octopus_url entries all still name api.octopus.energy. Its apps.yaml was not changed.

Octopus Direct. From the first cycle, every account query went to api.oegb-kraken.energy and returned 200: devices, device status, dispatches, intelligent settings and flexibility campaign events. Responses were identical to the ones logged before the upgrade on the old host. No request went to api.octopus.energy.

Saving sessions. The savingSessions query stayed on api.backend.octopus.energy and the sessions were loaded as before.

Compare. A manual compare run:

  • each of the 11 distinct old-domain URLs logged one Warn: ... uses the old Octopus API address line and was downloaded from api.oegb-kraken.energy;
  • a URL used by two tariffs was served from the cache under its new-domain key the second time;
  • all 12 tariffs completed with no errors.

As a cross-check, fetching four of those products' rates directly from both hosts gave identical results.

Not covered. The annual tariff and annual consumption downloads did not run during the test.

🤖 Generated with Claude Code

@chalfontchubby

chalfontchubby commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator Author

Posted by Claude on behalf of @chalfontchubby.

Confirmed working live, so I've removed NEEDS_LIVE_TEST.

Since the test described above, the same install has run this branch for about 19 hours, overnight included. Over that time every Octopus Direct call went to api.oegb-kraken.energy: the hourly tariff-agreement and consumption-measurement queries as well as the intelligent dispatch ones. The only Octopus errors were intermittent GraphQL Device status could not be fetched / Unable to fetch planned dispatches responses (HTTP 200 with an errors body), which Predbat handled by reusing its last known settings and dispatches. They are not new: the same install logged them at the same rate or more often on the old domain in the days before the switch.

The annual tariff tool was not exercised. It only runs on demand from the /annual page or the CLI, and its URL migration is covered by the unit tests.

🤖 Generated with Claude Code

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ExternalChange Something outside Predbat has changed Octopus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Octopus domain change

2 participants