Skip to content

Commit

Permalink
Fix: really trigger standby only once on DPL shutdown
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
schlimmchen committed Jan 15, 2025
1 parent 13904a4 commit 5944413
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/PowerLimiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
}
Expand Down

0 comments on commit 5944413

Please sign in to comment.