fix power-limit was not checked for max retransmits #667

fix blue LED lights up all the time #672
fix installing schedulers if NTP server isn't available
improved zero values on triggers #671
hardcoded MQTT subtopics, because wildcard `#` leads to errors
rephrased some messages on webif, thx to @Argafal #638
This commit is contained in:
lumapu 2023-02-11 02:02:04 +01:00
parent 1dd1b3be21
commit 026df8a09b
10 changed files with 76 additions and 56 deletions

View file

@ -161,14 +161,16 @@ void app::tickNtpUpdate(void) {
mMqtt.connect();
everySec(std::bind(&PubMqttType::tickerSecond, &mMqtt), "mqttS");
everyMin(std::bind(&PubMqttType::tickerMinute, &mMqtt), "mqttM");
mMqttReconnect = false;
}
if(mConfig->inst.rstValsNotAvail)
everyMin(std::bind(&app::tickMinute, this), "tMin");
if(mConfig->inst.rstYieldMidNight) {
uint32_t midTrig = mTimestamp - ((mTimestamp - 1) % 86400) + 86400; // next midnight
onceAt(std::bind(&app::tickMidnight, this), midTrig, "midNi");
// only install schedulers once even if NTP wasn't successful in first loop
if(mMqttReconnect) { // @TODO: mMqttReconnect is wrong name here
if(mConfig->inst.rstValsNotAvail)
everyMin(std::bind(&app::tickMinute, this), "tMin");
if(mConfig->inst.rstYieldMidNight) {
uint32_t midTrig = mTimestamp - ((mTimestamp - 1) % 86400) + 86400; // next midnight
onceAt(std::bind(&app::tickMidnight, this), midTrig, "midNi");
}
}
nxtTrig = isOK ? 43200 : 60; // depending on NTP update success check again in 12 h or in 1 min
@ -183,6 +185,8 @@ void app::tickNtpUpdate(void) {
mSendFirst = false;
once(std::bind(&app::tickSend, this), 2, "senOn");
}
mMqttReconnect = false;
}
once(std::bind(&app::tickNtpUpdate, this), nxtTrig, "ntp");
}
@ -233,17 +237,8 @@ void app::tickSun(void) {
//-----------------------------------------------------------------------------
void app::tickComm(void) {
if(!mIVCommunicationOn && (mConfig->inst.rstValsCommStop)) {
Inverter<> *iv;
// set values to zero, except yields
for (uint8_t id = 0; id < mSys.getNumInverters(); id++) {
iv = mSys.getInverterByPos(id);
if (NULL == iv)
continue; // skip to next inverter
mPayload.zeroInverterValues(iv);
}
}
if((!mIVCommunicationOn) && (mConfig->inst.rstValsCommStop))
once(std::bind(&app::tickZeroValues, this), mConfig->nrf.sendInterval, "tZero");
if (mMqttEnabled) {
if (!mMqtt.tickerComm(!mIVCommunicationOn))
@ -251,6 +246,19 @@ void app::tickComm(void) {
}
}
//-----------------------------------------------------------------------------
void app::tickZeroValues(void) {
Inverter<> *iv;
// set values to zero, except yields
for (uint8_t id = 0; id < mSys.getNumInverters(); id++) {
iv = mSys.getInverterByPos(id);
if (NULL == iv)
continue; // skip to next inverter
mPayload.zeroInverterValues(iv);
}
}
//-----------------------------------------------------------------------------
void app::tickMinute(void) {
// only triggered if 'reset values on no avail is enabled'
@ -273,6 +281,8 @@ void app::tickMidnight(void) {
uint32_t nxtTrig = mTimestamp - ((mTimestamp - 1) % 86400) + 86400; // next midnight
onceAt(std::bind(&app::tickMidnight, this), nxtTrig, "mid2");
DPRINTLN(DBG_INFO, "tickMidnight " + String(nxtTrig));
Inverter<> *iv;
// set values to zero, except yield total
for (uint8_t id = 0; id < mSys.getNumInverters(); id++) {