Repository navigation
fix(octopus): count the IOG cap in minutes the car charged, not whole completed half hours (#6252) - #6255
Draft
chalfontchubby wants to merge 1 commit into
Draft
fix(octopus): count the IOG cap in minutes the car charged, not whole completed half hours (#6252)#6255chalfontchubby wants to merge 1 commit into
chalfontchubby wants to merge 1 commit into
Conversation
… completed half hours (#6252) Octopus counts "the actual amount of time the car is charged for" towards the 6-hour Intelligent cap, but reports completed dispatches as whole half hours, so a half hour charged in for two minutes used thirty. Where every car with Intelligent dispatches has a car_charging_energy sensor, a past minute its raw records show no charging in now uses none of the cap, while still fitting the budget so its half hour stays cheap. Unknown minutes (before the first record, after the last, across a reset or an unavailable spell) still count; nothing changes without a sensor or under the window billing rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Posted by Claude on behalf of @chalfontchubby.
Fixes #6252.
Problem
On IOG-SMB tariffs Predbat counts the 6-hour cap in the minutes of each dispatch Octopus reports. That is right for planned dispatches, which carry exact times. But Octopus reports a completed dispatch as whole half-hour blocks, so a half hour the car charged in for 2 minutes uses 30 minutes of the cap.
In #6252, for 16 Nov 12:00 to 17 Nov 12:00, Predbat counted 17 completed half hours (510 min). The Ohme app shows 6h10m (370 min) of active charging: 140 minutes over-counted. Predbat decided the allowance was spent overnight and priced the 17 Nov 03:00 and 06:00–08:00 dispatches at peak, so the house battery did not charge in them. The reporter worked around it with
octopus_slot_max: 32.What Octopus says it counts
From Octopus's Intelligent Octopus Go charge limit FAQ:
Relation to #5510
#5510 decided Predbat counts the start and end Octopus sends for a completed dispatch and does not try to work out real charging minutes. That rested on Octopus sending the real start and end, and it doesn't: in the #6252 log every
completedDispatchesentry is a whole half hour (16:30–17:00,16:00–16:30, ...) with adeltakWh, and evenflexPlannedDispatchesare mostly on half-hour boundaries. The dispatch list cannot say how long the car charged, and the FAQ says that is what counts. This PR reverses that part of #5510, only where a car energy sensor gives the answer. Everything else in #5510 stays.Change
octopus_cap_idle_load()(read once a cycle infetch_sensor_data_cars(), after the dispatches are in and before the car plans and rates use them): the past minutes in which no car with Intelligent dispatches charged. Each such car needs its owncar_charging_energysensor with history, as the cap is per account; otherwise nothing is taken as idle.octopus_cap_entity_idle()works from the sensor's raw Home Assistant records, not the padded and smoothedcar_charging_energyseries, which reads as flat (idle) before its history starts and after its last update. A minute is idle only when it lies between two readings and the sensor rose by less than 0.5 kW in it. Unknown, so still counted: before the first record, after the last one, across a reset, and from anunavailablerecord to the next reading. The first rise after a pause is taken as charging for the minutes it would have needed at 0.5 kW before its record. A sensor records a change late, and a polled one later still, so smoothing would otherwise spread that rise back across the pause.take_cap_dispatch_minutes()replacestake_cap_minutes()and is shared by both counters:rate_add_io_slots(), andoctopus_cap_segments()for the car plan andoctopus_over_cap_minutes(). An idle minute still fits while budget is left, so its half hour stays cheap as Octopus bills it, but it uses none of the budget.intelligent_dispatch_billing: window), which bills the whole window whether the car charges or not (asdispatch_too_short()does).octopus_slot_maxindocs/car-charging.mdanddocs/apps-yaml.md.No setting changes. Without
car_charging_energy, behaviour is unchanged.Tests
run_cap_actual_charging_testsintests/test_rate_add_io_slots.pybuilds raw HA records (a reading every 5 s while charging) and runs the real loader. Each counting case goes through both counters.The new rate cases fail against main's
octopus.pyand pass with the change../run_pre_commit(including the quick suite) passes locally. Reviewed by a cold subagent and/code-review; the stale-idle ordering, padded-history and unavailable-gap findings from those are fixed here.Known limits
minute_data(). A power-unit sensor (W or kW) is not used.🤖 Generated with Claude Code