batpred icon indicating copy to clipboard operation
batpred copied to clipboard

Support per-car charging plan time and max price for multi-car setups

Open janipoussu-ui opened this issue 4 days ago • 3 comments

Predbat already supports multiple cars via num_cars, with per-car settings such as car_charging_limit, car_charging_planned, car_charging_battery_size and car_charging_exclusive, plus a separate charging-slot sensor per car (binary_sensor.predbat_car_charging_slot, ..._slot_1, etc.).

However, select.predbat_car_charging_plan_time and car_charging_plan_max_price appear to be single, shared settings rather than per-car lists. This means two cars can have different target SOCs, but they are always planned against the same charge-by time and the same price cap.

In most setups both cars charge together overnight during the cheapest hours, so this isn't a blocker day to day. But it would be a useful improvement for cases where the cars have different battery sizes and finish at different times, one car needs to be ready by a specific time while the other doesn't, or only one car is present on a given night.

Would it be feasible to make car_charging_plan_time and car_charging_plan_max_price accept per-car lists (same pattern as car_charging_limit), so each of the num_cars cars can have its own independent schedule and price cap?

For context, discussion #3001 ("My setup to charge 2 cars with Predbat") shows another user working around the same limitation with manual input_select/template-sensor logic, suggesting there's real demand for native per-car scheduling.

janipoussu-ui avatar Nov 29 '26 11:11 janipoussu-ui

Thanks for the detailed write-up, and for pointing at the discussion. This is an automated first-pass triage — a maintainer will review before any action is taken.

Classification: enhancement

What I found on current main (v9.10.3)

You have read the code correctly, and the good news is that most of what you are asking for already exists inside the planner.

  • plan_car_charging() is already per-car: it reads self.car_charging_plan_max_price[car_n] and parses self.car_charging_plan_time[car_n] for the car it is planning, and each car already gets its own slot sensor. No planner change would be needed.
  • The Octopus Intelligent path already fills the ready time per car from your octopus_ready_time entries, so cars on IOG are not affected by this limitation. The gap is the Predbat-led path.
  • What is shared is only the config read. get_car_charging_planned() fills both arrays the same way for every car, with self.get_arg("car_charging_plan_max_price", 0.0) and self.get_arg("car_charging_plan_time", "07:00:00") — no index=car_n, and no _1, _2… siblings in CONFIG_ITEMS. Compare car_charging_battery_size, car_charging_limit and car_charging_exclusive, which a few lines earlier are read with index=car_n, which is why those work per car.
  • Both settings are single Home Assistant entities (select.predbat_car_charging_plan_time, input_number.predbat_car_charging_plan_max_price), so a plain list on those keys in apps.yaml is not a usable workaround today: there is no per-car read to consume it, and an invalid plan-time entry is caught in plan_car_charging() and every car falls back to 07:00 with a warning.

Shape a fix would probably take (my reading of the code, not a decision)

Follow the car_charging_rate family: add car_charging_plan_time_1…_7 and car_charging_plan_max_price_1…_7 config items, and read them in get_car_charging_planned() by the suffixed name, the way car_charging_rate already is. That family machinery is in place: UserInterface.car_list_families() / car_list_arg() split a base-name list in apps.yaml across a _1, _2… family, added for car_charging_rate in PR #5383, so car_charging_plan_time: ["06:00:00", "08:00:00"] would then work with only the siblings added. A maintainer will want to weigh that (seven more selects and seven more input_numbers, which every existing install would inherit) against an apps.yaml-only list; I have not decided anything here.

Related

  • #662 ("Start time and charge rate for more than one car", opened Jan 2024, still open) is the earlier request for the per-car ready time half of this, and the maintainer answered "certainly doable" at the time. The per-car rate half of it did land later, as the car_charging_rate family. Your request adds the per-car price cap, which #662 does not mention, so I have not closed this as a duplicate — but the ready-time part is the same ask and a fix should close both.
  • PR #5383 (merged) is the precedent for a car setting becoming per-car, and its notes mention the same trap you would hit: apps.yaml values only seed the item default, so anyone who already has input_number.predbat_car_charging_plan_max_price sitting at a value will need to set the per-car entities once after the change.
  • #3890 (and PRs #3891, #3892) is about a related but different ready-time limitation — a charge target more than 24 hours away — not per-car times.

springfall2008 avatar Nov 29 '26 11:11 springfall2008

Bot, can you develop a PR for this functionality please, adding additional select.predbat_car_charging_plan_time and car_charging_plan_max_price sensors as requested.

I believe the existing pattern is that car_charging_limit_1, _2, etc are only created based upon num_cars, so users do not get 7 sensors unnecessarily created, they only get the num_cars sensors created.

Changes will be required to code, tests and documentation to describe the new features.

gcoan avatar Nov 29 '26 16:11 gcoan

@janipoussu-ui we have a draft change to implement the multi-car functionality you asked for

Could you please test by copying the following changed files from the PR https://github.com/springfall2008/batpred/pull/6432 over the top of these files in your Predbat directory? Take a copy of the existing ones first

image

gcoan avatar Nov 29 '26 18:11 gcoan