Skip to content

fix(ohme): take completed Intelligent dispatches from Octopus, planned slots from Ohme - #5443

Open
springfall2008 wants to merge 1 commit into
mainfrom
fix/ohme-planned-octopus-completed-5413
Open

springfall2008 wants to merge 1 commit into
mainfrom
fix/ohme-planned-octopus-completed-5413

Conversation

@springfall2008

Copy link
Copy Markdown
Owner

Draft for maintainer review. Fixes #5413

Summary

On Octopus Intelligent with an Ohme charger, the car slots came only from Ohme. Ohme reports the slots of the charge session in progress and nothing else, so unplugging the car emptied the slots, and the off-peak rate for charging already done was re-priced at day rate in the plan history and cost_today. The reporter's log shows this at every unplug.

This splits the two jobs:

  • New option octopus_intelligent_planned_slot (per car, optional). When set, planned dispatches are read from it and octopus_intelligent_slot supplies the completed ones. Slots the planned sensor reports as already finished are merged in behind the slot sensor's completed list, so a slot is covered from when it ends until Octopus lists it; the existing overlap handling in load_octopus_slots() drops whatever Octopus has by then.
  • Ohme component. On Intelligent it now sets only the planned option, the ready time and the charge limit when octopus_intelligent_slot is already a sensor of Octopus's (wired by the Octopus component, or set in apps.yaml to the Octopus Energy integration's). With no such sensor it supplies everything, as before. It re-checks every poll, so the Octopus component wiring or clearing its sensor is followed without a restart.
  • car_slot_owner now covers the ready time and charge limit only. The Octopus component keeps wiring its dispatch sensor under another component's claim.
  • Leaving Intelligent (tariff change, or every device suspended): the Octopus sensor Ohme was paired with has nothing more to give, so Ohme's own schedule or Predbat-led control takes over as it did before. It is left in place when Octopus is driving another device.

ohme_control is still ignored on Intelligent in both wirings.

Testing

  • ./run_pre_commit passes, including the full quick suite ("All tests passed, 4 slow tests skipped").
  • ohme, multi_car_iog, octopus_misc and octopus_intelligent_devices fail without the source change and pass with it (source files stashed, tests kept).
  • New tests: a fetch-level regression for the issue (planned_slot_sensor_5413: the completed dispatch survives the charger reporting no slots after unplug), and four Ohme tests covering which sensors count as Octopus's, the split wiring, following the Octopus sensor coming and going, and leaving Intelligent.
  • Three existing tests asserted the old behaviour (Octopus leaving octopus_intelligent_slot alone under an Ohme claim) and were updated.

Not tested against a live Ohme or Octopus account.

Notes

  • Behaviour change for existing Ohme users on Intelligent who run the Octopus component: octopus_intelligent_slot moves from the Ohme sensor to the Octopus dispatch sensor. The car's battery size and charge rate attributes are therefore now read from Octopus's sensor, where Ohme's had none.
  • Users with no Octopus dispatch sensor keep the bug. That includes anyone who followed docs/devices.md and pointed octopus_intelligent_slot at an Ohme sensor. The Ohme component logs which source it is using. The Home Assistant Ohme integration sections of docs/devices.md and the commented template lines are not changed here.
  • A slot Ohme reports as finished that Octopus never confirms stays at the off-peak rate until the car is unplugged, the same as today.
  • Multiple cars: Ohme's planned sensor is wired to car 0, as its slot sensor was.
  • Octopus: Intelligent devices stay cached and wired to the car slots after the account leaves an Intelligent tariff #5412 (Intelligent devices staying cached after leaving the tariff) still applies after a restart: the Octopus component re-wires the stale device's sensor on its first run.
  • Setting ohme_automatic_octopus_intelligent: false with ohme_control: true on an Intelligent tariff still turns Predbat-led control on. That is not changed here.
  • Impact analysis: fetch_sensor_data_cars rates HIGH in GitNexus (it is on the main loop); the change there does nothing when the new option is unset. The newer Ohme wiring functions are not in the GitNexus index, so their callers were established by search.

🤖 Generated with Claude Code

…d slots from Ohme (#5413)

Ohme only reports the slots of the charge session in progress, so unplugging the
car emptied the car slots and the off-peak rate already charged at was re-priced
at day rate in the plan history and today's cost.

Add octopus_intelligent_planned_slot: a per-car sensor the planned dispatches are
read from, leaving octopus_intelligent_slot as the record of the completed ones.
On Octopus Intelligent the Ohme component now sets only that, the ready time and
the charge limit when octopus_intelligent_slot is already a sensor of Octopus's
(wired by the Octopus component or set in apps.yaml), and falls back to supplying
everything when there is no such sensor. The car_slot_owner claim narrows to the
ready time and charge limit, so the Octopus component keeps its dispatch sensor
wired under it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@springfall2008 springfall2008 self-assigned this Oct 8, 2026
@springfall2008
springfall2008 marked this pull request as ready for review October 9, 2026 18:46
Copilot AI balanced review requested due to automatic review settings October 9, 2026 18:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Multi-car configurations can retain stale dispatch wiring and lose per-car ready-time and charge-limit targets.

1 open finding
What changed in this PR

Splits completed Octopus Intelligent dispatches from Ohme-planned slots to preserve historical off-peak pricing.

Changes:

  • Adds octopus_intelligent_planned_slot.
  • Updates Ohme/Octopus wiring ownership.
  • Adds documentation and regression tests.
File Description
apps/​predbat/​config.py Defines the new option.
apps/​predbat/​fetch.py Merges completed and planned dispatch sources.
apps/​predbat/​ohme.py Implements split sensor wiring.
apps/​predbat/​octopus.py Retains Octopus dispatch wiring under Ohme ownership.
apps/​predbat/​predbat.py Updates ownership semantics.
apps/​predbat/​tests/​test_multi_car_iog.py Tests split dispatch fetching.
apps/​predbat/​tests/​test_octopus_intelligent_devices.py Updates ownership tests.
apps/​predbat/​tests/​test_octopus_misc.py Tests retained dispatch wiring.
apps/​predbat/​tests/​test_ohme.py Adds Ohme transition and source tests.
docs/​apps-yaml.md Documents the option.
docs/​car-charging.md Explains split Ohme/Octopus behavior.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread apps/predbat/ohme.py
car on dispatches that never come. Not so while Octopus drives another device, whose
dispatches that sensor is about to carry.
"""
return bool(entity_id) and entity_id == self.slot_source_applied and not self.octopus_intelligent and not self.octopus_other_device

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IOG extra car charging slots still not holding the off-peak rate

2 participants