Skip to content

Allow car charge ready-by date more than 24 hours in the future#3891

Open
Pezmc wants to merge 2 commits into
springfall2008:mainfrom
Pezmc:Pezmc/extend-car-charge-by-window
Open

Allow car charge ready-by date more than 24 hours in the future#3891
Pezmc wants to merge 2 commits into
springfall2008:mainfrom
Pezmc:Pezmc/extend-car-charge-by-window

Conversation

@Pezmc
Copy link
Copy Markdown

@Pezmc Pezmc commented May 8, 2026

Closes #3890.

Adds a new select.predbat_car_charging_plan_date so 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 today
up until min(forecast_plan_hours, 96) / 24 days.

When the chosen date passes, it's removed from the list and the entity automatically reverts to "Default".

When plan_date is set and in the future, the plan engine anchors ready_minutes to that absolute date plus the existing
car_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.py mock widened to accept **kwargs since the new helper passes force=True. Full quick suite green, pre-commit clean.

Pezmc added 2 commits May 8, 2026 11:07
…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.
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.

Car charge target more than 24 hours away

1 participant