Improve PeakFilter#3380
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts hybrid inverter value post-processing to avoid exceptions when energy counter readings are temporarily None (e.g., due to PeakFilter behavior), preventing the whole inverter state update from being discarded.
Changes:
- Add
None-guards around hybrid energy counter correction logic infix_hybrid_values. - When required inputs are missing, mark
exportedas invalid (None) instead of computing withNonevalues.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+72
to
+76
| if (bat_get.imported is not None and bat_get.exported is not None and | ||
| imported is not None and exported is not None): | ||
| exported += bat_get.imported - bat_get.exported - imported | ||
| else: | ||
| exported = None |
Comment on lines
+72
to
+76
| if (bat_get.imported is not None and bat_get.exported is not None and | ||
| imported is not None and exported is not None): | ||
| exported += bat_get.imported - bat_get.exported - imported | ||
| else: | ||
| exported = None |
Comment on lines
+19
to
+24
| self.__pv.power.write(int(inverter_state.power)) | ||
| self.__pv.energy.write(inverter_state.exported) | ||
| self.__pv.energy_k.write(inverter_state.exported / 1000) | ||
| self.__pv.energy_k.write( | ||
| inverter_state.exported if inverter_state.exported is None | ||
| else inverter_state.exported / 1000 | ||
| ) |
Comment on lines
+75
to
+79
| if (bat_get.imported is not None and bat_get.exported is not None and | ||
| imported is not None and exported is not None): | ||
| exported += bat_get.imported - bat_get.exported - imported | ||
| else: | ||
| exported = None |
Comment on lines
81
to
85
| elif allowed_deviation > 0 and (total_energy - previous_total_energy) > allowed_deviation: | ||
| log.debug(f"PeakFilter: Unplausibler Zählerwert: {total_energy / 1000}kWh. " | ||
| f"Differenz zum vorherigen Wert: {total_energy - previous_total_energy}Wh. " | ||
| f"erlaubte Differenz: {round(allowed_deviation, 2)}Wh.") | ||
| self.fault_state.warning(f"Peakfilter: {total_energy / 1000}kWh. " | ||
| "Die Energie erscheint höher, als laut Anlagenkonfiguration plausibel " | ||
| "ist. Erneute Prüfung im nächsten Regelintervall.") | ||
| else: |
| self.__pv.energy_k.write(inverter_state.exported / 1000) | ||
| if inverter_state.exported is not None: | ||
| self.__pv.energy.write(inverter_state.exported) | ||
| self.__pv.energy_k.write(inverter_state.exported / 1000) |
Comment on lines
+76
to
+77
| else: | ||
| exported = None |
| imported is not None and exported is not None): | ||
| exported += bat_get.imported - bat_get.exported - imported | ||
| else: | ||
| exported = None |
LKuemmel
approved these changes
May 22, 2026
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.
Einige Wechselrichter haben bei Zählerständen grobe Auflösung im Register was wiederholt trotz valider Werte Peaks auslöst (Werte bilden Treppchen).
Solche validen Peaks werden eine Regelschleife später übernommen - in der ersten Regelschleife werden sie auf None gesetzt.
Bei Hybridsystemen werden die Werte in _inverter.py nochmal nachbearbeitet. Hier führt None zu einer Exception was dann dazu führt, dass alle Werte (auch aktuelle Leistung) verworfen werden.
Erkennbar ist dass Problem an kleinen, zyklischen Einbrüchen im Graphen.
Meldung im Forum: https://forum.openwb.de/viewtopic.php?p=143030#p143030
#3333 (comment) behandelt das Problem der häufigen Fehlermeldungen - wird hier aber auch berücksichtigt