diff --git a/src/CHANGES.md b/src/CHANGES.md index c60bd5c4..133e145a 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,13 @@ # Development Changes +## 0.8.130 - 2024-08-04 +* fix message `ERR_DUPLICATE_INVERTER` #1705, #1700 +* merge PR: Power limit command accelerated #1704 +* merge PR: reduce update cycle of ePaper from 5 to 10 seconds #1706 +* merge PR: small fixes in different files #1711 +* add timestamp to JSON output #1707 +* restart Ahoy using MqTT #1667 + ## 0.8.129 - 2024-07-11 * sort alarms ascending #1471 * fix alarm counter for first alarm diff --git a/src/config/settings.h b/src/config/settings.h index e43153d9..bbbf2507 100644 --- a/src/config/settings.h +++ b/src/config/settings.h @@ -410,8 +410,8 @@ class settings { if(keepWifi) memcpy(&mCfg.sys, &tmp, sizeof(cfgSys_t)); else { - snprintf(mCfg.sys.stationSsid, SSID_LEN, FB_WIFI_SSID); - snprintf(mCfg.sys.stationPwd, PWD_LEN, FB_WIFI_PWD); + mCfg.sys.stationSsid[0] = '\0'; + mCfg.sys.stationPwd[0] = '\0'; mCfg.sys.isHidden = false; } snprintf(mCfg.sys.apPwd, PWD_LEN, WIFI_AP_PWD); diff --git a/src/defines.h b/src/defines.h index 5914daa2..7324dea8 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 8 -#define VERSION_PATCH 129 +#define VERSION_PATCH 130 //------------------------------------- typedef struct { uint8_t ch; diff --git a/src/hm/hmInverter.h b/src/hm/hmInverter.h index ff3ff9c5..026bf6d8 100644 --- a/src/hm/hmInverter.h +++ b/src/hm/hmInverter.h @@ -817,14 +817,14 @@ class Inverter { private: inline void addAlarm(uint16_t code, uint32_t start, uint32_t end) { - bool found = false; uint8_t i = 0; if(start > end) end = 0; for(; i < 10; i++) { - mAlarmNxtWrPos = (++mAlarmNxtWrPos) % 10; + ++mAlarmNxtWrPos; + mAlarmNxtWrPos = mAlarmNxtWrPos % 10; if(lastAlarm[mAlarmNxtWrPos].code == code && lastAlarm[mAlarmNxtWrPos].start == start) { // replace with same or update end time diff --git a/src/plugins/Display/Display.h b/src/plugins/Display/Display.h index 0ce1522c..c818d217 100644 --- a/src/plugins/Display/Display.h +++ b/src/plugins/Display/Display.h @@ -79,16 +79,25 @@ class Display { void tickerSecond() { bool request_refresh = false; - if (mMono != NULL) + if (mMono != NULL) { + // maintain LCD and OLED displays with pixel shift screensavers, at least every 5 seconds request_refresh = mMono->loop(motionSensorActive()); - - if (mNewPayload || (((++mLoopCnt) % 5) == 0) || request_refresh) { - DataScreen(); - mNewPayload = false; - mLoopCnt = 0; + if (mNewPayload || (((++mLoopCnt) % 5) == 0) || request_refresh) { + DataScreen(); + mNewPayload = false; + mLoopCnt = 0; + } } #if defined(ESP32) && !defined(ETHERNET) + else if (DISP_TYPE_T10_EPAPER == mCfg->type) { + // maintain ePaper at least every 15 seconds + if (mNewPayload || (((++mLoopCnt) % 15) == 0)) { + DataScreen(); + mNewPayload = false; + mLoopCnt = 0; + } mEpaper.tickerSecond(); + } #endif } @@ -180,12 +189,14 @@ class Display { else if (DISP_TYPE_T10_EPAPER == mCfg->type) { mEpaper.loop((totalPower), totalYieldDay, totalYieldTotal, nrprod); mRefreshCycle++; - } - if (mRefreshCycle > 480) { - mEpaper.fullRefresh(); - mRefreshCycle = 0; + if (mRefreshCycle > 480) { + mEpaper.fullRefresh(); + mRefreshCycle = 0; + } + } + #endif } diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index 28cfb358..6e021bed 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -285,6 +285,9 @@ class PubMqtt { tickerMinute(); publish(mLwtTopic.data(), mqttStr[MQTT_STR_LWT_CONN], true, false); + snprintf(mVal.data(), mVal.size(), "ctrl/restart_ahoy"); + subscribe(mVal.data()); + for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { snprintf(mVal.data(), mVal.size(), "ctrl/limit/%d", i); subscribe(mVal.data(), QOS_2); @@ -386,9 +389,9 @@ class PubMqtt { pos++; } - /*char out[128]; + char out[128]; serializeJson(root, out, 128); - DPRINTLN(DBG_INFO, "json: " + String(out));*/ + DPRINTLN(DBG_INFO, "json: " + String(out)); (mSubscriptionCb)(root); mRxCnt++; diff --git a/src/publisher/pubMqttIvData.h b/src/publisher/pubMqttIvData.h index 7965cde6..5ba21f6d 100644 --- a/src/publisher/pubMqttIvData.h +++ b/src/publisher/pubMqttIvData.h @@ -231,6 +231,7 @@ class PubMqttIvData { publish = true; if (publish) { + doc[F("ts")] = rec->ts; // if next channel or end->publish serializeJson(doc, mVal.data(), mVal.size()); snprintf(mSubTopic.data(), mSubTopic.size(), "%s/ch%d", mIv->config->name, rec->assign[mPos].ch); diff --git a/src/utils/scheduler.h b/src/utils/scheduler.h index 0f7cea7b..5ce43a36 100644 --- a/src/utils/scheduler.h +++ b/src/utils/scheduler.h @@ -35,14 +35,21 @@ namespace ah { mMax = 0; mPrevMillis = millis(); mTsMillis = mPrevMillis % 1000; + mFastTicker = false; resetTicker(); } virtual void loop(void) { mMillis = millis(); mDiff = mMillis - mPrevMillis; - if (mDiff < 1000) + if (mDiff < 1000) { + if (mFastTicker) { + mDiffSeconds = 0; + checkTicker(); + mFastTicker = false; + } return; + } mDiffSeconds = 1; if (mDiff < 2000) @@ -127,6 +134,8 @@ namespace ah { mTicker[i].isTimestamp = isTimestamp; strncpy(mTicker[i].name, name, 5); mTicker[i].name[5]=0; + if (timeout == 0 && reload == false) + mFastTicker = true; if(mMax == i) mMax = i + 1; return i; @@ -162,6 +171,7 @@ namespace ah { uint32_t mMillis = 0, mPrevMillis = 0, mDiff = 0; uint8_t mDiffSeconds = 0; uint8_t mMax = 0; + bool mFastTicker; }; } diff --git a/src/web/RestApi.h b/src/web/RestApi.h index 345d542b..4cd74c2b 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -1060,6 +1060,8 @@ class RestApi { } else if(F("dev") == jsonIn[F("cmd")]) { DPRINTLN(DBG_INFO, F("dev cmd")); iv->setDevCommand(jsonIn[F("val")].as()); + } else if(F("restart_ahoy") == jsonIn[F("cmd")]) { + mApp->setRebootFlag(); } else { jsonOut[F("error")] = F("ERR_UNKNOWN_CMD"); return false; @@ -1105,7 +1107,7 @@ class RestApi { Inverter<> *iv; for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { - iv = mSys->getInverterByPos(jsonIn[F("id")], true); + iv = mSys->getInverterByPos(i, true); if(nullptr != iv) { if((i != jsonIn[F("id")]) && (iv->config->serial.u64 == jsonIn[F("ser")])) { jsonOut[F("error")] = F("ERR_DUPLICATE_INVERTER"); diff --git a/src/web/html/includes/footer.html b/src/web/html/includes/footer.html index 6aa89673..ce0c6852 100644 --- a/src/web/html/includes/footer.html +++ b/src/web/html/includes/footer.html @@ -1,6 +1,6 @@