Heating rod configured to only use PV-surplus appears as a necessary/fixed household demand in optimpizer's plan
Scope
- [x] I have checked that the request is correct, and the problem is the plan the optimizer returns for it or a missing model capability.
Describe the problem
I have a my-pv ELWA2 heating rod for domestic hot water that is strictly set to use only excess PV surplus (controlled by evcc) and has priority 0. However, the optimizer appears to extrapolate the heating rod's energy consumption as a fixed household demand that needs to taken into account in the charging plan (see screenshot). Therefore the plan prioritized the heating rod over the battery (this only affects the plan, the actual charging priority works, so the battery gets charged first and the heating rod only uses the excess).
Great work by the way, otherwise the optimizer works like a charm!
Request
{
"batteries": [
{
"c_max": 3680,
"c_min": 1380,
"charge_from_grid": true,
"d_max": 0,
"p_a": 0.0003944457,
"s_initial": 8900,
"s_max": 8900,
"s_min": 0
},
{
"c_max": 3000,
"c_min": 0,
"charge_from_grid": true,
"d_max": 2800,
"p_a": 0.0003944457,
"s_capacity": 11000,
"s_initial": 2684,
"s_max": 11000,
"s_min": 440
}
],
"eta_c": 0.9,
"eta_d": 0.9,
"grid": {
"p_max_imp": 30000
},
"strategy": {
"charging_strategy": "charge_before_export",
"discharging_strategy": "discharge_before_import"
},
"time_series": {
"dt": [28, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900],
"ft": [27.064724, 891.8125, 913.6875, 935.5625, 953.71875, 968.15625, 982.59375, 997.03125, 989.25, 959.25, 929.25, 899.25, 856.625, 801.375, 746.125, 690.875, 611.1875, 507.0625, 402.9375, 298.8125, 215.90625, 154.21875, 92.53125, 30.84375, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"gt": [7.145159, 291.9081, 354.5242, 368.86932, 429.4253, 446.2109, 546.7809, 525.5947, 560.06335, 504.96466, 522.54114, 533.5486, 542.0459, 577.9852, 546.5076, 542.68207, 458.1476, 397.9311, 375.38013, 331.78442, 310.7251, 344.73688, 339.64722, 290.63492, 319.46777, 400.5863, 455.18536, 385.85867, 330.22122, 380.7809, 369.0611, 337.54004, 357.08344, 359.45905, 383.829, 426.0053, 387.59192, 339.04013, 331.24048, 296.622, 300.60147, 314.33936, 349.29553, 308.47784, 286.64365, 268.84424, 257.0033, 269.39066],
"p_E": [0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734, 0.0000734],
"p_N": [0.0004498, 0.0004498, 0.0004498, 0.0004498, 0.0004427, 0.0004427, 0.0004427, 0.0004427, 0.0004437, 0.0004437, 0.0004437, 0.0004437, 0.0004859, 0.0004859, 0.0004859, 0.0004859, 0.0005612, 0.0005612, 0.0005612, 0.0005612, 0.0006036, 0.0006036, 0.0006036, 0.0006036, 0.000625, 0.000625, 0.000625, 0.000625, 0.0006136, 0.0006136, 0.0006136, 0.0006136, 0.0005785, 0.0005785, 0.0005785, 0.0005785, 0.000549, 0.000549, 0.000549, 0.000549, 0.0005241, 0.0005241, 0.0005241, 0.0005241, 0.0004954, 0.0004954, 0.0004954, 0.0004954]
}
}
Response or plan
{
"batteries": [
{
"charging_power": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"discharging_power": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"state_of_charge": [8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900, 8900]
},
{
"charging_power": [19.919565, 599.9044, 559.1633, 566.6932, 524.29346, 521.9454, 435.81284, 471.43655, 429.18665, 454.28534, 406.70886, 365.7014, 314.5791, 223.3898, 199.6174, 148.19293, 153.0399, 109.1314, 27.55737, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"discharging_power": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32.97192, 94.81885, 190.51813, 247.11597, 259.79117, 319.46777, 400.5863, 455.18536, 385.85867, 330.22122, 380.7809, 369.0611, 337.54004, 357.08344, 359.45905, 383.829, 426.0053, 387.59192, 339.04013, 331.24048, 296.622, 300.60147, 314.33936, 9.623074, 0, 0, 0, 0, 0],
"state_of_charge": [2701.9275, 3241.8416, 3745.0884, 4255.1123, 4726.9766, 5196.7275, 5588.959, 6013.252, 6399.52, 6808.3765, 7174.4146, 7503.546, 7786.667, 7987.718, 8167.3735, 8300.747, 8438.483, 8536.701, 8561.503, 8524.867, 8419.514, 8207.826, 7933.253, 7644.596, 7289.632, 6844.536, 6338.7744, 5910.043, 5543.1304, 5120.0405, 4709.9727, 4334.928, 3938.1687, 3538.7698, 3112.293, 2638.9539, 2208.2961, 1831.585, 1463.5399, 1133.96, 799.95825, 450.6923, 440, 440, 440, 440, 440, 440]
}
],
"flow_direction": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"grid_export": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"grid_import": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 339.67245, 308.47784, 286.64365, 268.84424, 257.0033, 269.39066],
"grid_import_overshoot": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"limit_violations": {},
"objective_value": -1.760796,
"status": "Optimal"
}
I have the same problem. My current workaround is to turn the heating rod into an integrateddevice without heating feature so the optimizer skips it. It then runs only on the "traditional" surplus logic only.
It would be nice if there was a better model for this. In my case the heating rod replaces gas at 12.5ct/kWh, feed-in is 7.5ct/kWh so it can be expressed as a gain of 5ct/kWh in the LP.
Charging my car replaces grid energy at grid prices, usually with a higher gain.
I have some ideas around this but the problem is that they sound like we have to add a lot of things to evcc to hand that data to the optimizer (and blow up the optimizer model), I'd be curious what @andig thinks if this is in scope or not. Hybrid heating systems are very common out there, at least for a while still.
Thanks for the detailed report. This looks like a missing model capability rather than a defect. Heating loadpoints add their forecast demand to the household load (addHeatingDemand in core/site_optimizer.go) and the optimizer treats it as fixed consumption. It has no notion of a consumer that runs only on PV surplus (priority 0), so the plan reserves battery/grid energy for the heating rod while the real control loop correctly charges the battery first.
Fixing this would need a way to hand a "surplus only" or value-based consumer to the optimizer (e.g. excluding such heaters from the fixed demand, or modelling a gain per kWh), which needs a design decision from the maintainers. The workaround mentioned above (configuring the rod as an integrateddevice without the heating feature) keeps it out of the plan.
🤖 Generated with Claude Code
@JohannesRudolph @slymorian do your devices have continuous set or are they only operating on surplus? It's not clear to me how these should be modeled without a power demand being deductible with absence of an soc value.
Maybe we need an additional heating demand category https://github.com/evcc-io/evcc/pull/34342 like surplusonly.
@andig @JohannesRudolph Thanks, and yes, the workaround is fine I would think. In the case of the my-pv ELWA2 there could be an even better way, given that my-pv cloud already models the water boiler with the rod as a 'battery' with a SOC based on a minimum temperature (at which water enters the system), the set maximum temperature, the volume, and the dimensions (height, levels of temperature sensors) of the boiler. Via one of the my-pv integrations for home assistant, this sensor value is readily available to be used in EVCC. So I assume, one could create a custom loadpoint from this. But I am not sure that this would work as a generic approach to model heating devices (in a boiler). And it is probably still not straightforward how to deduct a power demand in kWh from this "virtual" SoC.
5. @JohannesRudolph @slymorian do your devices have
continuousset or are they only operating on surplus? It's not clear to me how these should be modeled without a power demand being deductible with absence of ansocvalue.
No, not running continuous as I run i run the heating rod purely on surplus. I have some other logic in HA to let evcc boost from battery in the morning if the optimizer plan allows (enough battery, no grid charge planned).
A surplusonly category as @naltatis suggested (#34342) could fit. Yes modelling the "how much surplus can this sink" is challenging but i also think its not needed. By having a configurable price for "surplus sinks" the optimizer can weigh this against a (dynamic) feed-in price. If any of the surplus sinks stops being able to capture more during the day, the optimizer can re-plan.
I see some problems for use cases where a user wants to plan the optimum feed-in time - in my case (germany, fixed EEG pricing with zero rating on negative grid prices) that's a non-issue though. Users that want to model this accurately need to "fake" a SoC for their loadpoints to give the optimizer an early heads up about how much energy they can sink.
I don't think this needs another category but it's still tricky. If you have a non-continuous (i.e. heatpump) device you control the charging, i.e. the optimizer can plan surplus and doesn't need to take are about a load profile. Downside: optimizer will not plan the device at all since it's not plannable in terms of consumption. It would also not take past demand into account (for cases where the pool pump is switched "on" every day in 9:00). And what's actually worse: even for a continuous device, the energy profile will contain the pv-charged sessions.
So I think the real question here is "what is the correct demand profile for a non-battery loadpoint, especially regarding forced and smart charging (example here: heating, but may also be another type).
Not sure if there's a good approach here. Maybe @daniel309 has an idea?
Summary of which energy profiles evcc collects, how they reach the optimizer request, and how the optimizer allocates energy (evcc master, optimizer main).
1. Collected energy profiles (metrics collectors)
| Collector | Source | Contents | Used by optimizer |
|---|---|---|---|
home |
grid + max(0,pv) + battery − totalChargePower (core/site.go) |
Everything that is not a loadpoint: base load, aux meters, consumer meters, ext meters, any device not controlled by evcc | Yes: 28-day daily average profile becomes gt. Average may be percentile instead if configured. |
meter (ext), consumer (aux/consumer) |
Monitoring and aux meters | Per-device energy | No, but their consumption remains part of home since it is not subtracted |
loadpoint chargeEnergy |
Loadpoint charge meter | Energy drawn by vehicle or heater | Only for heating loadpoints (demandProfile) |
pv |
PV meters | Production | No profile, only the solar forecast scale (forecast vs. actual) |
forecast |
Solar tariff | Forecast energy per slot | Only the solar forecast scale |
temperature |
Temperature tariff | Outdoor temperature | Temperature bins for DemandTemperature heaters |
grid |
Grid meter | Import/export | No |
battery |
Battery meters | Charge/discharge | No profile, the SoC is read live |
2. How each consumer enters the optimizer request
| Consumer | Condition | Request field | Shape | Mode handling |
|---|---|---|---|---|
| Household base load | Always | gt |
28-day profile, first 4 slots blended with the measured energy | n/a |
| Aux meter (self-regulating, surplus only) | Always | gt (part of home) |
Historic consumption as fixed demand | None: surplus-only consumption is treated as must-serve demand |
| Consumer/ext meter (not controlled by evcc) | Always | gt (part of home) |
Same | None |
heating loadpoint (status B/C) |
Not off, unless Continuous |
Added to gt (addHeatingDemand) |
28-day profile; 7-day temperature binned for DemandTemperature; per weekday for DemandWeekday |
None: a heater in pv mode is counted as fixed demand, which is the case reported here |
Loadpoint without vehicle capacity and energy limit (e.g. integrateddevice without heating, unknown vehicle) |
Status B/C | Added to gt (addUnmodelledLoad) |
Current power, decaying to 0 over 4 slots | Always-charge floor while charging, no forecast |
| Vehicle loadpoint | Status B/C with known capacity or energy limit | batteries[] as charge-only battery (d_max 0, charge_from_grid true) |
s_initial/s_max from SoC and limit SoC, or from charged energy and energy limit; c_min/c_max from effective power |
See 3. |
| Disconnected loadpoint | Status A | Not sent | ||
| Home battery | Capacity and SoC known | batteries[] |
c_max/d_max from power limits, s_min/s_max from SoC limits |
charge_from_grid/discharge_to_grid from supported battery modes; an external mode forces hold/charge/discharge; the grid charge limit becomes p_demand |
3. Vehicle loadpoint by mode
| Mode | Request | Result in the plan |
|---|---|---|
off |
c_max 0 |
Never charges |
now |
p_demand = max power per slot, capped at full |
Forced charging (soft constraint, high penalty) |
minpv |
Free battery only, minimum power is not forced | Charges only where economic |
pv |
Free battery only | Charges only where economic |
smart |
Free battery plus s_goal (plan) plus p_demand from always charge, smart cost limit and precondition |
Goal soft, forced slots taken |
4. How the optimizer allocates energy
Per slot: ft + grid_import + Σ discharge = gt + Σ charge + grid_export. gt is fixed: every Wh in it must be served from PV, battery or grid.
| Objective term | Type | Effect |
|---|---|---|
−import × p_N |
Cost | Avoids import at expensive times |
+export × p_E |
Revenue | PV is exported if nothing beats p_E |
+s_final × p_a per battery |
Terminal value | evcc sends one p_a for all batteries (vehicle and home): max(min(p_N)·η·0.99, min(p_E)/η·1.01), so surplus goes into storage if p_a·η > p_E |
p_demand shortfall |
Soft penalty | Forced charging (now, always charge, smart cost limit, battery grid charge limit) |
s_goal shortfall |
Soft penalty | Plan goals |
| Grid limit overshoot | Soft penalty | p_max_imp/p_max_exp |
charge_before_export |
Preference (tie-break) | Fill batteries before exporting, earlier first |
discharge_before_import |
Preference (tie-break) | Use batteries before importing |
c_priority |
Preference (tie-break) | Ranks batteries against each other. Not sent by evcc, loadpoint priority is not relayed |
| Peak attenuation | Preference | Flattens import/export peaks if configured |
| Continuity | Preference | Fewer charge starts for c_min > 0 devices |
Cost terms are solved first, preferences only break ties between equally cheap plans.
Resulting gaps
- Surplus-only consumers (aux meters, heaters in
pvmode) end up ingtas fixed demand. The plan sees less surplus and more evening load than will actually occur. - Loadpoint priority is not relayed (
c_priorityunused). Vehicle vs. home battery and vehicle vs. vehicle is decided by cost and tie-breaks only. - The
minpvminimum power is not modelled as demand. - There is no value of consumption per device: a single
p_afor all batteries, and no substitute price for loads like a heating rod replacing gas.
🤖 Generated with Claude Code
Tricky indeed. But maybe we are overcomplicating things here. It sounds like this is all about using a heating rod as a "use surplus before selling to grid" case.
The logic is: just use this loadpoint as the last resort of surplus use before exporting to grid. Only export to grid when this loadpoint is "full".
In this case, I dont think optimizer should be involved. Optimizer always plans on assumptions, predictions and forecasts, which are imprecise measures of future loads. The point of the heating rod is to counterbalance these inaccuracies and just deal with over/under estimations of load predictions and be a "catch rest".
So the simplest solution to this case would be a new device "feature flag", like continuous, heating or integrateddevice.
based on
No, not running continuous as I run i run the heating rod purely on surplus. I have some other logic in HA to let evcc boost from battery in the morning if the optimizer plan allows (enough battery, no grid charge planned).
maybe call it externally_controlled or notoptimized. Once a device has this flag set (in yaml), its load will be excluded from the home profile and it wont be considered by the optimizer as a sink. Still, the usual boost, smart etc. logic for "charging" applies as normal.
Summary of which energy profiles evcc collects, how they reach the optimizer request, and how the optimizer allocates energy (evcc
master, optimizermain).1. Collected energy profiles (metrics collectors)
Collector Source Contents Used by optimizer
homegrid + max(0,pv) + battery − totalChargePower(core/site.go) Everything that is not a loadpoint: base load, aux meters, consumer meters, ext meters, any device not controlled by evcc Yes: 28-day daily average profile becomesgt. Average may be percentile instead if configured.meter(ext),consumer(aux/consumer) Monitoring and aux meters Per-device energy No, but their consumption remains part ofhomesince it is not subtracted loadpointchargeEnergyLoadpoint charge meter Energy drawn by vehicle or heater Only forheatingloadpoints (demandProfile)pvPV meters Production No profile, only the solar forecast scale (forecast vs. actual)forecastSolar tariff Forecast energy per slot Only the solar forecast scaletemperatureTemperature tariff Outdoor temperature Temperature bins forDemandTemperatureheatersgridGrid meter Import/export NobatteryBattery meters Charge/discharge No profile, the SoC is read live2. How each consumer enters the optimizer request
Consumer Condition Request field Shape Mode handling Household base load Always
gt28-day profile, first 4 slots blended with the measured energy n/a Aux meter (self-regulating, surplus only) Alwaysgt(part ofhome) Historic consumption as fixed demand None: surplus-only consumption is treated as must-serve demand Consumer/ext meter (not controlled by evcc) Alwaysgt(part ofhome) Same Noneheatingloadpoint (status B/C) Notoff, unlessContinuousAdded togt(addHeatingDemand) 28-day profile; 7-day temperature binned forDemandTemperature; per weekday forDemandWeekdayNone: a heater inpvmode is counted as fixed demand, which is the case reported here Loadpoint without vehicle capacity and energy limit (e.g.integrateddevicewithoutheating, unknown vehicle) Status B/C Added togt(addUnmodelledLoad) Current power, decaying to 0 over 4 slots Always-charge floor while charging, no forecast Vehicle loadpoint Status B/C with known capacity or energy limitbatteries[]as charge-only battery (d_max 0,charge_from_grid true)s_initial/s_maxfrom SoC and limit SoC, or from charged energy and energy limit;c_min/c_maxfrom effective power See 3. Disconnected loadpoint Status A Not sent Home battery Capacity and SoC knownbatteries[]c_max/d_maxfrom power limits,s_min/s_maxfrom SoC limitscharge_from_grid/discharge_to_gridfrom supported battery modes; an external mode forces hold/charge/discharge; the grid charge limit becomesp_demand.......
Bit off-topic: I found these tables quite usefull and gives good insights on how it all fits together and interacts with the optimizer. Especially for tinkerers like me that have started using the optimizer to actually control the battery and loadpoints. Knowing this could also prevent people asking questions/making issues because they don't understand how the interaction is.
Would it be possible to add such info to the documentation sector of the optimzer?
I solved the heating rod/boiler issue for now by configuring it as a loadpoint and a vehicle with a virtual SoC. The capacity of the virtual battery is calculated as 1.163 Wh per Liter and Kelvin, which in my case of a 300 liters boiler, minimum temperature of 11 degrees Celsius and a maximum of 63 degrees yields some 18,14 kWh. That's very close to the my-pv-model and fits quite well with the data points I have so far on how much energy I can sink in the boiler and how this translates into the virtual SoC. This way, the optimizer treats the heating rod the way I want (loadpoint with the lowest priority, only surplus charging and no fixed demand in the plan). The only downside is, of course, that the state is displayed as a SoC-percentage not as a temperature, but I can live with that.
Suggestion for a minimal fix that needs no new config, feature flag or optimizer change:
addHeatingDemand (core/site_load_predictor.go) currently skips a heating loadpoint only when it is disconnected, or when it is in off mode without the continuous feature. A non-continuous heater in pv mode still gets its historic chargeEnergy profile added to gt, although in pv mode evcc only ever runs it from surplus. By definition that consumption is never must-serve demand.
Proposal: extend the existing off gate to pv mode:
// non-continuous devices in off or pv mode never draw must-serve energy
if mode := lp.GetMode(); (mode == api.ModeOff || mode == api.ModePV) && !lp.chargerHasFeature(api.Continuous) {
continue
}
now,minpvandsmartkeep the fixed demand profile, since those modes do draw grid or battery energy.- Continuous devices (heat pumps on their own schedule) are unaffected.
- Trade-off: the plan no longer expects the rod to absorb surplus, so it may show more export than actually happens. Since
charge_before_exportfills batteries first and the rod has lowest priority anyway, that does not change battery decisions.
This does not solve the broader point that the profile of a device switching between modes mixes surplus-only and forced sessions; that would need per-mode energy metrics. Longer term, evcc-io/optimizer#85 (leaky thermal store heating model) would let the optimizer plan such devices as sinks instead of fixed load.
🤖 Generated with Claude Code
Trade-off: the plan no longer expects the rod to absorb surplus, so it may show more export than actually happens. Since charge_before_export fills batteries first and the rod has lowest priority anyway, that does not change battery decisions.
Since these aren't batteries I also don't see what else we could do?
Had another discussion with claude. Instead of removing the demand we could also add daily remaining demand as charge-only battery. That would however still overstate demand if the profile contains many sunny days. Either one is wrong. Current PR version is much simpler.
So shall we go with the current state of the PR?