Improve Peakfilter: filter energy exceeding 50 years#3574
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds an additional plausibility check in PeakFilter to drop imported/exported energy counter readings that exceed the maximum physically possible energy over 50 years at configured max power.
Changes:
- Add a “50-year max energy” threshold (
max_power * 24 * 365 * 50) to filter implausibly large imported/exported total energy readings. - Extend unit tests with scenarios around very large exported energy values near/over the 50-year threshold.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
packages/modules/common/utils/peak_filter.py |
Adds 50-year maximum energy plausibility filter for imported/exported totals. |
packages/modules/common/utils/test_peak_filter.py |
Adds/extends test cases for the new plausibility behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| max_energy = max_power * 24 * 365 * 50 | ||
| if imported is not None and imported > max_energy: | ||
| log.debug(f"PeakFilter: Unplausibler importierter Zählerstand: {imported / 1000}kWh. " | ||
| f"Maximal mögliche Energiemenge in 50 Jahren: {max_energy / 1000}kWh.") | ||
| imported = None |
| Params("Imp/ Exp Speicher - Export ~ 40Y", ComponentType.BAT, | ||
| 1000, 400000000, 400, 1005, 400000000, 1005, 400000000), |
| Params("Imp/ Exp Speicher - Werte invalide", ComponentType.BAT, 1000, 500, 400, 1300, 800, None, None), | ||
| Params("Imp/ Exp Speicher - Import invalide", ComponentType.BAT, 1000, 500, 400, 1300, 505, None, 505), | ||
| Params("Imp/ Exp Speicher - Export invalide", ComponentType.BAT, 1000, 500, 400, 1005, 800, 1005, None), | ||
| Params("Imp/ Exp Speicher - Export > 50Y", ComponentType.BAT, 1000, 500000000, 400, 1005, 500000000, 1005, None), |
| imp = self.check_total_energy(imported, self.imported, allowed_deviation, max_energy) | ||
| self.imported = imported | ||
|
|
||
| exp = self.check_total_energy(exported, self.exported, allowed_deviation) | ||
| exp = self.check_total_energy(exported, self.exported, allowed_deviation, max_energy) | ||
| self.exported = exported |
| Params("Imp/ Exp Speicher - Import > 50Y", ComponentType.BAT, | ||
| 400000000, 500, 400, 400000000, 505, 400000000, 505) |
| elif (allowed_deviation > 0 and | ||
| ((total_energy - previous_total_energy) > allowed_deviation or | ||
| (total_energy - previous_total_energy) < 0)): |
There was a problem hiding this comment.
Negativwerte werden in der setdata zusätzlich verworfen. Es geht darum kleinere Peaks nach großen Peaks zu filtern (wären negativ und würden durchgehen).
Es sollen nur steigende oder gleichbleibende Werte valide sein.
Ist keine aktuelle Leistung zum Vergleich hinterlegt soll kein Filter angewendet werden.
| Params("Imp/ Exp Speicher - Import > 50Y", ComponentType.BAT, 500000000, 500, 400, 500000000, 505, None, 505), | ||
| Params("Imp/ Exp Speicher - Export > 50Y", ComponentType.BAT, 1000, 500000000, 400, 1005, 500000000, 1005, None), | ||
| Params("Imp/ Exp Speicher - Export ~ 45Y", ComponentType.BAT, | ||
| 1000, 400000000, 400, 1005, 400000000, 1005, 400000000), | ||
| Params("Imp/ Exp Speicher - Import ~ 45Y", ComponentType.BAT, | ||
| 400000000, 500, 400, 400000000, 505, 400000000, 505) |
Zählerstande filtern die größer sind als die maximal mögliche Energiemenge in 50 Jahren
Formel:
max. Leistung × 24 h/Tag × 365 Tage/Jahr × 50 Jahre