make calcPowerLimit respect DTU poll interval

This commit is contained in:
MalteSchm 2023-04-07 19:08:27 +02:00
parent f84bdf7287
commit 734d34b7a8

View File

@ -175,8 +175,9 @@ int32_t PowerLimiterClass::calcPowerLimit(std::shared_ptr<InverterAbstract> inve
// Safety check, return on too old power meter values
if (millis() - PowerMeter.getLastPowerMeterUpdate() < (30 * 1000)
&& millis() - inverter->Statistics()->getLastUpdate() < (15 * 1000)) {
// If the power meter values are older than 30 seconds,
&& millis() - inverter->Statistics()->getLastUpdate() < (config.Dtu_PollInterval * 3 * 1000)) {
// If the power meter values are older than 30 seconds,
// and the Inverter Stats are older then 3x the poll interval
// set the limit to config.PowerLimiter_LowerPowerLimit for safety reasons.
MessageOutput.println("[PowerLimiterClass::loop] Power Meter values too old. Using lower limit");
return config.PowerLimiter_LowerPowerLimit;