Skip to content

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
mainfrom
fix/iog-cap-actual-charging-6252
Draft

chalfontchubby wants to merge 1 commit into
mainfrom
fix/iog-cap-actual-charging-6252

Conversation

@chalfontchubby

Copy link
Copy Markdown
Collaborator

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:

Is this 6 hours of charging, or 6 hours of half hourly slots that are being capped? Whilst billing for the home and car is in half-hour blocks, the actual amount of time the car is charged for is what's counted towards the 6 hour cap.

If my car is plugged in but not charging, does that count towards the 6 hour limit? No, simply having your car plugged in won't count towards the six hour limit, it's only the actual amount of time the car is smart charged for.

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 completedDispatches entry is a whole half hour (16:30–17:00, 16:00–16:30, ...) with a delta kWh, and even flexPlannedDispatches are 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 in fetch_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 own car_charging_energy sensor 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 smoothed car_charging_energy series, 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 an unavailable record 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() replaces take_cap_minutes() and is shared by both counters: rate_add_io_slots(), and octopus_cap_segments() for the car plan and octopus_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.
  • Not under the window billing rule (intelligent_dispatch_billing: window), which bills the whole window whether the car charges or not (as dispatch_too_short() does).
  • Docs: octopus_slot_max in docs/car-charging.md and docs/apps-yaml.md.

No setting changes. Without car_charging_energy, behaviour is unchanged.

Tests

run_cap_actual_charging_tests in tests/test_rate_add_io_slots.py builds raw HA records (a reading every 5 s while charging) and runs the real loader. Each counting case goes through both counters.

  • A completed half hour charged for 10 minutes uses 10 minutes of the cap.
  • These still count the whole half hour, as before:
    • no sensor;
    • no record after the charge;
    • history starting after the dispatch;
    • the window billing rule.
  • A reset or an unavailable spell is not idle; the known stretch before it is.
  • Two cars:
    • a minute is idle only when neither charged;
    • one sensor for two cars, or a car sensor with no history, gives nothing to go by;
    • a second car with no Intelligent dispatches needs no sensor.
  • Wh is converted, and a W sensor is not used.
  • Charging below 0.5 kW counts as none, except for the minute its first step takes.
  • When the budget runs out inside a completed dispatch, both half hours stay cheap, the past over-cap minutes are those after it ran out, and the next planned dispatch is over the cap.

The new rate cases fail against main's octopus.py and 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

  • No later reading: a minute after a sensor's last change still counts until a later reading shows the car stopped. A car that finishes partway through a half hour and then stays quiet saves nothing until it next charges, or until a daily sensor resets at midnight.
  • Slow trickle: charging slower than 0.5 kW counts as none. Most chargers' minimum is about 1.4 kW, but a slow top-off would be under-counted.
  • Sparse sensors: a sensor that goes more than about two hours without recording while the car charges can still place a short charge in the wrong minutes.
  • Units: the record parsing handles kWh, Wh and MWh itself, rather than reusing minute_data(). A power-unit sensor (W or kW) is not used.
  • Billing, not yet settled: the reporter's first History billing for Mon 16 Nov shows every dispatch half hour (14:30–16:00 and 19:00–23:30) billed at the standard rate, including the first 90 minutes of the period, which are inside any reading of the cap. So that bill doesn't distinguish half-hour counting from charging-time counting, and may not be settled yet. The FAQ is the basis for this change; the PR stays a draft until the settled bill is in.

🤖 Generated with Claude Code

… 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

No deployments
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.

Octopus Intelligent GO 6 hour cap miscalculating charge time?

1 participant