batpred icon indicating copy to clipboard operation
batpred copied to clipboard

Octopus Intelligent: let the user say whether the enrolled device is the car or the charger

Open chalfontchubby opened this issue 5 days ago • 2 comments

Posted by Claude on behalf of @chalfontchubby.

Summary

On Octopus Intelligent, what Predbat does with the charge target depends on whether Octopus has the car or the charger enrolled. For a charger, the target means "add X%"; for a car, it means "charge to X%" (#3034, fixed by #5822). Predbat currently works out which device is enrolled by inference. This asks for a setting so the user can say which it is, with automatic detection kept as the default.

Why the inference is fragile

utils.intelligent_device_is_charger() checks, in order:

  1. is_charger on the dispatch sensor. Only Predbat's own Octopus and Kraken components set it, from the GraphQL __typename (SmartFlexChargePoint).
  2. device_type on the charge-target entity or the dispatch sensor. This is for the BottlecapDave integration's unmerged PR #1917, so it is speculative.
  3. Which size attribute is filled in: a charger has charge_point_power_in_kw and no vehicle_battery_size_in_kwh, and a car the reverse.

Evidence from #6178 (Predbat's own Octopus component, myenergi Zappi enrolled as the charger): the dispatch sensor has

deviceType: "ELECTRIC_VEHICLES"
is_charger: true
model: "zappi (all models)"
vehicle_battery_size_in_kwh: null

So Octopus files a charger under the device type ELECTRIC_VEHICLES, the same as a car. Predbat's own component gets this right, because step 1 uses the GraphQL type. A BottlecapDave user would not be covered if that integration passes the same ELECTRIC_VEHICLES value through as device_type: step 2 runs before the size fallback and would read the charger as a car. This was raised in review on #5822 and was not acted on.

Proposal

  • A per-car setting, for example octopus_intelligent_device: auto | car | charger. The default auto keeps today's detection; car or charger overrides it. This could be in apps.yaml alongside octopus_intelligent_slot, or a select entity.
  • Log the result once, when it changes ("Car 0 Octopus device: charger (from config / detected)"), so a wrong guess shows up in the log.
  • Check which device_type values BottlecapDave PR #1917 actually emits before trusting step 2.

Related: #3034, #3060, #5822, #6178.

chalfontchubby avatar Nov 29 '26 11:11 chalfontchubby

This is an automated first-pass triage; a maintainer will review before any action is taken.

Classification: enhancement (Octopus Intelligent device type).

Thanks for the write-up. I checked it against main (v9.10.3) and the request is sound. A few things came out of that check worth settling before it is built.

What I confirmed

  • The detection is utils.intelligent_device_is_charger(), and it has one consumer, Fetch.octopus_charge_target_is_added(). The order is is_charger, then device_type, then the size fallback, as you describe.
  • The device_type concern is not only hypothetical for a BottlecapDave user. INTELLIGENT_DEVICE_TYPE_CHARGER = "ELECTRIC_VEHICLE_CHARGERS" appears nowhere else in the tree: Predbat's own Octopus component publishes deviceType: "ELECTRIC_VEHICLES" on the dispatch sensor for chargers as well as cars (the GraphQL deviceType is ELECTRIC_VEHICLES for every SmartFlex device, and is_charger is derived separately from __typename == SmartFlexChargePoint). Only step 1 always answering keeps step 2 from reading a Predbat-published charger as a car, and overriding the size fallback that would have got it right.
  • For the Zappi in #6178 the size fallback is correct (charge_point_power_in_kw set, vehicle_battery_size_in_kwh null); it is simply never reached, because step 2 answers first.
  • The detection already has thorough unit coverage in test_octopus_charge_target.py (_run_detection, _run_target_entity_detection), so an auto default that keeps today's behaviour is easy to pin.

Design notes

  • There is a second, independent detection: car_charger_control.charger_control_dispatch_is_charger() reads is_charger alone and treats anything else as "cannot be told". If the setting feeds only the fetch path, charger control goes on guessing, and the two can disagree about the same car. The override should feed both.
  • A per-car octopus_intelligent_device: auto | car | charger fits the config schema as a string_list with entries: num_cars (givtcp_rest and inverter_type are the existing pattern), and the name is unused. A select would work too, but apps.yaml is the simpler first step and covers people who never touch the UI.

Related: #3034 (closed, fixed by #5822), #3060 (open, same root cause), #6178 (the evidence quoted above), #6430 (spun out of the same ticket, a different problem: dispatches trimmed against car 0's SoC when a shared charger is enrolled), #5726.

I found no existing issue asking for a manual override, so this is not a duplicate. The log line you suggest on change is a good idea regardless of the setting: it makes a wrong inference visible without anyone having to ask for a dump.

springfall2008 avatar Nov 29 '26 11:11 springfall2008

There is an outstanding pr on bcd to add some device type indicator but that is as yet unmerged.

chalfontchubby avatar Nov 29 '26 14:11 chalfontchubby