Skip to content

Charger control on automatically: GE, Ohme and Zappi follow their automatic setup, Octopus per car, guest charging (stage 2, stacked on #5284) - #5311

Closed
chalfontchubby wants to merge 21 commits into
feat/charger-control-mixinfrom
feat/charger-control-auto
Closed

chalfontchubby wants to merge 21 commits into
feat/charger-control-mixinfrom
feat/charger-control-auto

Conversation

@chalfontchubby

@chalfontchubby chalfontchubby commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Posted by Claude on behalf of @chalfontchubby.

Stacked on #5284: review and merge that first. This PR's diff is against its branch, feat/charger-control-mixin.

What this does

Stage 2 of Predbat-led EV charger control. It follows the rule agreed on #5284: if Predbat is planning the car and the user has turned on the charger's automatic setup, Predbat can control the charger without being asked separately.

Until now, ge_cloud_evc_control and myenergi_zappi_control were off unless set. They now have three states (ohme_control stays opt-in, see decision 2):

Setting Unset false true
ge_cloud_evc_control on when ge_cloud_automatic_evc is on off on, and warns if a prerequisite is missing
ohme_control off (unchanged): Ohme's own schedule is the car plan (#5401) off on
myenergi_zappi_control on only if the user wrote myenergi_automatic or myenergi_automatic_zappi in apps.yaml off on

It also adds three things, each described below:

  • a per-car rule for Octopus Intelligent;
  • a guest charging switch;
  • a few fixes found while reviewing it.

Behaviour change on upgrade

Users who already have ge_cloud_automatic_evc on now get charger control, and so do Zappi users who wrote myenergi_automatic into apps.yaml. Ohme users see no change. For each of them, Predbat starts and stops the charger unless they set its control setting to false.

Users who already had *_control: true see no change, apart from the new Octopus rule and the guest switch. One part of the Octopus rule does change things for them: where Octopus drives the car itself, Predbat now leaves the charger alone unless switch.predbat_octopus_intelligent_charger_follows_car is on, where before it drove the charger to its plan.

The docs say this in car-charging.md, in the new section "Predbat starting and stopping your charger". This probably wants a line in the release notes.

Decisions, and the options rejected

  1. Zappi: on only when the user wrote the automatic setting (fa7c9f6). myenergi_automatic and myenergi_automatic_zappi both default on, so the GE/Ohme rule would switch every Zappi user over on upgrade. A Zappi that Predbat controls is Stopped between windows, so it stops diverting solar in Eco/Eco+. The options considered are in enable_control()'s docstring, for review and to tidy up later:
    • Rejected: on for every Zappi user.
    • Chosen: on only when the user wrote the setting.
    • Rejected: Zappi stays opt-in.
  2. Ohme stays opt-in (e631a2c, replacing 7a35d85). Since feat(ohme): take the car plan from Ohme's own schedule when Predbat is not controlling the charger #5401, an Ohme that Predbat does not control already has its own schedule taken as the car plan, so the default user gets a plan that matches what the charger does. Turning control on by default would override that schedule, which the user may have set up deliberately, with max charge, which also overrides the Ohme app's target.
  3. Octopus Intelligent is judged per car (067f637, d3663f6, 3f6422c). You agreed this on refactor(car): share Predbat-led EV charger control across Ohme, Zappi and GivEnergy #5284. Predbat reads is_charger from the car's own dispatch sensor in octopus_intelligent_slot. Both the Octopus and Kraken components publish it, so E.ON/EDF SmartFlex is covered, and a car can't be paired with another car's device. What Predbat does depends on which device Octopus drives:
    • Octopus drives the charger: Predbat leaves the charger alone, whatever switch.predbat_octopus_intelligent_charging says. That switch only changes Predbat's own planning; Octopus keeps switching the charger either way, so driving it would fight Octopus.
    • Octopus drives the car: by default Predbat leaves the charger alone; a charger it was holding is released as usual, since nobody else drives it (5fa79fb, 0ab856d). A new expert-mode switch, switch.predbat_octopus_intelligent_charger_follows_car (default off), has Predbat drive the charger instead: on during dispatches and off otherwise, so the car cannot charge on its own timers. It follows the plan and also the dispatch times on the sensor, judged against the clock, so it picks up a new dispatch without waiting for the 5-minute plan and stops the charger when the dispatch ends. With octopus_intelligent_charging off, Predbat plans the car itself and the charger follows that plan, whatever the new switch says. The Ohme follows the same rules (bbbfb3f), so with the switch on ohme_control: true can run where fix(ohme): leave the Intelligent car slots to Octopus when the Intelligent device is the car #5405 would otherwise stand it down.
    • Can't tell (for example the Octopus Energy HA integration's sensor): Predbat leaves the charger alone unless *_control: true, and logs a warning naming that setting (6cec384). A charger Predbat was holding is handed back as usual, so one it had stopped is not stranded. Released users are unaffected, because before this PR control only ran with true.
    • Still discovering (the Octopus or Kraken component has not wired its devices yet): the charger is left as it is, and still held, until discovery finishes. After 15 minutes it is treated as can't tell, with a warning.
  4. Handing a charger to Octopus never starts a charge (d3663f6). A normal release undoes a stop, so that read only mode never leaves a car unable to charge. Octopus deciding when to charge is different, so the hand-over does this instead:
    • GE: sends nothing.
    • Ohme: turns max charge off, then resumes into its smart schedule.
    • Zappi: goes back to its own mode, with Eco+ in place of Fast.
  5. Guest charging switch (b6d30e4, 8032b55, ec86180). While Predbat drives a charger it holds it off outside the plan, so a visitor's car can't charge. The switch lets them:
    • The entities: switch.predbat_gecloud_guest_charging, switch.predbat_myenergi_guest_charging and switch.predbat_ohme_guest_charging.
    • What it does: releases the charger, as read only mode does. How the guest charges (boost, solar only) is chosen on the charger itself; Predbat never picks a mode.
    • When it ends: when a car plugged in after the switch went on is unplugged, using the plug state of all three chargers. Unplugging the owner's car to make way for the guest doesn't end it. It also ends after 12 hours.
    • Restarts: it isn't remembered across a restart.

Fixes found in review before opening

  • Octopus discovery: with octopus_automatic off, Predbat waited for Octopus discovery that never came, so control never turned on.
  • Setting values: a quoted "false" or a 0 read as on, because removing the defaults also skipped get_arg()'s boolean conversion. parse_control_setting() now normalises them.
  • Dispatch end: following the dispatch sensor's on/off state ran the charger up to about 3 minutes past the end of a dispatch.
  • GE status blip: an offline or unavailable status on a GE charger ended guest charging.

Found by a further /code-review after opening:

Rebased onto main (5 Oct)

The stack is rebased onto main, which meanwhile changed the Ohme component in #5401 and #5405. How the two fit:

Found by review after the rebase:

  • Can't tell stranded a GE charger: it was let go without being started, as if Octopus were taking over, so a charger Predbat had stopped stayed stopped with nobody in charge (5394c56).
  • Discovery waited for good: a Kraken component whose first run never succeeds left every unwired car's charger alone indefinitely. Now bounded at 15 minutes, and a held charger is left as it is while waiting rather than released, so a component restart does not start a charge (5394c56, 6405d2e, c8278fd).
  • A false warning on restart: the apps.yaml default's literal re: string, before its regex matches, was read as a dispatch sensor (5394c56).

Not in this PR (known and deferred)

  • Empty Zappi or Ohme: Predbat still sends commands to one with no car plugged in. Only GE skips an empty charger today. Using the plug state there is a separate change, because a car plugged into a Zappi left in Fast could charge for up to a minute before the next tick.
  • Guest energy: the guest's charging is still counted as the owner's car's.
  • GE size and limit: whether GE needs the same size/limit guard as the Ohme.
  • Ohme ohme_automatic_octopus_intelligent: has the same quoted-"false" problem, from before this PR.
  • No cars: with num_cars at 0 there is no plan to read, so control does nothing that cycle, including releasing a charger it holds. This comes from refactor(car): share Predbat-led EV charger control across Ohme, Zappi and GivEnergy #5284 and is unchanged.
  • Hardware: not tested on real chargers. In particular it is unverified that an Ohme resumed into its smart schedule doesn't start charging outside a dispatch.

Testing

  • New tests: for each decision above, in test_car_charger_control.py, test_ge_cloud.py, test_ohme.py and test_myenergi.py.
  • Checks: every commit passes pre-commit and the full suite on its own.
  • Reviews: two rounds before opening and four after the rebase, each a cold subagent review plus a local /code-review high. Their findings are the fixes listed above.

🤖 Generated with Claude Code

chalfontchubby added a commit that referenced this pull request Sep 30, 2026
…g a charger (#5311 review)

Only the Octopus component was waited for. After a restart a Kraken (E.ON/EDF
SmartFlex) user's charger could be driven before Kraken had wired
octopus_intelligent_slot - stopping a GE charger mid-dispatch, which the hand-over on
the next cycle then left stopped. Kraken wires its devices in its first successful run,
from cache or fresh discovery, so until it has started the charger is left alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chalfontchubby
chalfontchubby force-pushed the feat/charger-control-auto branch from 393fdc5 to d411ca7 Compare September 30, 2026 09:37
chalfontchubby added a commit that referenced this pull request Oct 2, 2026
…g a charger (#5311 review)

Only the Octopus component was waited for. After a restart a Kraken (E.ON/EDF
SmartFlex) user's charger could be driven before Kraken had wired
octopus_intelligent_slot - stopping a GE charger mid-dispatch, which the hand-over on
the next cycle then left stopped. Kraken wires its devices in its first successful run,
from cache or fresh discovery, so until it has started the charger is left alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chalfontchubby
chalfontchubby force-pushed the feat/charger-control-auto branch from d411ca7 to 15514d1 Compare October 2, 2026 12:49
@chalfontchubby
chalfontchubby added this pull request to stack #5351 October 2, 2026 13:15
chalfontchubby and others added 17 commits October 5, 2026 21:52
…arger

Charger control now decides per car whether Octopus Intelligent is in
charge of the charger. Where Octopus delivers its dispatches by driving
the charger itself, Predbat leaves it alone - releasing it if it was
holding it - so the two never fight. Where Octopus drives the car, or
there is no Intelligent car, Predbat drives the charger from the car
slot sensor, which then carries the Octopus dispatches, so the car
cannot charge outside them on its own timers.

Octopus car N is the Nth wired Intelligent device, and the Octopus
component already records whether each is a charge point. When that
cannot be told - slots from outside the Octopus component, or before
it has discovered its devices - the charger is left alone, unless the
component's control setting is explicitly true.

Nothing turns control on by default yet; that follows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ge_cloud_evc_control no longer defaults to false. Left unset, control follows
ge_cloud_automatic_evc: setting that is the user asking Predbat to plan for the car,
and it is what maps each charger to its car. An explicit false keeps control off,
and only an explicit true warns when a prerequisite is missing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ohme_control no longer defaults to false. Left unset, control follows ohme_automatic,
which registers the car. Where the Intelligent slots come from the Ohme, Octopus
drives the charger and Predbat still leaves it alone - logged as Info for an unset
control, and as a warning only when ohme_control was explicitly set true.

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

myenergi_zappi_control no longer defaults to false. Left unset, control turns on
only when the user wrote myenergi_automatic or myenergi_automatic_zappi into
apps.yaml themselves. Both default on, so following their values alone - the rule
GE and Ohme use - would switch every Zappi user to Predbat control on upgrade, and a
Zappi held off between windows can no longer divert solar in Eco/Eco+. The options
considered are recorded in enable_control()'s docstring for review.

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

A new "Predbat starting and stopping your charger" section in car-charging.md sets
out when each charger's control turns on while its setting is unset, the upgrade
change for existing automatic users, and what happens on Octopus Intelligent
depending on whether Octopus drives the charger or the car. The per-setting entries
in apps-yaml.md and components.md now describe the unset default instead of false.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er start a charge handing over

Found by review before opening the stage 2 PR:

- Read is_charger from the car's own wired octopus_intelligent_slot sensor instead of
  pairing car N with the Nth sorted Octopus device. Both the Octopus and Kraken
  components publish it there, so E.ON/EDF SmartFlex users are covered and a slot list
  in a different order can no longer pair a car with another car's device.
- Only wait for Octopus discovery when the Octopus component runs its automatic setup.
  With octopus_automatic off it never wires the slots, so control never turned on.
  "Cannot tell yet" also gets its own log line rather than claiming the car is on IOG.
- Handing a charger to Octopus no longer starts it. A normal release undoes a stop so
  a car is never stranded, but here Octopus decides when to charge: a GE charger
  Predbat stopped is left for Octopus, an Ohme has max charge turned off before it is
  resumed into its smart schedule, and a Zappi returns to its own mode, Eco+ in place
  of Fast.
- The control settings have no default, which also skipped get_arg()'s boolean
  conversion, so a quoted "false" or a 0 read as set. parse_control_setting()
  normalises them to None, True or False in each component.

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

Predbat drives an Ohme with max charge, which overrides the target set in the Ohme
app, so car_charging_battery_size and car_charging_limit are all that stop a charge.
Left at their defaults (100 kWh, 100%) the car would be charged to full. Unset
ohme_control now waits for both to be in apps.yaml and logs why; an explicit
ohme_control: true is still the user's call.

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pus drives follows its dispatch sensor

- switch.predbat_octopus_intelligent_charging only changes Predbat's own planning:
  Octopus goes on switching a charger that is its Intelligent device whatever the
  switch says. The device is now judged first, so turning the switch off no longer
  has Predbat fight Octopus for that charger. For a car Octopus drives, the switch
  still decides whether the charger follows the dispatches or Predbat's own plan.
- Where Octopus drives the car, the charger also runs while the car's dispatch sensor
  is on. The plan carries the dispatches but is only republished every 5 minutes and
  leaves out a dispatch Octopus has not given any energy yet, so the charger held the
  car off for the first minutes of a new dispatch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
While Predbat drives a charger it holds it off outside the planned windows, so a
visitor's car could not charge - and stage 2 turns control on by default. Each
component (GE, myenergi, Ohme) now publishes switch.predbat_<component>_guest_charging
beside its control. On, Predbat releases the charger as it does for read only mode, so
it runs on its own settings; how the guest charges is chosen on the charger itself.

It turns itself off when a connected car is unplugged, on chargers that can tell
(GE), and otherwise after GUEST_CHARGING_MAX_HOURS (12). It is deliberately not
persisted, so a restart puts Predbat back in charge. The guest's charging is still
counted as the car's.

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

Both report whether a car is plugged in - the Zappi's plug status, the Ohme's
UNPLUGGED status - so guest charging now ends on unplug for every charger, not just
GE. A new charger_control_car_plugged() hook carries it, separate from
charger_control_connected(), so how Predbat drives an empty Zappi or Ohme is
unchanged. An unknown plug state reads as plugged in, leaving the 12 hour limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ends are judged by the clock

Found by review before opening the stage 2 PR:

- Guest charging ended on any unplug, including the owner's car being unplugged to make
  way for the guest. Only a car plugged in after the switch went on now ends it
  (empty, plugged in, empty again); a guest who plugged in first is left to the 12 hour
  limit or a manual off.
- A GE status blip (offline, unavailable, unknown) read as an unplug and ended guest
  charging. Only "available" and "idle" count as empty now, as the Zappi and Ohme
  already treat unknown states as plugged in.
- The charger followed the dispatch sensor's on/off state, which only refreshes every
  couple of minutes and so ran the charger past the end of a dispatch. The dispatch
  times on the sensor are now judged against the clock, in both the Octopus and the
  Kraken formats, falling back to the state for a sensor with no times.
- A toggle on the guest switch now flips it rather than turning it off.

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

A dispatch sensor that does not say which device Octopus drives (the Octopus Energy
integration, for one) leaves the charger uncontrolled for good, and was only an Info
line. It is now a warning naming the component's own setting to set true. Waiting for
the Octopus component to discover its devices, which normally clears within a cycle
or two, stays Info. Each reason is logged once, and again only when it changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g a charger (#5311 review)

Only the Octopus component was waited for. After a restart a Kraken (E.ON/EDF
SmartFlex) user's charger could be driven before Kraken had wired
octopus_intelligent_slot - stopping a GE charger mid-dispatch, which the hand-over on
the next cycle then left stopped. Kraken wires its devices in its first successful run,
from cache or fresh discovery, so until it has started the charger is left alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…it, and stop waiting on discovery after 15 minutes (#5311 review)

- Cannot tell whether Octopus drives a charger: a charger Predbat had stopped
  was let go without being started, as if Octopus were taking it over. With
  nobody known to take it over, a GE charger was left stopped indefinitely.
  It is now released as usual; the non-starting hand-over is kept for a
  charger Octopus is known to drive.
- Waiting for Octopus or Kraken discovery is bounded at 15 minutes. A Kraken
  component whose first run never succeeds (a failed login) otherwise left
  every unwired car's charger uncontrolled for good. The log line now names
  both components.
- The apps.yaml default's literal "re:" string, before its regex matches, is
  no longer read as a dispatch sensor - which on every restart warned users
  with no Intelligent sensor to set a control override they do not need.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…at a discovery that never finishes as cannot tell (#5311 review)

Releasing during discovery started a charge Predbat had stopped whenever the
Octopus or Kraken component restarted, and driving the charger once the wait
ran out could fight Kraken if it was the one driving it. While discovery is
under way the charger is now left as it is and still held, so it is settled
either way once discovery finishes. After 15 minutes Predbat still cannot
tell, so it warns once and hands back a charger it holds, as for a dispatch
sensor that does not say.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r is known (#5311 review)

The wait's start was only cleared when discovery was asked about with nothing
discovering, which stops happening once every car's driver is known. A later
component restart could then find the old start and count the wait as
already over.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chalfontchubby
chalfontchubby force-pushed the feat/charger-control-auto branch from 15514d1 to c8278fd Compare October 6, 2026 01:50
chalfontchubby and others added 3 commits October 6, 2026 08:56
…its own schedule stays the car plan otherwise

Main's #5401 now takes the car plan from Ohme's own schedule when Predbat is
not controlling the charger, so a default user already gets a plan that matches
what the charger will do. Turning control on by default would override that
schedule - one the user may have set up deliberately - with max charge, which
also overrides the Ohme app's target. ohme_control goes back to a false default;
GE and Zappi keep their automatic defaults. The size and limit guard for an
unset ohme_control goes, as there is no unset default any more.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…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>
…llowing Predbat's own plan with Intelligent charging off, and log only real Ohme changes (#5311 review)

- Octopus driving the car means nobody drives the charger, so a charger
  Predbat had stopped is released as usual (GE started, Zappi back to its own
  mode including Fast) rather than handed over without starting, which left it
  stopped through every dispatch.
- With switch.predbat_octopus_intelligent_charging off Predbat plans the car
  itself, so it still drives the charger to that plan whatever the new switch
  says.
- An Ohme poll that sees only the new switch change logs that change, and only
  re-decides control while Octopus drives another device - not the Octopus
  tariff change it used to report.
- The log points at expert mode for the switch, and the class docstring says
  the charger is left alone by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ging off while Octopus drives the car (#5311 review)

The shared charger rule drives a charger for a car Octopus drives when
switch.predbat_octopus_intelligent_charging is off, as Predbat then plans the
car itself; the Ohme stood control down there regardless. It now follows the
same rule, and re-decides when either switch changes.

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

Copy link
Copy Markdown
Collaborator Author

Posted by Claude on behalf of @chalfontchubby.

Folded into #5448 together with #5284, for a single final review. The commits are unchanged apart from the rebase onto main. Closing this one in favour of it.

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.

1 participant