Allow car charge ready-by date more than 24 hours in the future#3891
Open
Pezmc wants to merge 2 commits into
Open
Allow car charge ready-by date more than 24 hours in the future#3891Pezmc wants to merge 2 commits into
Pezmc wants to merge 2 commits into
Conversation
…ice, plan_time These three reads at fetch.py:1887-1889 lacked the index=car_n argument that adjacent lines (car_charging_battery_size, car_charging_limit, car_charging_exclusive) already use. The result was that with num_cars > 1, all cars shared the same plan_smart, plan_max_price, and plan_time value rather than honouring per-car overrides like car_charging_plan_time_1. Single-car configs are unaffected (index 0 falls back to the scalar).
Adds select.predbat_car_charging_plan_date alongside the existing car_charging_plan_time so the ready-by deadline can extend beyond 24 hours. Useful when the car isn't going to be used for a couple of days (weekend, holiday) and you want Predbat to pick the cheapest charging slots across the whole window rather than cramming everything into the next 24 hours. The dropdown is populated dynamically each plan cycle following the manual_times pattern. Options are absolute dates from today out to min(forecast_plan_hours, 96) // 24 days, plus a "Default" sentinel that preserves the existing 24-hour wrap behaviour exactly. When the chosen date passes, the entity reverts to "Default" automatically so episodic configurations can't go stale. Plan engine: when plan_date is set and in the future, ready_minutes is anchored to that absolute date plus the existing time-of-day. Past dates, "Default", today, and unparseable values fall through to the existing wrap-around. Octopus Intelligent cars are unaffected since their charging flow already bypasses plan_car_charging. Includes unit tests covering Default, today, future date, invalid input, multi-day window, options-respect-horizon, and stale-past auto-decay. Updates docs/car-charging.md with the feature description, horizon caveat, and rate-replication caveat for variable tariffs. Also widens the test_fetch_config_options expose_config mock to accept **kwargs since the new options helper passes force=True.
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.
Closes #3890.
Adds a new
select.predbat_car_charging_plan_dateso the car charging ready-by deadline can be pushed beyond 24 hours.Useful when the car isn't going to be used for a couple of days (weekend, holiday) and you want Predbat to pick the cheapest slots across the whole window.
Default value is "Default", which preserves the existing 24-hour wrap behaviour exactly. Excisting users see no change in behaviour.
Caveat: The list is limited by
forecast_plan_hours, which defaults to 24 hours, users need to bump the plan length to benefit.How it works
The dropdown is rebuilt each plan cycle following the same pattern as
manual_times. It adds absolute dates from todayup until
min(forecast_plan_hours, 96) / 24days.When the chosen date passes, it's removed from the list and the entity automatically reverts to "Default".
When
plan_dateis set and in the future, the plan engine anchorsready_minutesto that absolute date plus the existingcar_charging_plan_time.Past dates, "Default", today, and unparseable values fall through to the existing 24-hour wrap.
Octopus Intelligent cars are unaffected since their charging already bypasses
plan_car_charging.Existing
tests/test_fetch_config_options.pymock widened to accept**kwargssince the new helper passesforce=True. Full quick suite green, pre-commit clean.