fix implicit if-comparisons#3396
Open
LKuemmel wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Diese PR behebt implizite Truthiness-Checks (z. B. if x:) bei numerischen Werten, sodass 0 nicht mehr fälschlich wie “kein Wert” behandelt wird. Das adressiert insbesondere das geschilderte Verhalten beim gleichzeitigen Laden mehrerer Fahrzeuge mit Überschuss, bei dem zwischendurch unerwartet mit Netzbezug geladen wurde.
Changes:
- Explizite
None-Prüfungen in Loadmanagement/Counter (Leistungs- und Dimmingschranken) sowie bei SoC/EVSE-Current Checks. - Anpassung/Erweiterung von Unit- und Integrationstests für die neuen Randfälle (
0vs.None). - Erwartungswerte in PV-Integrationstest an die geänderte Begrenzungslogik angepasst.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/control/loadmanagement.py | Präzisiert Power-/Dimming-Limits durch None-Checks und neue Behandlung von raw_power_left <= 0. |
| packages/control/loadmanagement_test.py | Erweitert Tests für _limit_by_power um 0- und None-Fälle. |
| packages/control/ev/charge_template.py | SoC-Grenzlogik nutzt soc is not None, damit 0 korrekt behandelt wird. |
| packages/control/counter.py | Macht raw_power_left optional und ersetzt Truthiness-Checks durch is not None. |
| packages/control/algorithm/surplus_controlled.py | Verhindert, dass evse_current == 0 die Korrekturlogik überspringt. |
| packages/control/algorithm/integration_test/pv_charging_test.py | Aktualisiert erwartete Ströme nach geänderter Power-Limit-Auswertung. |
| packages/control/algorithm/integration_test/conftest.py | Setzt raw_power_left für counter6 explizit auf None (nicht-EVU-Zähler). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| elif raw_power_left > 0: | ||
| if feed_in is not None: | ||
| raw_power_left = raw_power_left - feed_in | ||
| log.debug(f"Verbleibende Leistung unter Berücksichtigung der Einspeisegrenze: {raw_power_left}W") |
| reserved_surplus: float = field(default=0, metadata={"topic": "set/reserved_surplus"}) | ||
| released_surplus: float = field(default=0, metadata={"topic": "set/released_surplus"}) | ||
| raw_power_left: float = 0 | ||
| raw_power_left: Optional[float] = 0 |
Comment on lines
+208
to
209
| if self.data.set.surplus_power_left is not None: | ||
| self.data.set.surplus_power_left -= sum([c * cp_voltage for c in diffs]) |
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.
Beim gleichzeitigen Laden von zwei Autos mit Überschuss wird zwischendurch immer mal wieder ohne erkennbaren Grund mit deutlichem Bezug geladen.
https://forum.openwb.de/viewtopic.php?p=142924#p142924