Controller Timeslot Peakshaving: Avoid endless while loop#3464
Merged
sfeilmeier merged 2 commits intoOpenEMS:developfrom Dec 6, 2025
Merged
Controller Timeslot Peakshaving: Avoid endless while loop#3464sfeilmeier merged 2 commits intoOpenEMS:developfrom
sfeilmeier merged 2 commits intoOpenEMS:developfrom
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #3464 +/- ##
=============================================
+ Coverage 59.54% 59.54% +0.01%
Complexity 112 112
=============================================
Files 2901 2901
Lines 124935 124926 -9
Branches 9357 9356 -1
=============================================
- Hits 74381 74379 -2
+ Misses 47737 47725 -12
- Partials 2817 2822 +5 🚀 New features to boost your workflow:
|
Contributor
|
@tsicking thank you for this pull request. We've currently faced this issue on one of our customer systems. We are testing this on the system at the moment. I will give you response if it works out. You are saving me a lot of debug time by your pr 👏🏽 |
clehne
approved these changes
Dec 5, 2025
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.
In the previous implementation, if the min power of the ess is 0 (e.g. if the battery has an error), and the SOC is below the hysteresis SOC while being in state slowcharge, the while loop would toggle between the states
SLOWCHARGEandHYSTERESISendlessly. This is critical, as the method runs inside the core cycle, therefore the whole system would stop.One can reproduce the bug with a simulated ess, a controller fix active power setting the ess to 0, and a controller timeslot peakshaving running afterwards in state
SLOWCHARGE.The new implementation leaves out the while loop altogether and does not check the min power.
When going through the code, I saw that there is more room for improvement, namely:
ess()would need to be renamed toess_id())SLOWCHARGE, the controller will not get back into the state, but remain in stateNORMAL.This will be done in separate PRs.