Closed
Conversation
Adds optional temperature correction to household load forecasts for the optimizer, allowing more accurate predictions when heating/cooling loads vary with outdoor temperature. Configuration (optional, in site config): - heatingThreshold: °C 24h avg above which corrections are disabled (default 12°C) - heatingCoefficient: fractional load change per °C delta (default 0.05 = 5%) Algorithm: 1. Gates on past 24h avg temperature vs threshold (heating active if below) 2. For each future slot, compares forecast temp to historical avg at same hour 3. Adjusts load: load *= (1 + coeff * (T_historical_avg - T_forecast)) - Colder forecast → higher load estimate - Warmer forecast → lower load estimate Requires the Temperature tariff (TariffUsageTemperature) to be configured. Changes household profile lookback from 30 days to 7 days because: - 7 days follows household rhythms more closely (weekly patterns) - Temperature changes too much over 30 days, making older data less relevant
- Separate heater load from base household consumption - Apply temperature correction only to heating devices (heat pumps, electric heaters) - Base loads (lighting, appliances) remain unchanged - Backward compatible: falls back to old behavior if no heating devices Changes: - Extended metrics DB to track per-loadpoint consumption - Added loadpoint energy tracking infrastructure in Site - Implemented profile extraction and aggregation functions - Modified homeProfile() to separate, correct, and merge profiles Addresses feedback on PR evcc-io#27780 that temperature adjustment should only apply to heating devices, not entire household consumption.
The fallback behavior was incorrectly applying temperature correction to the entire household profile when no heating devices or heater data were available. This defeated the purpose of heater profile separation. Temperature correction should ONLY be applied to heating device loads, never to the entire household consumption. When heating devices or data are not available, the profile should be returned uncorrected. This ensures: - Systems without heating devices: no temperature correction - Systems with heating devices but no data: no temperature correction - Systems with heating devices and data: correction only to heater load Fixes the logic to align with the design intent of separating base household loads (lighting, appliances, cooking) from temperature- dependent heating loads.
Added cautious logging to track heater profile extraction and separation: - DEBUG: Log when heater profile is extracted with slot count - DEBUG: Log when no heating devices/data, returning uncorrected profile - DEBUG: Log when applying temperature correction to heater profile only - WARN: Log when negative base load detected (heater > total consumption) - DEBUG: Detailed logging in extractHeaterProfile for each loadpoint This helps diagnose issues with: - Heating device detection - Historical data availability - Profile separation calculations - Temperature correction application Follows existing evcc logging patterns using site.log.DEBUG/WARN.
Changed temperature correction to be fully opt-in by removing default values for heatingThreshold and heatingCoefficient. The correction algorithm is now only active when BOTH values are explicitly configured. Before: Used defaults (12.0°C threshold, 0.05 coefficient) After: Skips correction if either value is 0 (not configured) This ensures users must consciously enable and tune the feature for their specific setup, preventing unexpected behavior with default values that may not suit all installations. Configuration required: heatingThreshold: 12.0 # Must be set explicitly heatingCoefficient: 0.05 # Must be set explicitly
4 tasks
632c566 to
3f774d1
Compare
Removed PR_DESCRIPTION.md and TEMPERATURE_CORRECTION_LOGIC_FIX.md. These are temporary development files not needed in the repository.
Both weather data and profiles are on 15-minute slots, so direct timestamp matching is simpler and more accurate than searching for the nearest rate.
Replace magic numbers with named constants: - MeterTypeHousehold = 1 - MeterTypeLoadpoint = 2 Makes the code more self-documenting and maintainable.
- Changed LoadpointNameHousehold from empty string to '_household' - Added default:'_household' to loadpoint column in GORM schema - Ensures automatic backfilling when column is added to existing databases - More explicit and maintainable than empty string identifier
Owner
Author
|
closed in favor of: evcc-io#28232 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Temperature-Based Household Load Correction with Heater Profile Separation
Base PR: evcc-io#27780 (Weather Tariff)
This PR: Heater Profile Separation for Temperature Correction
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:
Solution Overview
This PR builds on evcc-io#27780 (which added the
open-meteoweather tariff) and implements temperature-based correction of the household load profile with a critical improvement: the correction is applied only to heating device loads, not the entire household consumption.Key Innovation: Heater Profile Separation
The original approach (discussed in evcc-io#27780) applied temperature correction to the entire household profile. However, only heating/cooling loads are temperature-dependent. Base household loads (lighting, appliances, cooking, etc.) remain constant regardless of outdoor temperature.
This PR implements a three-step process:
gt_heater)gt_heaterTemperature Correction Algorithm
The correction algorithm (from base PR evcc-io#27780) remains unchanged:
where:
T_past_avg[h]= average temperature at hour-of-dayhover the past 7 daysT_forecast[i]= forecast temperature at the wall-clock time of slotiheatingCoefficient= fractional load sensitivity per °C (default 0.05 = 5%/°C)The correction is gated on the 24h average actual temperature of the past 24 hours. If that average is at or above
heatingThreshold(default 12°C), heating is considered off and no correction is applied to any slot.Example: With default settings and a 7-day historical average of 8°C:
Files Changed
core/metrics/db.gocore/site.gocore/site_optimizer.goConfiguration
The feature is fully opt-in — no changes needed for existing setups. Temperature correction is only active when explicitly configured.
To enable (requires base PR evcc-io#27780):
Important: Both
heatingThresholdandheatingCoefficientmust be explicitly configured. There are no default values. If either is missing (or 0), temperature correction is completely disabled.Tuning Guidance
heatingThreshold: Set to the 24h average outdoor temperature above which your heating system is fully off. Typical values: 10–15°C depending on building insulation. Start with 12°C for an average insulated house and adjust based on your system.heatingCoefficient: Represents how sensitive your heating load is to temperature changes. A well-insulated passive house might use 0.02–0.03; a poorly insulated older building might use 0.08 or higher. Start with 0.05 (5% per °C) and tune based on observed behavior.Backward Compatibility
The feature is completely opt-in and requires explicit configuration. Existing setups are unaffected.
Heating Consumption Always Included
Important: Heating device consumption is always added to the household profile, regardless of whether temperature correction can be applied. This ensures accurate total household load forecasts in all scenarios.
The algorithm works as follows:
Temperature Correction Conditions
Temperature correction is only applied to heating loads when ALL of the following conditions are met:
tariffs.temperature)api.Heatingfeature flag)heatingThresholdexplicitly configured (no default)heatingCoefficientexplicitly configured (no default)If any condition is not met, the uncorrected heating profile is used, but heating consumption is still added to the base load.
Key Points:
Multiple Heater Support
The implementation fully supports multiple heating devices:
api.Heatingfeature are automatically identifiedExample with 2 heaters:
This approach ensures that:
Database Schema
Adds
loadpointcolumn tometerstable with default value'_household'to distinguish between:The default value ensures existing household records are automatically backfilled when the column is added.
Migration is automatic via GORM AutoMigrate - no manual intervention required.
Benefits
Accuracy Improvements
Notes
api.Heatingfeature flag (heat pumps, electric heaters, etc.)Dependencies
api.Heatingfeature flag for device identification