feat(measurement): treat long *_emr_keys meter gaps as unknown

Additional fixes:
Add timezone to loadakkudoktoradapted tests datetime generation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
This commit is contained in:
Bobby Noelte
2026-11-15 18:30:00 +01:00
co-authored by Claude Opus 5.5
parent f441759dfa
commit cc875f798c
13 changed files with 179 additions and 25 deletions
+2 -1
View File
@@ -277,7 +277,8 @@
],
"pv_production_emr_keys": [
"pv1_emr"
]
],
"emr_max_gap_seconds": 10800
},
"optimization": {
"algorithm": "GENETIC",
+4 -1
View File
@@ -8,6 +8,7 @@
| Name | Environment Variable | Type | Read-Only | Default | Description |
| ---- | -------------------- | ---- | --------- | ------- | ----------- |
| channels | `EOS_MEASUREMENT__CHANNELS` | `dict[str, akkudoktoreos.measurement.measurement.MeasurementChannelSettings]` | `rw` | `required` | Typed raw measurement channels keyed by measurement key. |
| emr_max_gap_seconds | `EOS_MEASUREMENT__EMR_MAX_GAP_SECONDS` | `Optional[int]` | `rw` | `10800` | Longest gap between two readings of a `*_emr_keys` meter [s] whose energy is spread evenly over the gap. A longer gap has no energy value (unknown) instead. A meter with its own `channels` entry uses that entry's `max_gap_seconds`. None spreads every gap evenly. |
| energy_context_seconds | `EOS_MEASUREMENT__ENERGY_CONTEXT_SECONDS` | `int` | `rw` | `86400` | None |
| grid_export_emr_keys | `EOS_MEASUREMENT__GRID_EXPORT_EMR_KEYS` | `Optional[list[str]]` | `rw` | `None` | The keys of the measurements that are energy meter readings of energy export to grid [kWh]. |
| grid_import_emr_keys | `EOS_MEASUREMENT__GRID_IMPORT_EMR_KEYS` | `Optional[list[str]]` | `rw` | `None` | The keys of the measurements that are energy meter readings of energy import from grid [kWh]. |
@@ -42,7 +43,8 @@
],
"pv_production_emr_keys": [
"pv1_emr"
]
],
"emr_max_gap_seconds": 10800
}
}
```
@@ -72,6 +74,7 @@
"pv_production_emr_keys": [
"pv1_emr"
],
"emr_max_gap_seconds": 10800,
"keys": [
"grid_export_emr",
"grid_import_emr",
+1 -1
View File
@@ -1,6 +1,6 @@
# Akkudoktor-EOS
**Version**: `v0.3.0.dev2611122196862169`
**Version**: `v0.3.0.dev2611151515912129`
<!-- pyml disable line-length -->
**Description**: This project provides a comprehensive solution for simulating and optimizing an energy system based on renewable energy sources. With a focus on photovoltaic (PV) systems, battery storage (batteries), load management (consumer requirements), heat pumps, electric vehicles, and consideration of electricity price data, this system enables forecasting and optimization of energy flow and costs over a specified period.
+42 -3
View File
@@ -80,9 +80,48 @@ linearly approximated. Storing values between optimization intervals is generall
The EOS measurement store automatically sums all given loads to create a total load value series
for specified intervals, usually one hour. This aggregated data can be used for load predictions.
An interval that the meters do not fully cover (before the first or after the last reading, a meter
reset, or a gap longer than the channel's `max_gap_seconds`) has no value instead of zero load; with
several load meters, all of them must cover it. Without `max_gap_seconds` a gap between two readings
is spread evenly over it. The `LoadAkkudoktorAdjusted` provider skips hours without a value.
reset, or a gap longer than the meter's gap limit) has no value instead of zero load; with
several load meters, all of them must cover it. The `LoadAkkudoktorAdjusted` provider skips hours
without a value.
### Meter gaps
The energy between two readings of a `*_emr_keys` meter (load, grid import/export, PV production)
is spread evenly over the time between them. A gap longer than `measurement.emr_max_gap_seconds`
(default 10800 s, 3 hours) has no energy value instead: an outage of EOS or of the meter does not
turn into invented, even consumption or production, nights included.
```json
{
"measurement": {
"emr_max_gap_seconds": 10800
}
}
```
Set it to `null` to spread every gap evenly (the behaviour before the limit). A feeder that only
sends a reading when the meter value changes (e.g. a PV or export meter that stands still at night)
needs `null` or a value longer than its longest still period; the Home Assistant adapter reads
the meters on every energy management run and needs no change.
A single meter can get its own limit with a `channels` entry, which takes precedence:
```json
{
"measurement": {
"pv_production_emr_keys": ["pv1_emr"],
"channels": {
"pv1_emr": {
"quantity": "cumulative_energy",
"unit": "kWh",
"max_gap_seconds": 43200
}
}
}
}
```
The entry of a `*_emr_keys` meter must stay `cumulative_energy` in `kWh`.
:::{admonition} Warning
:class: warning
+4 -2
View File
@@ -907,10 +907,12 @@ keys in `measurement.pv_production_emr_keys` to fit the model against measuremen
Calibration preserves daily energy while optionally correcting the intraday
azimuth shape, clamps correction factors and respects inverter capacity.
Hourly meters are fitted hourly; native quarter-hour meters retain their cadence.
Readings marked invalid or unavailable do not count for the meter cadence.
Meters may report at any time stamps: each interval gets the energy interpolated at its
boundaries. With several PV meters only the period all of them report is fitted, and
intervals a meter does not fully cover (a reset, or a gap longer than the channel's
`max_gap_seconds`) are skipped.
intervals a meter does not fully cover (a reset, or a gap longer than
`measurement.emr_max_gap_seconds` or the channel's `max_gap_seconds`, see the meter gaps
in the measurement documentation) are skipped.
Probable outage or curtailment days are excluded by default. Without sufficient
usable measurements the uncalibrated physical model is used.