feat(octopus): Power Up/Power Down migration - join service and entity regex (points 2 & 3 of #4548) - #4601
feat(octopus): Power Up/Power Down migration - join service and entity regex (points 2 & 3 of #4548)#4601chalfontchubby wants to merge 3 commits into
Conversation
…ed one Bottle Cap Dave's Octopus Energy integration renamed join_octoplus_saving_session_event to join_octoplus_power_down_session_event (ADR-0004). Both remain registered until the old one is retired in January 2027, so try the new name first and fall back to the old one on failure. Part of #4548 (point 3). TODO(#4599) tracks removing the fallback once the old service name is gone upstream.
…r Down/Up rename Octopus Energy integration v19.0.0 renamed the saving-session and free-electricity event entities to Power Down and Power Up (event.octopus_energy_ACCOUNT_ID_octoplus_power_down_events / ..._power_up_events). Both old and new entities remain registered until January 2027 (ADR-0004), and resolve_arg_re()'s regex matching against HA state keys is a one-off startup resolution, so broadening the 're:' alternation to match either name is enough - no runtime try-new-then-old logic is needed here, unlike the join service rename in point 3. Updates the octopus_saving_session/octopus_free_session regex in apps.yaml (default, coverage test fixture, and all 23 inverter templates that configure them), plus docs/energy-rates.md to mention the rename, the entity_registry_enabled_default=False gotcha, and the January 2027 cutoff. Part of #4548 (point 2). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR updates Predbat’s Octopus Energy integration handling to support the Octopus v19.0.0 rename of Saving Sessions/Free Electricity sessions to Power Down/Power Up, while maintaining compatibility with the deprecated names through the upstream deprecation window (until Jan 2027).
Changes:
- Updates the saving-session auto-join service call to try
octopus_energy/join_octoplus_power_down_session_eventfirst, with fallback to the deprecated.../join_octoplus_saving_session_event. - Broadens
apps.yaml-stylere:entity match patterns across templates and fixtures to match both legacy and new Power Down/Up event entity names. - Updates documentation and adds/extends unit tests covering the service fallback and regex matching.
Reviewed changes
Copilot reviewed 29 out of 30 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| templates/teslemetry.yaml | Broaden saving-session entity re: pattern to include Power Down. |
| templates/tesla_powerwall.yaml | Broaden saving-session entity re: pattern to include Power Down. |
| templates/sunsynk.yaml | Broaden saving/free session entity re: patterns to include Power Down/Up. |
| templates/solis_cloud.yaml | Broaden saving/free session entity re: patterns to include Power Down/Up. |
| templates/solax_sx4.yaml | Broaden saving/free session entity re: patterns to include Power Down/Up. |
| templates/solax_cloud.yaml | Broaden saving/free session entity re: patterns to include Power Down/Up. |
| templates/solaredge.yaml | Broaden saving/free session entity re: patterns to include Power Down/Up. |
| templates/solar_assistant_growatt_sph.yaml | Broaden saving-session entity re: pattern to include Power Down. |
| templates/solar_assistant_growatt_spa.yaml | Broaden saving-session entity re: pattern to include Power Down. |
| templates/sofar.yaml | Broaden saving/free session entity re: patterns to include Power Down/Up. |
| templates/sofar_modbus.yaml | Broaden saving-session entity re: pattern to include Power Down. |
| templates/sigenergy_sigenstor.yaml | Broaden saving-session entity re: pattern to include Power Down. |
| templates/sigenergy_cloud.yaml | Broaden saving/free session entity re: patterns to include Power Down/Up. |
| templates/luxpower.yaml | Broaden saving/free session entity re: patterns to include Power Down/Up. |
| templates/kostal.yaml | Update commented free-session entity re: pattern to include Power Up. |
| templates/givenergy_givtcp.yaml | Broaden saving/free session entity re: patterns to include Power Down/Up. |
| templates/givenergy_ems.yaml | Broaden saving/free session entity re: patterns to include Power Down/Up. |
| templates/givenergy_cloud.yaml | Broaden saving/free session entity re: patterns to include Power Down/Up. |
| templates/ginlong_solis.yaml | Broaden saving/free session entity re: patterns to include Power Down/Up. |
| templates/fronius.yaml | Broaden saving/free session entity re: patterns to include Power Down/Up. |
| templates/fox.yaml | Broaden saving/free session entity re: patterns to include Power Down/Up. |
| templates/fox_cloud.yaml | Broaden saving/free session entity re: patterns to include Power Down/Up. |
| templates/enphase_cloud.yaml | Broaden saving/free session entity re: patterns to include Power Down/Up. |
| docs/energy-rates.md | Document the Power Down/Up rename, Jan 2027 cutoff, and entity-default-disabled nuance; update example regexes. |
| coverage/apps.yaml | Update fixture commented free-session entity re: pattern to include Power Up. |
| apps/predbat/config/apps.yaml | Update default template regexes to match legacy + Power Down/Up entities. |
| apps/predbat/octopus.py | Implement join-service “try new then fallback to old” logic. |
| apps/predbat/tests/test_infra.py | Add service_store_fail + change stored service-call return behavior for tests. |
| apps/predbat/tests/test_saving_session.py | Update expected join service + add tests for service fallback and entity-regex rename coverage. |
| apps/predbat/unit_test.py | Register the new saving-session tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| # Join via Bottle Cap Dave's Octopus Energy HA integration. Try the current | ||
| # service name first (join_octoplus_power_down_session_event, which | ||
| # superseded join_octoplus_saving_session_event - see the integration's | ||
| # ADR-0004), falling back to the old name for anyone on an integration | ||
| # version that predates the rename. Both remain registered until the old | ||
| # one is removed in January 2027, so this fallback is a temporary bridge, | ||
| # not a permanent branch. | ||
| # TODO(#4599): remove this fallback once the old service name is retired upstream. | ||
| if not self.call_service_wrapper("octopus_energy/join_octoplus_power_down_session_event", event_code=code, entity_id=entity_id): | ||
| self.log("Note: octopus_energy/join_octoplus_power_down_session_event not available, falling back to the deprecated join_octoplus_saving_session_event service") | ||
| self.call_service_wrapper("octopus_energy/join_octoplus_saving_session_event", event_code=code, entity_id=entity_id) |
| def call_service(self, service, **kwargs): | ||
| print("Calling service: {} {}".format(service, kwargs)) | ||
| if self.service_store_enable: | ||
| self.service_store.append([service, kwargs]) | ||
| return None | ||
| # Services in service_store_fail simulate a service that doesn't exist (e.g. testing a | ||
| # try-new-service-then-fall-back-to-old caller) - everything else succeeds, matching real | ||
| # HA behaviour for a registered service call. | ||
| return None if service in self.service_store_fail else True |
async_call_service_websocket_command() returned None for a successful call when return_response wasn't requested - identical to its failure return value. This made the point-3 join-service fallback in octopus.py (dabf8a7) fire on every call regardless of whether the new service actually succeeded, double-calling the deprecated service on top of a working one. TestHAInterface's call_service() already returned True on success, masking the bug in tests. Checked every other call_service/call_service_wrapper call site (inverter.py, userinterface.py, web.py, predbat.py) - none branch on the return value's truthiness, so this is safe. Copilot review finding on PR #4601. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Review:
|
Summary
Octopus Energy integration v19.0.0 renamed saving sessions/free electricity events to Power Down/Power Up (see #4548, points 2 & 3). This covers the two mechanical renames:
octopus_energy/join_octoplus_power_down_session_eventfirst, falling back to the deprecatedjoin_octoplus_saving_session_eventif the current one isn't available (e.g. an older integration version).octopus_saving_session/octopus_free_sessionre:entity-matching patterns inapps.yaml(default template, coverage test fixture, and all 23 inverter templates that set these keys) are broadened to match both the deprecated and new (Power Down/Power Up) entity names in one alternation. This is a one-off startup regex resolution (resolve_arg_re()), not a per-cycle call, so no runtime try-new-then-old logic is needed here (unlike point 3's service call).Both old and new entities/services remain registered by BottleCapDave's integration until January 2027 (ADR-0004), so this is non-breaking for anyone still on the old names.
docs/energy-rates.mdupdated to mention the rename, the January 2027 cutoff, and that the new entities shipentity_registry_enabled_default: False(so users need to enable them in the HA UI, or Predbat's regex will just keep quietly matching the old entity with no visible sign anything changed).Filed #4599 as the tracking issue for removing the point-3 fallback once the old service name is retired upstream (not before Jan 2027); the point-3 fallback in
octopus.pycarries aTODO(#4599)comment.Test plan
./run_all --quickpassestest_saving_session_join_service_fallback(point 3): current service succeeds → no fallback; current service fails → falls back to deprecated servicetest_saving_session_entity_regex_power_rename(point 2):resolve_arg_re()matches deprecated entity names, matches new Power Down/Power Up entity names, and does not cross-match Power Up against the saving-session pattern or vice versa./run_pre_commitpasses (ruff, black, cspell, markdownlint, etc.)🤖 Generated with Claude Code