Working an multi battery feature, feedback wanted on how to handle bi-directional ev charging #610
Replies: 9 comments 8 replies
|
I'm very interested in this capability and would like to work with you on this. I have a hybrid SigEnergy bidirectional charger and 2xEVs which I'm currently controlling using EMHASS. My fixed battery is 40 kWh and can discharge at 21 kW, when a vehicle is plugged in I then have +60 kWh and can discharge at 40 kW. To work with EMHASS I dynamically increase battery capacity to 160 kW (2x EV + fixed) and discharge rate to 30 kW when the vehicle is plugged in and both are at home. If the vehicles are not at home then I reduce to 40 kWh/ 21 kW. For vehicle charging I add a delay start_timestep of 2 hours if they are not home, so they get scheduled to charge, just not immediately. An end time step would be useful for battery performance and I would often like to force 100% SOC by sunset each day. https://v2g-liberty.eu/ provides a useful framework for bidirectional charging but I haven't implemented it yet.
|
EV charging defined as a deferrable load then? Creative thinking to increase battery capacity and battery power on the fly when connecting a V2G capable EV. Being able to set it as a separate battery should give you better results. Had a look at the https://v2g-liberty.eu/ link you sent. They use home assistant UI in combination with Flexmeasures (open source optimisation engine and alternative to emhass) . Using multiple batteries in combination with a schedule when the V2H device will be connected will allow us to do the same thing with emhass. You would need to create a translation from for example a calender schedule when the car will at home (or autodetect it or have a model predict it) and set the battery parameters in emhass. If i think about it some more, if you have multiple at home/away periods during your emhass optimisation window merely using using a start and end timestep wont cut it. A battery connected true/false list per optimisation step might be a better solution. Or only plan the next period the car will be connected.. (thinking out loud here) |
|
@JoshC1994 thanks for the ping. For clarity, my 0.17.9 changes were all single-battery work, so this would be a fresh build rather than a continuation of anything, but I'm keen. Before writing code I'd want to agree the shape with @davidusb-geek, so here's what I'd build. Phase 1: N stationary batteries Follow the deferrable-loads pattern: a Each battery gets its own charge/discharge variables and SOC trajectory, and the power balance sums over batteries. Two model-level points:
Phase 2, separately: intermittently connected batteries (V2G/V2H). @scruysberghs already had the right primitive earlier in this thread: a per-timestep connected true/false list per battery, which also covers multiple plug/unplug cycles where start/end pairs can't. The genuinely hard part is SOC continuity. SOC is currently one cumulative chain from a single Phase 3, later and over in #870: battery-to-inverter association for real multi-inverter setups. Out of scope here. @scruysberghs your @davidusb-geek no urgency, but if a phase-1 PR in roughly this shape would be welcome, I'll build it. Equally happy to adjust or drop it. |
|
An update since the last round of comments here: ffrog8 closed #1020 rather than run a competing design. The site-level direction lock in his proposal turned out to be a shortcut he was fine dropping, so there's no conflict left between the two shapes. His R1-R6 findings and the SOC-balance idea fold into phase 3, and he's asked to be tagged as this progresses. @davidusb-geek with that settled, phase 1 just needs your call on the shape: N stationary batteries via the same list pattern as the deferrables, scalars broadcast, nested battery weights, per-battery direction binary, no mode or ordering binaries, and single-battery configs mathematically unchanged with regression tests to pin that. If that works for you I'll build it as the next PR. If you want a different cut, cheaper to tell me now than after the code exists. |
|
Ok @LesIT1, let's greenlight Phase 1 exactly as you've described it. I strongly agree with your two model-level constraints:
Keeping the power balance as a simple sum across batteries, very much like how we handle multiple PV plants, keeps things clean. |
|
Thanks David, building it to that exact shape: array pattern like the deferrables, dispatch left to emerge from per-battery efficiencies and costs, epsilon tilt for tie-breaking only, power balance as a plain sum, and phases 2 and 3 firmly out of scope. Single-battery configs stay mathematically unchanged, with regression tests to pin that. @scruysberghs your prioritisation question is answered by David's second bullet: no priority knobs or ordering gates. Dispatch falls out of the per-battery efficiencies and weights, and if you want one-by-one behaviour in practice you can get it by giving batteries slightly different weights. The epsilon tilt only breaks exact ties so the solver stays deterministic. @ffrog8 tagging you as promised, the phase 1 schema will be in the PR for your review. |
|
@JoshC1994 yes, that's the one deliberately excluded piece. The identification estimator assumes a single power meter and a single SOC signal, so at N>1 it skips with a logged warning rather than fit garbage. It's called out in the PR notes under behaviour notes. The good news is that per-battery sensor pairs actually make the problem easier, not harder. Right now a single AC-side meter can only ever identify the fleet round-trip product. If each battery has its own I'd treat it as a follow-up PR: per-battery sensor keys in the config (list pattern, same as the rest of #1032), run the existing estimator once per battery, publish per-battery identified sensors. Since you're already running a multi-battery fleet with the sensors in HA, you'd be the ideal real-world test case. Can you share what your battery sensor entities look like? |






Uh oh!
There was an error while loading. Please reload this page.
I've been working on a feature to allow multiple batteries to be defined in emhass (comparable with how multipe deferrable loads are handled)

A feature I would like to add while I'm working on this is support for bi-directional ev charging. Basicly for emhass this is just another battery with a start soc and a charging goal (end soc). The only difference I see is that the car won't always be there. I was thinking this could be handled by using start_timesteps_of_each_battery and end_timesteps_of_each_battery (comparable with the comparable settings for each deferrable load start_timesteps_of_each_deferrable_load).
By default it will be from now until the end of the planning horizon for fixed batteries but it will allow you to set the period your bi-directional car will be connected and when it will leave beforehand.
Anyone here with a bi-directional car or an opinion on this?
All reactions