From 5944413b4bf60e083476c0c3a7f5c4d928688770 Mon Sep 17 00:00:00 2001 From: Bernhard Kirchen Date: Wed, 15 Jan 2025 11:37:30 +0100 Subject: [PATCH] Fix: really trigger standby only once on DPL shutdown relying on updateInverters() to return false after requesting inverter standby is not a good idea. the standby function will always set a new limit, and the updateInverters() function may fail to recognize that no change is actually required. instead, we trigger the standby only once and rely on the updateInverters() function being called as part of the DPL loop() to apply the standby state. --- src/PowerLimiter.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/PowerLimiter.cpp b/src/PowerLimiter.cpp index 60c19fbfb..e3b9e214a 100644 --- a/src/PowerLimiter.cpp +++ b/src/PowerLimiter.cpp @@ -82,6 +82,10 @@ void PowerLimiterClass::announceStatus(PowerLimiterClass::Status status) _lastStatusPrinted = millis(); } +/** + * NOTE: this method relies on being called regularly, i.e., as part of the + * loop(), and that it is called *after* updateInverters(). + */ bool PowerLimiterClass::isDisabled() { auto const& config = Configuration.get(); @@ -104,7 +108,10 @@ bool PowerLimiterClass::isDisabled() for (auto& upInv : _inverters) { upInv->standby(); } - _shutdownComplete = !updateInverters(); + // we triggered the shutdown, and we won't trigger it again until the DPL + // enabled and disabled again. we rely that updateInverters() is called + // in the DPL loop(), applying the standby limit and power state. + _shutdownComplete = true; return true; }