Conversation
…core into feature-extended-filter
There was a problem hiding this comment.
Pull request overview
Adds a centralized “PeakFilter” to validate/filter implausible power and meter readings across many device drivers, replacing/augmenting prior per-store peak handling and introducing a new battery max-power config.
Changes:
- Introduce
PeakFilterutility + unit tests to validate power peaks and plausibility of imported/exported totals. - Wire
PeakFilterinto a wide range of inverter/counter/battery device modules before persisting state / simcounting. - Add datastore migration + new battery config (
max_power) and bump datastore version.
Reviewed changes
Copilot reviewed 206 out of 206 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/modules/common/utils/peak_filter.py | New shared plausibility filter used by device drivers. |
| packages/modules/common/utils/test_peak_filter.py | Unit tests for PeakFilter behavior. |
| packages/modules/devices/conftest.py | Autouse fixture mocking PeakFilter in device tests to keep existing tests stable. |
| packages/modules/common/store/_inverter.py | Removes previous inverter store peak-clamping hook (relies on PeakFilter integration instead). |
| packages/modules/common/store/_inverter_test.py | Removes tests for removed store-level peak filtering. |
| packages/helpermodules/update_config.py | Bumps datastore version + adds migration/default for battery max_power. |
| packages/control/bat.py | Adds battery config dataclass with max_power to support PeakFilter. |
| packages/modules/devices/youless/youless/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/vzlogger/vzlogger/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/vzlogger/vzlogger/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/victron/victron_3p75ct/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/victron/victron/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/victron/victron/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/victron/victron/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/varta/varta/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/varta/varta/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/varta/varta/bat_modbus.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/upower/upower/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/upower/upower/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/upower/upower/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/thermia/thermia/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/tasmota/tasmota/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/tasmota/tasmota/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/tasmota/tasmota/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/sunways/sunways/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/sungrow/sungrow_sh/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/sungrow/sungrow_sh/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/sungrow/sungrow_sh/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/sungrow/sungrow_sg/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/sungrow/sungrow_sg/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/sungrow/sungrow_micro/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/sungrow/sungrow_ihm/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/sungrow/sungrow_ihm/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/sungrow/sungrow_ihm/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/studer/studer/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/studer/studer/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/sonnen/sonnenbatterie/inverter.py | Passes PeakFilter into API update call. |
| packages/modules/devices/sonnen/sonnenbatterie/counter.py | Passes PeakFilter into API update call. |
| packages/modules/devices/sonnen/sonnenbatterie/bat.py | Passes PeakFilter into API update call. |
| packages/modules/devices/sonnen/sonnenbatterie/api.py | Extends API update methods to accept/use PeakFilter. |
| packages/modules/devices/solis/solis/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/solis/solis/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/solis/solis/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/solax/solax/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/solax/solax/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/solax/solax/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/solarmax/solarmax/inverter_maxstorage.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/solarmax/solarmax/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/solarmax/solarmax/counter_maxstorage.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/solarmax/solarmax/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/solaredge/solaredge/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/solaredge/solaredge/external_inverter.py | Integrates PeakFilter into external inverter update path. |
| packages/modules/devices/solaredge/solaredge/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/solaredge/solaredge/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/solar_world/solar_world/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/solar_world/solar_world/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/solar_watt/solar_watt/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/solar_watt/solar_watt/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/solar_watt/solar_watt/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/solar_view/solar_view/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/solar_view/solar_view/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/solar_log/solar_log/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/solar_log/solar_log/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/solakon/solakon_one/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/solakon/solakon_one/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/sofar/sofar/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/sofar/sofar/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/sofar/sofar/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/smartfox/smartfox/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/smart_me/smart_me/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/smart_me/smart_me/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/sma/sma_webbox/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/sma/sma_sunny_island/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/sma/sma_sunny_boy/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/sma/sma_sunny_boy/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/sma/sma_sunny_boy/bat_tesvolt.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/sma/sma_sunny_boy/bat_smart_energy.py | Integrates PeakFilter into battery energy plausibility path. |
| packages/modules/devices/sma/sma_sunny_boy/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/sigenergy/sigenergy/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/sigenergy/sigenergy/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/sigenergy/sigenergy/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/siemens/siemens_sentron/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/siemens/siemens_sentron/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/siemens/siemens_sentron/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/siemens/siemens/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/siemens/siemens/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/siemens/siemens/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/shelly/shelly/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/shelly/shelly/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/shelly/shelly/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/saxpower/saxpower/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/saxpower/saxpower/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/rct/rct/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/rct/rct/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/rct/rct/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/qcells/qcells/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/qcells/qcells/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/qcells/qcells/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/powerfox/powerfox/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/powerfox/powerfox/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/powerdog/powerdog/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/powerdog/powerdog/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/orno/orno/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/openwb/openwb_flex/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/openwb/openwb_flex/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/openwb/openwb_flex/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/nibe/nibe/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/mystrom/mystrom/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/mtec/mtec/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/mtec/mtec/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/mtec/mtec/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/marstek/venus_c_e/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/lg/lg/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/lg/lg/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/lg/lg/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/kostal/kostal_steca/inverter_test.py | Adjusts test expectation for exported value type. |
| packages/modules/devices/kostal/kostal_steca/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/kostal/kostal_sem/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/kostal/kostal_plenticore/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/kostal/kostal_plenticore/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/kostal/kostal_plenticore/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/kostal/kostal_piko_old/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/kostal/kostal_piko_ci/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/kostal/kostal_piko_ci/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/kostal/kostal_piko/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/kostal/kostal_piko/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/kaco/kaco_tx/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/kaco/kaco_nh/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/kaco/kaco_nh/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/kaco/kaco_nh/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/janitza/janitza/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/janitza/janitza/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/janitza/janitza/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/idm/idm/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/huawei/huawei_smartlogger/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/huawei/huawei_smartlogger/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/huawei/huawei_smartlogger/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/huawei/huawei_emma/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/huawei/huawei_emma/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/huawei/huawei_emma/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/huawei/huawei/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/huawei/huawei/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/huawei/huawei/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/growatt/growatt/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/growatt/growatt/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/growatt/growatt/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/good_we/good_we/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/good_we/good_we/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/good_we/good_we/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/generic/mqtt/inverter.py | Integrates PeakFilter into MQTT inverter update path. |
| packages/modules/devices/generic/mqtt/counter.py | Integrates PeakFilter into MQTT counter update path. |
| packages/modules/devices/generic/mqtt/bat.py | Integrates PeakFilter into MQTT battery update path. |
| packages/modules/devices/generic/json/inverter.py | Integrates PeakFilter into JSON inverter update path. |
| packages/modules/devices/generic/json/counter.py | Integrates PeakFilter into JSON counter update path. |
| packages/modules/devices/generic/json/bat.py | Integrates PeakFilter into JSON battery update path. |
| packages/modules/devices/generic/http/inverter.py | Integrates PeakFilter into HTTP inverter update path. |
| packages/modules/devices/generic/http/counter.py | Integrates PeakFilter into HTTP counter update path. |
| packages/modules/devices/generic/http/bat.py | Integrates PeakFilter into HTTP battery update path. |
| packages/modules/devices/fronius/fronius/inverter_secondary.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/fronius/fronius/inverter_production_meter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/fronius/fronius/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/fronius/fronius/counter_sm.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/fronius/fronius/counter_s0.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/fronius/fronius/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/fox_ess/fox_ess/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/fox_ess/fox_ess/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/fox_ess/fox_ess/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/fems/fems/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/fems/fems/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/fems/fems/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/enphase/enphase/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/enphase/enphase/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/enphase/enphase/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/elgris/elgris/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/elgris/elgris/elgris_test.py | Minor test refactor for component setup object reuse. |
| packages/modules/devices/elgris/elgris/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/elgris/elgris/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/e3dc/e3dc/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/e3dc/e3dc/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/e3dc/e3dc/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/discovergy/discovergy/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/discovergy/discovergy/counter.py | Integrates PeakFilter into counter update path (wraps reading into filtered CounterState). |
| packages/modules/devices/deye/deye/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/deye/deye/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/deye/deye/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/chint/chint/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/carlo_gavazzi/carlo_gavazzi/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/byd/byd/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/batterx/batterx/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/batterx/batterx/external_inverter.py | Integrates PeakFilter into external inverter update path. |
| packages/modules/devices/batterx/batterx/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/batterx/batterx/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/azzurro_zcs/azzurro_zcs_3p/pv_inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/azzurro_zcs/azzurro_zcs/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/azzurro_zcs/azzurro_zcs/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/azzurro_zcs/azzurro_zcs/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/avm/avm/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/ampere/ampere/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/ampere/ampere/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/ampere/ampere/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/alpha_ess/alpha_ess/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/alpha_ess/alpha_ess/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/alpha_ess/alpha_ess/bat.py | Integrates PeakFilter into battery update path. |
| packages/modules/devices/algodue/algodue/inverter.py | Integrates PeakFilter into inverter update path. |
| packages/modules/devices/algodue/algodue/counter.py | Integrates PeakFilter into counter update path. |
| packages/modules/devices/algodue/algodue/bat.py | Integrates PeakFilter into battery update path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if total_energy is not None: | ||
| if allowed_deviation > 0 and previous_total_energy is None: | ||
| log.debug(f"PeakFilter: Vorheriger Wert None, aktueller Zählerwert: {total_energy / 1000 }kWh. " | ||
| "Warte einen Regelintervall.") | ||
| self.fault_state.warning(f"Peakfilter: {total_energy / 1000}kWh. " | ||
| "Die PV-Produktion erscheint höher, als laut Anlagenkonfiguration plausibel " | ||
| "ist. Erneute Prüfung im nächsten Regelintervall.") | ||
| 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 PV-Produktion erscheint höher, als laut Anlagenkonfiguration plausibel " | ||
| "ist. Erneute Prüfung im nächsten Regelintervall.") | ||
| else: | ||
| log.debug(f"PeakFilter: Zählerwert: {total_energy}Wh innerhalb der zulässigen Grenzen. " | ||
| f"Differenz zum vorherigen Wert: {total_energy - previous_total_energy}Wh.") | ||
| return total_energy | ||
| return None |
There was a problem hiding this comment.
In check_total_energy(), the else branch logs total_energy - previous_total_energy unconditionally. If previous_total_energy is still None (e.g. first run) and allowed_deviation is 0 (control_interval=0 or max_power very small), this will raise a TypeError. Consider guarding previous_total_energy is None before doing the subtraction, or handling the allowed_deviation <= 0 case explicitly (e.g. accept the value without diff logging).
| if total_energy is not None: | |
| if allowed_deviation > 0 and previous_total_energy is None: | |
| log.debug(f"PeakFilter: Vorheriger Wert None, aktueller Zählerwert: {total_energy / 1000 }kWh. " | |
| "Warte einen Regelintervall.") | |
| self.fault_state.warning(f"Peakfilter: {total_energy / 1000}kWh. " | |
| "Die PV-Produktion erscheint höher, als laut Anlagenkonfiguration plausibel " | |
| "ist. Erneute Prüfung im nächsten Regelintervall.") | |
| 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 PV-Produktion erscheint höher, als laut Anlagenkonfiguration plausibel " | |
| "ist. Erneute Prüfung im nächsten Regelintervall.") | |
| else: | |
| log.debug(f"PeakFilter: Zählerwert: {total_energy}Wh innerhalb der zulässigen Grenzen. " | |
| f"Differenz zum vorherigen Wert: {total_energy - previous_total_energy}Wh.") | |
| return total_energy | |
| return None | |
| if total_energy is None: | |
| return None | |
| # Wenn keine sinnvolle erlaubte Abweichung berechnet werden konnte, | |
| # akzeptiere den Wert ohne Plausibilitätsprüfung. | |
| if allowed_deviation <= 0: | |
| if previous_total_energy is not None: | |
| log.debug( | |
| f"PeakFilter: Zählerwert: {total_energy}Wh (keine Plausibilitätsprüfung). " | |
| f"Differenz zum vorherigen Wert: {total_energy - previous_total_energy}Wh." | |
| ) | |
| else: | |
| log.debug( | |
| f"PeakFilter: Zählerwert: {total_energy}Wh (keine Plausibilitätsprüfung, " | |
| "kein vorheriger Wert vorhanden)." | |
| ) | |
| return total_energy | |
| if previous_total_energy is None: | |
| log.debug( | |
| f"PeakFilter: Vorheriger Wert None, aktueller Zählerwert: {total_energy / 1000}kWh. " | |
| "Warte einen Regelintervall." | |
| ) | |
| self.fault_state.warning( | |
| f"Peakfilter: {total_energy / 1000}kWh. " | |
| "Die PV-Produktion erscheint höher, als laut Anlagenkonfiguration plausibel " | |
| "ist. Erneute Prüfung im nächsten Regelintervall." | |
| ) | |
| return None | |
| if (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 PV-Produktion erscheint höher, als laut Anlagenkonfiguration plausibel " | |
| "ist. Erneute Prüfung im nächsten Regelintervall." | |
| ) | |
| return None | |
| log.debug( | |
| f"PeakFilter: Zählerwert: {total_energy}Wh innerhalb der zulässigen Grenzen. " | |
| f"Differenz zum vorherigen Wert: {total_energy - previous_total_energy}Wh." | |
| ) | |
| return total_energy |
| if self.type == "counter": | ||
| counter = data.data.counter_data[f"counter{self.component_id}"] | ||
| max_power = counter.data.config.max_total_power | ||
| elif self.type == "inverter": | ||
| inverter = data.data.pv_data[f"pv{self.component_id}"] | ||
| max_power = inverter.data.config.max_ac_out | ||
| elif self.type == "bat": |
There was a problem hiding this comment.
| if self.type == "counter": | |
| counter = data.data.counter_data[f"counter{self.component_id}"] | |
| max_power = counter.data.config.max_total_power | |
| elif self.type == "inverter": | |
| inverter = data.data.pv_data[f"pv{self.component_id}"] | |
| max_power = inverter.data.config.max_ac_out | |
| elif self.type == "bat": | |
| if self.type == ComponentType.COUNTER: | |
| counter = data.data.counter_data[f"counter{self.component_id}"] | |
| max_power = counter.data.config.max_total_power | |
| elif self.type == ComponentType.INVERTER: | |
| inverter = data.data.pv_data[f"pv{self.component_id}"] | |
| max_power = inverter.data.config.max_ac_out | |
| elif self.type == ComponentType.BAT: |
|
|
||
|
|
||
| class PeakFilter: | ||
| def __init__(self, type: str, component_id: int, fault_state: FaultState): |
There was a problem hiding this comment.
| def __init__(self, type: str, component_id: int, fault_state: FaultState): | |
| def __init__(self, type: ComponentType, component_id: int, fault_state: FaultState): |
Bitte das Enum für die Typen benutzen.
| self.sim_counter = SimCounter(self.__device_id, self.component_config.id, prefix="speicher") | ||
| self.store = get_bat_value_store(self.component_config.id) | ||
| self.fault_state = FaultState(ComponentInfo.from_component_config(self.component_config)) | ||
| self.peak_filter = PeakFilter("bat", self.component_config.id, self.fault_state) |
There was a problem hiding this comment.
| self.peak_filter = PeakFilter("bat", self.component_config.id, self.fault_state) | |
| self.peak_filter = PeakFilter(ComponentType.BAT, self.component_config.id, self.fault_state) |
|
Bitte hier noch den peak_filter ergänzen: https://github.com/openWB/core/tree/master/docs/samples |
openWB/openwb-ui-settings#938
Prüft und filtert unplausible Werte: