Skip to content

fix(ohme): leave the Intelligent car slots to Octopus when the Intelligent device is the car - #5405

Merged
springfall2008 merged 2 commits into
mainfrom
fix/ohme-intelligent-device-is-car-5402
Oct 5, 2026
Merged

springfall2008 merged 2 commits into
mainfrom
fix/ohme-intelligent-device-is-car-5402

Conversation

@springfall2008

Copy link
Copy Markdown
Owner

Fixes #5402. Builds on #5401, which is merged.

The problem

With ohme_automatic: true and ohme_automatic_octopus_intelligent unset, the Ohme component took the Intelligent car slots for itself whenever the import tariff was an Intelligent one. It never checked which device Octopus Intelligent controls.

When that device is the car (a BMW, Mini or Volkswagen linked to Octopus directly) and not the Ohme, Octopus schedules the charge through the car and the Ohme is only the socket. Predbat was then planning from Ohme's session, target and ready time, and ignoring Octopus's own dispatch list. The issue has an example: Octopus reporting no dispatches and 80% by 18:40, while Predbat worked from a 12-hour, 91 kWh Ohme slot to 100% by 11:52.

What this changes

Auto-detection now looks at the Octopus component's Intelligent devices as well as the tariff. On an Intelligent tariff with the flag unset:

Octopus Intelligent devices (not suspended) Car slots come from Notes
Include an Ohme charger Ohme, at the off-peak rate Unchanged
Only other devices (the car, or another make of charger) The Octopus component's own dispatches New. Ohme's schedule is not used at all, and ohme_control stands down
None, but there are suspended ones Ohme's own schedule, at the normal tariff rate New. No device is being scheduled by Octopus, so there are no dispatches
No Intelligent device on the account Ohme, at the off-peak rate Unchanged, now a deliberate fallback

An explicit ohme_automatic_octopus_intelligent: true or false still wins, and the Ohme is still registered as the charger (car_charging_planned, car_charging_now, car_charging_energy) in every case.

Decisions worth a look

  • "Ohme charger" means is_charger true and provider Ohme (case-insensitive), as the issue proposed. A charger of another make on the account is treated like the car: Octopus keeps the slots.
  • Suspended devices are ignored, matching what OctopusAPI.automatic_config() already does for its own wiring. This does change behaviour for an Ohme whose smart charging is suspended in the Octopus app: its slots used to be priced as cheap dispatches and are now car load at the tariff rate. That seems right, since Octopus is not dispatching it, but it is wider than the issue's example.
  • No Intelligent device at all keeps the old behaviour. Octopus has nothing to wire the car slots to there, so Ohme's slots are the only record of the charge.
  • ohme_control is ruled out when Octopus drives another device, not only when the slots come from Ohme. Otherwise Predbat would pause and max-charge the Ohme while Octopus is scheduling the car through it. With an explicit ohme_automatic_octopus_intelligent: false it is still allowed, as before.

How it works

Testing

  • test_ohme.py: the detection rules for each device combination (Ohme, car, other charger, both, suspended, none, explicit flag, non-Intelligent tariff); a first run with the car as the device, with and without Octopus's wiring already in place, and with ohme_control; and a running install where the device is found late, swapped for the Ohme, then suspended.
  • test_octopus_intelligent_devices.py: the Octopus component leaves the slots alone while Ohme holds them, wires its own entity on the next sensor refresh after Ohme lets go, and does not repeat that.
  • ./run_all --quick passes.

Docs: docs/car-charging.md (the auto-detect description and the "Which car charging plan Predbat shows" table) and the Ohme entry in docs/components.md.

🤖 Generated with Claude Code

…igent device is the car

With ohme_automatic on and ohme_automatic_octopus_intelligent unset, the
Ohme component took the Intelligent car slots for itself on any
Intelligent tariff. Where the device Octopus Intelligent drives is the
car and not the Ohme, Octopus schedules the charge through the car, and
Ohme's session has nothing to do with the dispatches (#5402).

Auto-detection now looks at the Octopus component's live, non-suspended
Intelligent devices. The Ohme takes the slots when it is one of them, or
when the account has no Intelligent device at all. When Octopus drives
another device the slots are left to the Octopus component, Ohme's own
schedule is not used as the plan, and ohme_control stands down. With
every device suspended there are no dispatches, so Ohme's schedule is
the plan at the tariff rate.

The Octopus component now re-wires the car slots when their owner
changes, so they are picked up when Ohme gives up a claim it made before
the device was known.

Fixes #5402

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 5, 2026 10:07

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.

Copilot review overview

🟡 Changes recommended

Ownership release can incorrectly erase Ohme’s schedule for suspended devices or restore stale dispatch wiring after leaving an Intelligent tariff.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Updates Ohme/Octopus Intelligent coordination so charging slots follow the device controlled by Octopus.

Changes:

  • Detects whether Octopus controls the Ohme charger or another device.
  • Rewires slot ownership when the controlled device changes.
  • Adds regression tests and documentation.
File Description
apps/​predbat/​ohme.py Selects slots based on the Intelligent device.
apps/​predbat/​octopus.py Reconfigures slots after ownership changes.
apps/​predbat/​tests/​test_ohme.py Tests device detection and transitions.
apps/​predbat/​tests/​test_octopus_intelligent_devices.py Tests ownership-based rewiring.
docs/​car-charging.md Documents slot-selection behavior.
docs/​components.md Clarifies Ohme auto-detection.

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

Comment thread apps/predbat/octopus.py Outdated
… to wire them to

Review feedback on #5405. The Ohme component also gives up its claim on
the car slots when there are no dispatches to be had from anyone - the
Intelligent device suspended, or the tariff no longer Intelligent - and
then wires them to the charger's own schedule. The owner-change re-wire
added in this PR ran automatic_config() in those cases too:

- with every device suspended it cleared the wiring Ohme had just made;
- off an Intelligent tariff, where the device list is not refreshed and
  still holds the old device, it overwrote it with stale dispatch entities.

The re-wire now only runs when the slots were released and there is a
live, non-suspended device on a tariff that is still Intelligent;
otherwise the new owner is just noted. automatic_config() also only
clears car slot wiring that is still what it last put there, as the
device-set change that follows a suspension would otherwise clear the
same wiring one refresh later.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@springfall2008
springfall2008 merged commit 0395cac into main Oct 5, 2026
2 checks passed
@springfall2008
springfall2008 deleted the fix/ohme-intelligent-device-is-car-5402 branch October 5, 2026 18:40
chalfontchubby added a commit that referenced this pull request Oct 6, 2026
…alone when Octopus drives the car, unless asked to follow it

When the car itself is the Octopus Intelligent device, the car starts and stops
its own charge. Predbat now leaves the charger alone by default, handing over a
charger it held without starting a charge, as it does when Octopus drives the
charger. The new expert-mode switch, default off, has Predbat drive the charger
to the car's dispatches instead, so the car cannot also charge on its own
timers.

The Ohme follows the same switch: with it on, ohme_control can run while
Octopus drives the car, where #5405 otherwise stands it down. A change of the
switch is picked up on the next Ohme poll.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
springfall2008 added a commit that referenced this pull request Oct 8, 2026
…s); mark GH#5399/#5401, GH#5402/#5405, GH#5349/#5360 and GH#4832/#4956 fixed; add the debug-enable-engine-switch symptom row and the TEST_REGISTRY-name trap (#5416)

Co-authored-by: CI <ci@example.com>
Co-authored-by: Claude Code <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.

Ohme: Intelligent car slots are taken from Ohme even when the Octopus Intelligent device is the car, not the charger

2 participants