Octopus Intelligent: let the user say whether the enrolled device is the car or the charger
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:
is_chargeron the dispatch sensor. Only Predbat's own Octopus and Kraken components set it, from the GraphQL__typename(SmartFlexChargePoint).device_typeon the charge-target entity or the dispatch sensor. This is for the BottlecapDave integration's unmerged PR #1917, so it is speculative.- Which size attribute is filled in: a charger has
charge_point_power_in_kwand novehicle_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 defaultautokeeps today's detection;carorchargeroverrides it. This could be inapps.yamlalongsideoctopus_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_typevalues BottlecapDave PR #1917 actually emits before trusting step 2.
Related: #3034, #3060, #5822, #6178.
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 isis_charger, thendevice_type, then the size fallback, as you describe. - The
device_typeconcern 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 publishesdeviceType: "ELECTRIC_VEHICLES"on the dispatch sensor for chargers as well as cars (the GraphQLdeviceTypeisELECTRIC_VEHICLESfor every SmartFlex device, andis_chargeris 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_kwset,vehicle_battery_size_in_kwhnull); 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 anautodefault 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()readsis_chargeralone 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 | chargerfits the config schema as astring_listwithentries: num_cars(givtcp_restandinverter_typeare 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.
There is an outstanding pr on bcd to add some device type indicator but that is as yet unmerged.