Repository navigation
fix(car): a charger-linked Octopus Intelligent target adds to the SoC at plug-in (#3034) - #5822
Conversation
… at plug-in (#3034) With Octopus linked to the charger rather than the car, Octopus cannot see the car's SoC, so its charge target is a percentage to add rather than a SoC to reach. Predbat read it as a SoC ceiling: a car plugged in at 39% with "add 40%" was taken as already charged as soon as the charge Octopus does at plug-in took it past 40%, and its Intelligent slots were then ignored. Which device is linked comes from the dispatch sensor: is_charger from Predbat's own Octopus and Kraken components, device_type from the HA Octopus Energy integration (proposed upstream), and otherwise from the integration filling in only the charge point's power for a charger and only the battery size for a car. When none of these says, the target is read as before. The plug-in SoC is the lowest SoC seen while plugged in, held in memory. The limit can only come out higher than before, never lower, and users with no car SoC sensor (SoC 0) are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…elper; read device_type from the charge target The #3034 detection - is_charger, then device_type, then which size the Octopus Energy integration's dispatch sensor fills in - moves out of Fetch into utils.intelligent_device_is_charger(), so charger control can use the same rule later rather than a copy. device_type is now also read from the car's octopus_charge_limit entity when that is an entity: BottlecapDave/HomeAssistant-OctopusEnergy#1917 puts it on the intelligent charge target, not on the dispatch sensor. A target set as a plain number has no entity, so the dispatch sensor alone decides, as before. is_charger as a string ("true"/"false") is read too. Charger control is deliberately not switched to it here: detecting the device for Octopus Energy integration users changes what an explicit charger control setting does, which needs deciding with #5807's veto. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… sensor, and leave an Ohme target alone Review follow-ups for #3034: - The base was the lowest SoC seen while plugged in, so one stale low reading latched it and the "add X%" limit with it - dropping the car's slots, the #3034 symptom. It is now captured when the car is plugged in and held until it is unplugged. - Plugged in is read from car_charging_plugged where it is set, since car_charging_planned can turn off at the end of a charge with the car still plugged in. Without a plug sensor the old rule stands. - When Ohme has claimed car 0's charge limit, octopus_charge_limit is Ohme's own SoC target, so it is never treated as a percentage to add. - is_charger strings and numbers are read as the charger control reads them. - The "linked to the charger" line is logged when it changes, not every cycle. - Docs: device_type on the charge target is read should the integration add it, rather than claimed as something it does today. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
springfall2008
left a comment
There was a problem hiding this comment.
Automated comment from the triage bot.
Reviewed 72280ee (fix(car): a charger-linked Octopus Intelligent target adds to the SoC at plug-in, #3034). The core is sound: is_charger really is published on the dispatch sensor by Predbat's own Octopus and Kraken components (octopus.py:2845, octopus.py:2948, kraken.py:1471), so the shared helper's first check keys off real data; the plug-in base holds through charging, a 0 reading and a stale-low reading (tests 7/13/14); a plug sensor outranks car_charging_planned where it is set (test 14); compare.py re-runs (save=False) reuse the live base without recording one (test 6); an Ohme-claimed target stays a SoC to reach (test 15); and the #3034 numbers resolve correctly - 39% + "add 40%" → 79% limit, so the car_charging_soc >= car_charging_limit drop at execute.py:944 no longer fires, and #3060's IOG-charger "add 22%" reads the same way. Detection falls back to the old SoC-to-reach reading when nothing says, which is the conservative default. 1 low finding, posted inline; none in the body.
While the car is unplugged the base follows the live SoC, so the "adds X kWh to the Y kWh the car had when plugged in" line re-fired on every cycle of a drive with a number that was not a plug-in SoC. Leave the base out of the change key while unplugged and log only when plugged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Opened by Claude on behalf of @chalfontchubby.
Fixes #3034. Also addresses #3060, which has the same root cause.
Problem
When Octopus Intelligent is linked to the charger rather than the car, Octopus's charge target means "add X%", not "charge to X%". Predbat read
octopus_charge_limitas a SoC to reach. So a car with a real SoC sensor was treated as already charged, and its slots were dropped. The #3034 log shows exactly this: 39% with "add 40%", and the car is "already charged" at 43%.Change
Detecting which device is linked: the new shared helper
utils.intelligent_device_is_charger()checks, in order:is_chargeron the dispatch sensor, from Predbat's own Octopus and Kraken components.device_type(ELECTRIC_VEHICLE_CHARGERS/ELECTRIC_VEHICLES), on the car'soctopus_charge_limitentity or the dispatch sensor. It's for feat: Indicate whether the intelligent charge target is a state of charge or a percentage to add BottlecapDave/HomeAssistant-OctopusEnergy#1917, which is still open, so today it's only read if present.charge_point_power_in_kwfor a charger, and onlyvehicle_battery_size_in_kwhfor a car. I checked this against the integration's source.If none of these says, the target is read as a SoC to reach, as before.
Charger-linked limit: the SoC at plug-in plus the target, still capped by
car_charging_limit.car_charging_pluggedwhere it's set. Otherwise it comes fromcar_charging_planned, the car charging now, or planned dispatches (unlessoctopus_intelligent_ignore_unplugged).Ohme: when Ohme has claimed car 0's charge limit,
octopus_charge_limitis Ohme's own SoC target and is never treated as a percentage to add.compare.py re-runs (
save=False) use the live fetch's plug-in SoC without recording one.The helper is ready for charger control to use, but deliberately isn't wired in here. Telling the device apart for Octopus Energy integration users changes what an explicit charger control setting does, which needs deciding alongside #5807's veto. See #5808.
Known limits
Tests
./run_all --test octopus_charge_target: 15 cases covering:device_typeon the charge target andis_chargeras a stringThey fail on main.
./run_all --quickpasses, and so does pre-commit. A cold review and/code-review highwere run, and their findings are fixed in the last commit.🤖 Generated with Claude Code