Browse Source

Use histrical total values only when an iverter was seen at least once seen power up

pull/1866/head
Mariusz Wasiluk 3 weeks ago
parent
commit
df3504a2f8
  1. 7
      src/publisher/pubMqttIvData.h

7
src/publisher/pubMqttIvData.h

@ -171,19 +171,20 @@ class PubMqttIvData {
mTotal[3] += mIv->getValue(mPos, rec); mTotal[3] += mIv->getValue(mPos, rec);
break; break;
} }
} else if (mIv->GeneralConfig->rstValsAtMidNight) { } else if (mIv->GeneralConfig->rstValsAtMidNight && rec->ts > 0) {
// Inverter is OFF - use last stored YT/YD values for total calculation. // Inverter is OFF - use last stored YT/YD values for total calculation.
// It is safe to use them when values are reset at midnight. // It is safe to use them when values are reset at midnight.
// Timestap check is to avoid wrong totals after restart (lower than before restart).
// This helps in having correct total values during daytime even when some inverters are OFF // This helps in having correct total values during daytime even when some inverters are OFF
switch (rec->assign[mPos].fieldId) { switch (rec->assign[mPos].fieldId) {
case FLD_YT: case FLD_YT:
DPRINT_IVID(DBG_DEBUG, mPos); DPRINT_IVID(DBG_DEBUG, mIv->id);
DBGPRINT(F("Inverter is OFF - Using last YT: ")); DBGPRINT(F("Inverter is OFF - Using last YT: "));
DBGPRINTLN(String(mIv->getValue(mPos, rec))); DBGPRINTLN(String(mIv->getValue(mPos, rec)));
mTotal[1] += mIv->getValue(mPos, rec); mTotal[1] += mIv->getValue(mPos, rec);
break; break;
case FLD_YD: { case FLD_YD: {
DPRINT_IVID(DBG_DEBUG, mPos); DPRINT_IVID(DBG_DEBUG, mIv->id);
DBGPRINT(F("Inverter is OFF - Using last YD: ")); DBGPRINT(F("Inverter is OFF - Using last YD: "));
DBGPRINTLN(String(mIv->getValue(mPos, rec))); DBGPRINTLN(String(mIv->getValue(mPos, rec)));
mTotal[2] += mIv->getValue(mPos, rec); mTotal[2] += mIv->getValue(mPos, rec);

Loading…
Cancel
Save