From 5f3c6feb35e3843546b1d61214f8fd9ce53ac5fb Mon Sep 17 00:00:00 2001 From: rejoe2 Date: Thu, 30 May 2024 12:44:50 +0200 Subject: [PATCH] MI - Fix AC calc after midnight For other than 1ch inverters --- src/hm/Communication.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/hm/Communication.h b/src/hm/Communication.h index 3192c513..341a2eb0 100644 --- a/src/hm/Communication.h +++ b/src/hm/Communication.h @@ -897,7 +897,14 @@ class Communication : public CommQueue<> { stsok = false; if( (!oldState) || (!q->iv->alarmCnt) ) { // initial zero value? => just write this channel to main state and raise changed flags changedStatus = true; - q->iv->alarmCnt = 1; // minimum... + if( !q->iv->alarmCnt ) { + q->iv->alarmCnt = 1; // minimum... + for (uint8_t i = 1; i <= 9; i++) { //start with 1 + if (i != stschan && q->iv->lastAlarm[i].code) { + q->iv->lastAlarm[i].code = 0; // zero outdated values + } + } + } } else { //sth is or was wrong? if (q->iv->type == INV_TYPE_1CH) { @@ -996,7 +1003,7 @@ class Communication : public CommQueue<> { ac_pow += iv->getValue(iv->getPosByChFld(1, FLD_PDC, rec), rec); } else { for(uint8_t i = 1; i <= iv->channels; i++) { - if ((!iv->lastAlarm[i].code) || (iv->lastAlarm[i].code == 1)) + if ((!iv->lastAlarm[i].code) || (iv->lastAlarm[i].code == 1) || ( (iv->alarmCnt == 1) && (iv->lastAlarm[0].code == 1) ) ) ac_pow += iv->getValue(iv->getPosByChFld(i, FLD_PDC, rec), rec); } }