Retain past manual import/export rate overrides so cost_today and the savings baseline price consumed energy correctly - #5078
Conversation
…he savings baseline price consumed energy correctly
Manual import/export rate overrides were dropped as soon as their slot
passed, so today_cost() fell back to the base tariff for energy that had
already been consumed at the overridden price, and the yesterday savings
baseline (which shifts the rate table back a day) never saw them either.
Keep import/export overrides for 24 hours after their slot, writing them
back with an absolute date ("YYYY-MM-DD HH:MM") so they do not resolve to
next week once the weekday has passed. get_override_time_from_string()
accepts the absolute format, and manual_select() matches stored entries
by resolved slot so the plan card can still clear or replace a past slot
by its weekday label. Retained overrides also show on the published rate
charts and plan for the slots they cover.
manual_soc / manual_load / manual_soc_max keep the old behaviour of
dropping past slots. Adds test_manual_rates_history covering retention
for import and export, flow-through into the rate table at today's and
yesterday's minutes, clearing, replacement and the 24-hour cut-off, plus
absolute-date cases in the override_time tests. Documents the behaviour
in docs/customisation.md.
|
Not a firm pushback - thinking out loud. I thought we should be fetching octopus information that would correctly show free hours without manual overrides - but that is going from memory. |
I fully agree that integration is the best in practice for this use case and should be added, but it's not the only reason I've ever overridden (a while ago USwitch offered free electricity for a period too and to my knowledge this isn't integrated in a way predbat could work with). Potentially with other providers too, but I don't know for sure. My counter would be that if a user overrides the rate they're paying/importing at, it doesn't make sense that the costing in the entity doesn't account for this. As a user, I told it these hours are free, but ended up over accounting by nearly £2 and there's no way to get the real value I programmed in. I do get your point, it's a change to previous behaviours if someone is anticipating that to add up with the original tariff values, but it feels like the wrong way to achieve it when you can specifically force an action or set a favoured battery level, which don't have the side effect of messing up costing. |
|
I agree that if you manually override costs, then it should be reflected in calculations. |
Problem
Using the Octopus free weekend hours, I manually set the pricing for those two 30 min slots to 0, to allow predbat to calculate correctly. However, I noticed in the totals, it was still showing as if I hadn't nil rated it.
Manual import/export rate overrides (
select.predbat_manual_import_rates/manual_export_rates) were dropped assoon as their slot passed. Two things went wrong as a result:
predbat.cost_today(andcost_today_import/cost_today_export/cost_today_car) fell back to the base tarifffor energy that had already been consumed at the overridden price, so the running total for the day was wrong.
calculate_yesterday()shifts the live rate table back a day, so it never saw theoverride either, while
cost_yesterday(read back from the recordedcost_todayhistory) did. The two sidesdisagreed on any day with an override.
Octopus saving sessions and Axle VPP sessions don't have this problem because they persist in the API session list
after the slot ends. This brings manual overrides in line with them.
Fix
manual_rates()keeps import/export overrides for 24 hours after their slot (today and yesterday). Other manualitems (
manual_soc,manual_soc_max,manual_load_adjust) are unchanged and still drop past slots.2025-12-19 11:00=0.0) instead ofFri 11:00=0.0, so once theweekday has passed they don't resolve to next week.
get_override_time_from_string()accepts the absolute format.manual_rate_same_slot()helper matches stored entries by resolved slot, so the plan card can still clear orreplace a past slot using its weekday label.
read the same rate tables.
Tests
manual_rates_historytest: retention for import and export, flow-through intorate_importat today's minutesand at yesterday's negative minutes (where the savings baseline reads), clearing by weekday label, replacement
without duplication, dropdown options, and the 24-hour cut-off.
override_time.Docs
Added a paragraph to
docs/customisation.mddescribing the retention and the absolute-date form shown in theselector.