Energy demand profile: to take heating into account
Temperature-Based Household Load Correction with Heater Profile Separation
Base PR: #27780 (Weather Tariff)
This PR: Heater Profile Separation for Temperature Correction
note: this PR doesn't change the database schema. It is based on, and uses the "history for meters" work merged via https://github.com/evcc-io/evcc/pull/23185.
TL/DR
With this PR optimizer forecasts for the household load are significantly improved when you have a heatpump device registered in evcc.
Before that they were barely useable because:
- heater loadpoints got subtracted from profile gt, and
- no temperature correction applied.
evidence of the effects of this PR: https://github.com/evcc-io/evcc/pull/28232#issuecomment-4070646368 explanation of the mathematical function to estimate corrections: https://github.com/evcc-io/evcc/pull/28232#issuecomment-4090251831
Problem
The evopt energy optimizer uses a household load profile (gt) to predict how much energy the home will consume in each future 15-minute slot. This profile is currently computed as a 30-day historical average — the same flat pattern is repeated regardless of weather conditions.
This is a significant blind spot: heating and cooling loads are strongly temperature-dependent. On a cold winter day, a home with a heat pump or electric heating can consume 30–80% more energy than on a mild day. When the optimizer doesn't know this, it:
- Under-estimates household demand on cold days → schedules EV charging at times when grid power is actually needed for heating
- Over-estimates household demand on warm days → unnecessarily avoids cheap/green charging windows
- Misses opportunities to pre-charge the battery before a cold night when heating demand will spike
Important: The evcc optimizer is a mathematical solver that optimizes EV charging and battery schedules based on given inputs (solar forecast, grid prices, household load). It cannot forecast household load itself—it requires accurate future household load predictions as input. Without temperature-corrected heat pump load forecasts, the optimizer receives inaccurate household demand predictions, leading to suboptimal charging decisions that conflict with actual heating needs.
Solution Overview
This PR builds on #27780 (which added the open-meteo weather tariff) and implements temperature-based correction of the household load profile with a critical improvement: the correction is applied only to heating device loads that are explicitly marked as temperature-sensitive.
Key Innovation: Selective Temperature Correction
Not all heating devices have temperature-dependent loads. For example:
- Heat pumps are highly temperature-dependent
- Auxiliary electric heaters may be temperature-dependent (more electricity because its colder outside) or not when used for warm water.
This PR implements a four-step process:
- Identify: Detect which heating devices are temperature-sensitive via the
OutdoorTemperatureSensitivefeature flag - Separate: Extract temperature-sensitive and non-sensitive heater profiles separately
- Correct: Apply temperature adjustment only to temperature-sensitive heaters
- Merge: Combine base load + corrected temp-sensitive heaters + uncorrected non-sensitive heaters
Total Household = Base Load + Temp-Sensitive Heaters + Non-Sensitive Heaters
(gt_base) (gt_temp_corrected) (gt_non_sensitive)
↓ ↓ ↓
[unchanged] [temp corrected] [unchanged]
↓ ↓ ↓
Final Profile = gt_base + gt_temp_corrected + gt_non_sensitive
Note on Historical Data Periods:
- Base load profile: 30-day historical average (excludes all loadpoints)
- Heater profiles: 7-day historical data (for both temp-sensitive and non-sensitive)
- Temperature averaging: 7-day historical average per hour-of-day for correction calculation
Temperature Correction Algorithm
The correction algorithm uses a physics-based model that relates heating load to the temperature difference between indoor and outdoor conditions:
which becomes:
load[i] = load_avg[i] × ((T_room − T_forecast[i]) / (T_room − T_past_avg[h]))
where:
T_room= 21°C (constant room temperature)T_past_avg[h]= average temperature at hour-of-dayhover the past 7 daysT_forecast[i]= forecast temperature at the wall-clock time of sloti
This formula models heating load as proportional to the temperature difference that must be maintained. The correction factor represents the ratio of future heating demand to historical average demand.
Safety Check: If historical temperature is within 0.5°C of room temperature (indicating heating was likely off), the correction is skipped for that time slot.
Clamping: Correction factors are clamped to the range [0.5, 2.0] to prevent extreme corrections from bad data.
Example: With a 7-day historical average of 8°C at a given hour:
- Forecast 8°C → no correction (factor = (21-8)/(21-8) = 1.0)
- Forecast 3°C → +38% heater load (factor = (21-3)/(21-8) = 1.38)
- Forecast −2°C → +77% heater load (factor = (21-(-2))/(21-8) = 1.77)
- Forecast 13°C → −38% heater load (factor = (21-13)/(21-8) = 0.62)
Configuration
The feature is fully opt-in — no changes needed for existing setups. Temperature correction is only active for heating devices explicitly marked as temperature-sensitive.
Basic Setup (requires base PR #27780)
tariffs:
temperature:
type: template
template: open-meteo-temperature
latitude: 48.1
longitude: 11.6
chargers:
- name: heatpump
type: template
template: luxtronik
host: 192.168.1.10
# Luxtronik template includes outdoortemperaturesensitive by default
- name: water_heater
type: custom
features:
- heating # Mark as heating device
# No outdoortemperaturesensitive - no correction applied
Configuration Details
Temperature Tariff (required for correction):
- Must be configured as shown above
- Provides historical and forecast temperature data from Open-Meteo
Heating Device Features:
heating- Marks the device as a heating system (required for all heating devices)outdoortemperaturesensitive- Enables temperature correction for this specific device (optional)
Important:
- Devices with only
heatingfeature will have their consumption included in forecasts but without temperature correction - Devices with both
heatingandoutdoortemperaturesensitivewill have temperature correction applied - This allows mixing temperature-dependent devices (space heating heat pumps) with schedule-based devices (water heaters, pool heaters)
Backward Compatibility
The feature is completely opt-in and requires explicit configuration. Existing setups are unaffected.
Multiple Heater Support
The implementation fully supports multiple heating devices with selective correction:
- Automatic Detection: All loadpoints with
api.Heatingfeature are automatically identified - Selective Correction: Only devices with
api.OutdoorTemperatureSensitiveget temperature correction - Individual Tracking: Each heater's consumption is tracked separately in the database using its loadpoint ID
- Slot-by-Slot Aggregation: Multiple heater profiles are summed together for each 15-minute slot
- Separate Processing: Temperature-sensitive and non-sensitive heaters are processed independently
This approach ensures that:
- Each heater's historical pattern is preserved
- Only temperature-dependent loads are adjusted for weather
- Schedule-based heaters remain predictable
- Total heating load is accurately represented
- Works with any number and combination of heating devices
Database Schema
Uses the new entity and meters tables introduced by PR https://github.com/evcc-io/evcc/pull/23185.
Dependencies
- Requires base PR #27780 (Weather Tariff) to be merged (makes lots of changed files in this PR go away)
- No new external dependencies
- Uses existing
api.Heatingfeature flag for device identification - Adds new
api.OutdoorTemperatureSensitivefeature flag for selective correction
First thing is to get https://github.com/evcc-io/evcc/pull/23185 in.
This contribution does not appear to meet our AI contribution guidelines.
@naltatis this PR shows general understanding of evcc and has prior PRs. Fine for me.
ill add more evidence for local testing and benefits once I have the build green. should be there is a bit.
ai reviews addressed as follows ✅ Comment 2: Fixed goroutine loop variable capture ✅ Comment 3: Fixed zero default temperature handling with debug logging ✅ Comment 4: Implemented map-based rate lookup for clarity ✅ Linter: Fixed all gci formatting issues ❌ Comment 1: Not applicable (Go 1.22+ syntax valid) ❌ Overall: Not applicable (no concurrent map access issue)
ok, ready for review.
because Base PR: https://github.com/evcc-io/evcc/pull/27780 (Weather Tariff) is open,
only look at these 3 files below. The rest are the temperature tariff code changes that go away once that PR is merged.
ill continue local testing and add evidence from the sqllite db, about migration (using my evcc.db file from latest) and most importantly, about the added precision of household load forecasts.
With this PR optimizer forecasts are finally useable when you have a heatpump device registered in evcc.
Before that they were unuseable because:
- heater loadpoints got substracted from profile
gt, and - no temperature correction applied.
update: db schema changes removed. see PR description. no more additional loadpoint column.
@andig I removed any db schema change from this PR, so this is now independent of https://github.com/evcc-io/evcc/pull/23185.
see
Just tested compatibility with v0.303. works fine without issues.
also, table "meter" remains lean which is a good thing. adding a varchar added significant volume to the file (20 bytes per each row...)
the offset between meter ids and loadpoint ids is now 1000 to give enough space between the two for all practical numbers of meters and loadpoints.
evidence of the entire process working and about the impact on optimizer forecast and corrections.
log messages of a working system:
[site ] DEBUG 2026/03/16 21:57:28 optimizer: optimizing 105 slots until 2026-03-18 00:00:00 +0100 CET: grid=105, feedIn=585, solar=193, first slot: 2m31s
[site ] DEBUG 2026/03/16 21:57:28 heater profile: querying 1 heating loadpoint(s)
[site ] DEBUG 2026/03/16 21:57:28 heater profile: loadpoint 0 has 96 slots of data
[site ] DEBUG 2026/03/16 21:57:28 heater profile: aggregated 1 heating loadpoint(s) into 96 slots
[site ] DEBUG 2026/03/16 21:57:28 home profile: extracted heater profile with 96 slots
[site ] DEBUG 2026/03/16 21:57:28 home profile: attempting temperature correction on heater profile
[site ] DEBUG 2026/03/16 21:57:28 temperature correction: slot 21:45 (hour 20): forecast=4.3°C, hist_avg=6.3°C, delta=2.0°C, load: 200Wh -> 220Wh (9.9%)
[site ] DEBUG 2026/03/16 21:57:28 temperature correction: slot 22:00 (hour 21): forecast=4.3°C, hist_avg=6.1°C, delta=1.8°C, load: 182Wh -> 198Wh (8.8%)
[site ] DEBUG 2026/03/16 21:57:28 temperature correction: slot 22:15 (hour 21): forecast=4.3°C, hist_avg=6.1°C, delta=1.8°C, load: 150Wh -> 163Wh (8.8%)
-> see how the heater profile slots got adjusted based on temperature forecast
here is the result in the optimizer. see the wavy pattern of a modulating heatpump, how de-icing was running around 5am and how warm water was produced starting around noon.
now here is the same optimizer profile without the temperature adjustments (you see differences in the range of 10% as per log messages above temperature didnt change that much between profile avg and tomorrow)
[site ] DEBUG 2026/03/16 22:06:43 temperature correction: heatingThreshold or heatingCoefficient not configured, skipping correction
and finally, here is the exact same optimizer picture from vanilla evcc v0.303. Completely different household load and honestly not very useable/realistic.
#######################
@andig relevant code is in these 3 files. the remaining changes are all from the base PR (temperature tariff)
did a rebase to master. if desired, I can do squashes to group those commits better.
Thank you for this interesting PR!
I have a few conceptual comments:
I think it is necessary to distinguish between the actual types of heat generation used for each heating appliance. Not every ‘heating system’ automatically has temperature-dependent consumption. For example, a heat pump can be used in at least three different scenarios:
- Heating the building only (depending on the outside temperature)
- Providing hot water only (temporarily) (not, or only to a limited extent, dependent on the outside temperature)
- Doing both together or alternating between them at times
The same applies to other types of heating, such as electric heating elements.
Unfortunately, there are also many other interfering factors in hybrid configurations where, for example, additional heating is provided by other (fossil fuel) heat generators below certain temperatures, or where the output of an existing solar thermal system is also taken into account.
Furthermore, I would suggest simplifying the configuration of the temperature-dependent load profile by using a load curve defined by two temperature points (min/max). It may also be necessary to include a cut-off temperature at which the power consumption is assumed to be 0. The simple heating curve setting on Panasonic Aquarea heat pumps could serve as a model.
Perhaps, through a careful selection of configuration options, it would be possible to adequately represent at least the most common hybrid systems.
Not every ‘heating system’ automatically has temperature-dependent consumption.
and
Unfortunately, there are also many other interfering factors in hybrid configurations where, for example, additional heating is provided by other (fossil fuel) heat generators below certain temperatures, or where the output of an existing solar thermal system is also taken into account.
and
Furthermore, I would suggest simplifying the configuration of the temperature-dependent load profile by using a load curve defined by two temperature points (min/max). It may also be necessary to include a cut-off temperature at which the power consumption is assumed to be 0. The simple heating curve setting on Panasonic Aquarea heat pumps could serve as a model.
Agreed. I wanted to rework the configuration parts next. My plan is to move configuration up to individual charger, remove from site. I.e. the items
heatingThreshold: 12.0 # °C — 24h avg above which corrections are disabled
heatingCoefficient: 0.05 # fraction — load changes by this fraction per °C delta
will go away in favour of one single (optional) config entry for the "heating" charger and if its load should be scaled according to outdoor temperature or not.
Also, heatingThreshold will go away as part of this excercise, the heater itself decides when to heat or not. When its not heating, load is 0 and I can just scale that (effectively doing nothing).
I like the idea of the model being based on a heatcurve. I can calculate the coefficient from the two points given.
But I am also playing with an alternative model that simply looks at the load (Q) and scales it according to
Its more accurate it seems and it also doesnt need any external config, which is always preferable :-)
Ill play a bit more on my system and then decide.
All changes implemented, including adding the OutdoorTemperatureSensitive feature to the luxtronik.yaml template. Ill let other template maintainers add this flag once merged.
I also updated the PR description to describe the updated approach.
Ill continue to test this PR on my system. The new algorithm looks much better.
Example trace with the latest changes
[site ] DEBUG 2026/03/19 13:59:49 optimizer: optimizing 137 slots until 2026-03-21 00:00:00 +0100 CET: grid=137, feedIn=617, solar=196, first slot: 10s
[site ] DEBUG 2026/03/19 13:59:49 heater profile: querying 1 heating loadpoint(s)
[site ] DEBUG 2026/03/19 13:59:49 heater profile: loadpoint 0 has 96 slots of data (temperature-sensitive: true)
[site ] DEBUG 2026/03/19 13:59:49 heater profile: aggregated 1 temperature-sensitive heating loadpoint(s) into 96 slots
[site ] DEBUG 2026/03/19 13:59:49 home profile: extracted temperature-sensitive heater profile with 96 slots
[site ] DEBUG 2026/03/19 13:59:49 home profile: applying temperature correction
[site ] DEBUG 2026/03/19 13:59:49 temperature correction: slot 13:45 (hour 12): forecast=13.7°C, hist_avg=9.4°C, factor=0.631, load: 125Wh -> 79Wh (-36.9%)
[site ] DEBUG 2026/03/19 13:59:49 temperature correction: slot 14:00 (hour 13): forecast=13.8°C, hist_avg=9.1°C, factor=0.607, load: 125Wh -> 76Wh (-39.3%)
[site ] DEBUG 2026/03/19 13:59:49 temperature correction: slot 14:15 (hour 13): forecast=13.9°C, hist_avg=9.1°C, factor=0.599, load: 125Wh -> 75Wh (-40.1%)
cc: @premultiply @andig
Why the Change to a Ratio-based Function for Heating Load Correction?
Function 1 is preferred because it directly models heating physics: heat loss is proportional to temperature difference from room temperature (Q ∝ ΔT). When the baseline is 5°C (ΔT = 16°C) and forecast drops to 0°C (ΔT = 21°C), heating demand increases by the ratio 21/16 = 1.31, which is physically accurate. Function 2's linear 5%/°C assumption underestimates this by treating all temperature changes equally, regardless of the absolute temperature difference from room temperature.
This behavior is modelled as follows:
which becomes:
load[i] = load_avg[i] × ((T_room − T_forecast[i]) / (T_room − T_past_avg[h]))
Since heating usually only active below ~15°C average temperature, Function 1's instability issues (which only occur when T_past_avg approaches T_room = 21°C) are irrelevant in practice. The current implementation already includes a safety check (math.Abs(denominator) < 0.5) that prevents edge cases, making Function 1 both physically accurate and operationally safe for heating optimization.
The graph shows that in realistic heating scenarios (-5°C to 10°C baselines), Function 1 (blue) provides more accurate load predictions that better match the non-linear relationship between temperature and heating demand, while Function 2 (red) consistently underestimates the impact of temperature changes.
Background:
Function 1. load[i] = load_avg[i] × ((T_room − T_forecast[i]) / (T_room − T_past_avg[h]))
Function 2. load[i] = load_avg[i] × (1 + heatingCoefficient × (T_past_avg[h] − T_forecast[i]))
with
t_room = 21
heatingCoefficient=0.05
T_past_avg[h] = average temperature at hour-of-day h over the past 7 days
T_forecast[i] = forecast temperature at the wall-clock time of slot i
heatingCoefficient = fractional load sensitivity per °C
Was solar radiation taken into account in the calculation of the heating energy demand? For houses with large window areas, the heating energy demand in winter can depend on solar radiation.
Was solar radiation taken into account in the calculation of the heating energy demand? For houses with large window areas, the heating energy demand in winter can depend on solar radiation.
Solar radiation from windows is not taken into account. Its tough to model that. And I would argue it probably doesnt affect the forecast too much.
This situation happens during daylight, which is exactly when PV produces power as well. So it could be that the correction algorithm overestimates heating load for when the sun shines bright, but it will not matter much in practice as at that same time there is usually plenty of excess PV energy anyways and the optimizer deals with excess in those slots already.
In addition, when heating switches off because of solar, this load change is taken into the historical profile (smoothed by the 7-day avg) and will affect future day forecasts.
If you have such a situation, it would be great if you could try this PR and see how it behaves. I am curious.
I can offer a binary with this PR's changes if that makes testing easier for you @florian240483
some more data on how impactful heating load corrections based on forecasts are: we have a temperature drop here in my area for the next days. Look at the min/max temp values and how it varies:
Today is where temperature drops are very steep, and here are a few samples of the load corrections applied based on how historical load/temperature differs from forecast
Granted, its an extreme example and one of the joys of late March weather I guess.
[site ] DEBUG 2026/03/25 13:44:32 temperature correction: slot 13:30 (hour 12): forecast=7.3°C, hist_avg=11.6°C, factor=1.464, load: 95Wh -> 139Wh (46.4%)
[site ] DEBUG 2026/03/25 13:44:32 temperature correction: slot 13:45 (hour 12): forecast=6.6°C, hist_avg=11.6°C, factor=1.539, load: 114Wh -> 176Wh (53.9%)
[site ] DEBUG 2026/03/25 13:44:32 temperature correction: slot 14:00 (hour 13): forecast=6.1°C, hist_avg=12.4°C, factor=1.736, load: 151Wh -> 262Wh (73.6%)
Hi there,
I have a slight different use case that fits in here quite well.
Rather than heating, I have a room to deep freeze (-28°C) through electricity.
Weather obviously is a big factor for energy consumption of this energy sink.
I don't know if you are here always optimizing to have a steady temperature in a house? For us, going to -32°C would be possible as long as we are consuming 100% of excess energy. So we can use the freezer as a energy storage rather then selling the excess energy for pennies on a dime.
Would love to hear if this optimizing function would also work the other way around (freeze instead of heat).
Cheers 🙂
hmm, interesting use-case. Thanks for sharing @gramss. In theory this PR could help in this situation, as I assume the freezer needs somewhat proportionally more energy to reach the desired -28C if it gets warmer outside. So it could help to correct historical load profiles based on weather forecast temperatures.
It would need a change though: for heatings, energy consumption reduces as its gets warmer outside. For your freezer, its the opposite: energy consumption increases as it gets warmer. Its the exact opposite.
Best option I see is to introduce another feature flag for the loadpoint. Instead of the "OutdoorTemperatureSensitive" flag introduced by this PR, it would need to be something like
"LoadProportionalToOutdoorTemperature" (cooling) vs.
"LoadAntiProportionalToOutdoorTemperature" (heating).
Additionally, it would need
- a new "past 24h avg outdoor temperature" threshold that helps to decide which mode to use in case both flags are used for the same loadpoint.
- a configurable "room" temperature (as your freezer wants to stay at -28) per loadpoint. Today, its 21C internal default.
I know some people use their heatpumps for cooling the house in the summer, so this generally sounds like a useful future extension.
Proposal how to use the new entity and meters tables introduced by PR https://github.com/evcc-io/evcc/pull/23185.
This allows to remove the +1000 offset used in this PR for loadpoint tracking. Instead, the database would look like this with the new structure when we add historical tracking for each "heating" type loadpoint.
Or use group "heating" instead?
entities table:
id | group | name
---+------------+-------------
1 | home | home
2 | grid | grid-meter
3 | pv | pv-meter-1
4 | loadpoint | loadpoint-0
5 | loadpoint | loadpoint-1
meters table:
meter | timestamp | import | export
------+--------------------+--------+--------
1 | 2026-03-31 09:00:00| 1.5 | 0.0
4 | 2026-03-31 09:00:00| 2.3 | 0.0 <- loadpoint 0
5 | 2026-03-31 09:00:00| 1.8 | 0.0 <- loadpoint 1
fyi @andig ^^
Now that metrics have landed we can start collecting pv/battery/loadpoint metrics. PRs welcome!