From 85dae3805f0f05313803d90f55828553eb77166f Mon Sep 17 00:00:00 2001 From: lumapu Date: Sun, 6 Aug 2023 00:25:47 +0200 Subject: [PATCH] 0.7.24 * merge PR #1069 make MqTT client ID configurable * fix #1016, general MqTT status depending on inverter state machine * changed icon for fully available inverter to a filled check mark #1070 * fixed `last_success` update with MqTT #1068 * removed `improv` esp-web-installer script, because it is not fully functional at this time --- src/CHANGES.md | 7 +++++++ src/app.cpp | 6 +++--- src/app.h | 4 ++-- src/defines.h | 4 ++-- src/publisher/pubMqtt.h | 18 +++++++++--------- src/web/html/api.js | 4 ++++ src/web/html/index.html | 12 ++++++------ src/web/html/setup.html | 2 +- 8 files changed, 34 insertions(+), 23 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index c48c834e1..275110710 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,12 @@ # Development Changes +## 0.7.24 - 2023-08-05 +* merge PR #1069 make MqTT client ID configurable +* fix #1016, general MqTT status depending on inverter state machine +* changed icon for fully available inverter to a filled check mark #1070 +* fixed `last_success` update with MqTT #1068 +* removed `improv` esp-web-installer script, because it is not fully functional at this time + ## 0.7.23 - 2023-08-04 * merge PR #1056, visualization html * update MqTT library to 1.4.4 diff --git a/src/app.cpp b/src/app.cpp index 56a85f187..96a53a941 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -97,7 +97,7 @@ void app::setup() { mPubSerial.setup(mConfig, &mSys, &mTimestamp); - mImprov.setup(this, mConfig->sys.deviceName, mVersion); + //mImprov.setup(this, mConfig->sys.deviceName, mVersion); regularTickers(); } @@ -105,7 +105,7 @@ void app::setup() { //----------------------------------------------------------------------------- void app::loop(void) { mInnerLoopCb(); - mImprov.tickSerial(); + //mImprov.tickSerial(); } //----------------------------------------------------------------------------- @@ -214,7 +214,7 @@ void app::regularTickers(void) { everySec(std::bind(&DisplayType::tickerSecond, &mDisplay), "disp"); every(std::bind(&PubSerialType::tick, &mPubSerial), mConfig->serial.interval, "uart"); //everySec(std::bind(&Improv::tickSerial, &mImprov), "impro"); - // every([this]() {mPayload.simulation();}, 15, "simul"); + //every([this]() {mPayload.simulation();}, 15, "simul"); } //----------------------------------------------------------------------------- diff --git a/src/app.h b/src/app.h index 85624c9c8..508dcd92c 100644 --- a/src/app.h +++ b/src/app.h @@ -24,7 +24,7 @@ #include "utils/crc.h" #include "utils/dbg.h" #include "utils/scheduler.h" -#include "utils/improv.h" +//#include "utils/improv.h" #include "web/RestApi.h" #include "web/web.h" #include "wifi/ahoywifi.h" @@ -304,7 +304,7 @@ class app : public IApp, public ah::Scheduler { PayloadType mPayload; MiPayloadType mMiPayload; PubSerialType mPubSerial; - Improv mImprov; + //Improv mImprov; #ifdef ESP32 CmtRadioType mCmtRadio; HmsPayloadType mHmsPayload; diff --git a/src/defines.h b/src/defines.h index c97d069d0..07e744fd6 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 7 -#define VERSION_PATCH 23 +#define VERSION_PATCH 24 //------------------------------------- typedef struct { @@ -85,7 +85,7 @@ enum {MQTT_STATUS_OFFLINE = 0, MQTT_STATUS_PARTIAL, MQTT_STATUS_ONLINE}; #define NTP_ADDR_LEN 32 // DNS Name #define MQTT_ADDR_LEN 64 // DNS Name -#define MQTT_CLIENTID_LEN 65 +#define MQTT_CLIENTID_LEN 22 // number of chars is limited to 23 up to v3.1 of MQTT #define MQTT_USER_LEN 65 // there is another byte necessary for \0 #define MQTT_PWD_LEN 65 #define MQTT_TOPIC_LEN 65 diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index 65dfef283..2b3b008af 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -76,11 +76,10 @@ class PubMqtt { if((strlen(mCfgMqtt->user) > 0) && (strlen(mCfgMqtt->pwd) > 0)) mClient.setCredentials(mCfgMqtt->user, mCfgMqtt->pwd); - if(strlen(mCfgMqtt->clientId) > 0) - { - snprintf(mClientId, 24, "%s-", mCfgMqtt->clientId); + if(strlen(mCfgMqtt->clientId) > 0) { + snprintf(mClientId, 23, "%s-", mCfgMqtt->clientId); mClient.setClientId(mCfgMqtt->clientId); - }else{ + } else{ snprintf(mClientId, 24, "%s-", mDevName); uint8_t pos = strlen(mClientId); mClientId[pos++] = WiFi.macAddress().substring( 9, 10).c_str()[0]; @@ -485,8 +484,13 @@ class PubMqtt { // inverter status iv->isProducing(); // recalculate status - if (iv->isAvailable()) + if (InverterStatus::OFF < iv->status) { anyAvail = true; + + snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/last_success", iv->config->name); + snprintf(mVal, 40, "%d", iv->getLastTs(rec)); + publish(mSubTopic, mVal, true); + } else // inverter is enabled but not available allAvail = false; @@ -501,10 +505,6 @@ class PubMqtt { snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/available", iv->config->name); snprintf(mVal, 40, "%d", (uint8_t)iv->status); publish(mSubTopic, mVal, true); - - snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/last_success", iv->config->name); - snprintf(mVal, 40, "%d", iv->getLastTs(rec)); - publish(mSubTopic, mVal, true); } } diff --git a/src/web/html/api.js b/src/web/html/api.js index 5022f0071..917b1f700 100644 --- a/src/web/html/api.js +++ b/src/web/html/api.js @@ -30,6 +30,10 @@ iconSuccess = [ "M10.97 4.97a.235.235 0 0 0-.02.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-1.071-1.05z" ]; +iconSuccessFull = [ + "M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z" +]; + /** * GENERIC FUNCTIONS */ diff --git a/src/web/html/index.html b/src/web/html/index.html index f2afe3c03..9a35a87ec 100644 --- a/src/web/html/index.html +++ b/src/web/html/index.html @@ -119,10 +119,12 @@

Support this project:

function parseIv(obj) { var p = div(["none"]); for(var i of obj) { - var icon = iconWarn; - var cl = "icon-warn"; - avail = ""; + var icon = iconSuccess; + var cl = "icon-success"; + var avail = ""; if(false == i["enabled"]) { + icon = iconWarn; + cl = "icon-warn"; avail = "disabled"; } else if(false == i["is_avail"]) { @@ -131,16 +133,14 @@

Support this project:

avail = "not yet available"; } else if(0 == i["ts_last_success"]) { - icon = iconSuccess; avail = "available but no data was received until now"; } else { - icon = iconSuccess; avail = "available and is "; if(false == i["is_producing"]) avail += "not "; else - cl = "icon-success"; + icon = iconSuccessFull; avail += "producing"; } diff --git a/src/web/html/setup.html b/src/web/html/setup.html index c2bc863de..ebd11b32c 100644 --- a/src/web/html/setup.html +++ b/src/web/html/setup.html @@ -251,7 +251,7 @@
Client Id (optional)
-
+
Username (optional)