From 38fd15becaee1c7300a639e557c6ce75bcac5fb3 Mon Sep 17 00:00:00 2001 From: DanielR92 Date: Wed, 29 May 2024 18:59:01 +0200 Subject: [PATCH 1/9] Update RestApi.h remove pm_pass, for security reason --- src/web/RestApi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/RestApi.h b/src/web/RestApi.h index 49a7caff..225ae105 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -843,7 +843,7 @@ class RestApi { objGroup[F("pm_src")] = String(mConfig->plugin.zeroExport.groups[group].pm_src); objGroup[F("pm_jsonPath")] = String(mConfig->plugin.zeroExport.groups[group].pm_jsonPath); objGroup[F("pm_user")] = String(mConfig->plugin.zeroExport.groups[group].pm_user); - objGroup[F("pm_pass")] = String(mConfig->plugin.zeroExport.groups[group].pm_pass); + //objGroup[F("pm_pass")] = String(mConfig->plugin.zeroExport.groups[group].pm_pass); // for security reason objGroup[F("pm_target")] = (uint8_t)mConfig->plugin.zeroExport.groups[group].pm_target; // Inverters objGroup[F("max_inverters")] = ZEROEXPORT_GROUP_MAX_INVERTERS; From b159a773f46a7e37e1ee15fabaa9787274dee157 Mon Sep 17 00:00:00 2001 From: DanielR92 Date: Wed, 29 May 2024 19:02:04 +0200 Subject: [PATCH 2/9] add power value to get from restapi --- src/plugins/zeroExport/powermeter.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/zeroExport/powermeter.h b/src/plugins/zeroExport/powermeter.h index eb0e6253..c06e1ab6 100644 --- a/src/plugins/zeroExport/powermeter.h +++ b/src/plugins/zeroExport/powermeter.h @@ -119,7 +119,8 @@ class powermeter { if (result) { bufferWrite(power, group); - + mCfg->groups[group].power = power; + // MQTT - Powermeter if (mMqtt->isConnected()) { mMqtt->publish(String("zero/state/groups/" + String(group) + "/powermeter/P").c_str(), String(ah::round1(power)).c_str(), false); @@ -236,7 +237,8 @@ class powermeter { // } bufferWrite(power, group); - + mCfg->groups[group].power = power; // TODO: join two sites together (PM & MQTT) + // MQTT - Powermeter if (mCfg->debug) { if (mMqtt->isConnected()) { From a1ad25040bbe5c41334577d98e9c0e48c8eb1e4f Mon Sep 17 00:00:00 2001 From: DanielR92 Date: Wed, 29 May 2024 19:04:50 +0200 Subject: [PATCH 3/9] Update platformio.ini for debugging change branch from MQTTClient to a special comit --- src/platformio.ini | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/platformio.ini b/src/platformio.ini index 763ac041..2c6ab3df 100644 --- a/src/platformio.ini +++ b/src/platformio.ini @@ -28,7 +28,11 @@ lib_deps = https://github.com/esphome/ESPAsyncWebServer @ ^3.2.0 https://github.com/nRF24/RF24.git#v1.4.8 paulstoffregen/Time @ ^1.6.1 - https://github.com/bertmelis/espMqttClient#v1.6.0 + ;https://github.com/bertmelis/espMqttClient#v1.6.0 + + ;TODO: tmp. bug fix, please change it to original later + https://github.com/bertmelis/espMqttClient.git#cb0c386 + bblanchon/ArduinoJson @ ^6.21.3 https://github.com/JChristensen/Timezone @ ^1.2.4 olikraus/U8g2 @ ^2.35.9 From 768e0d47bd996acb478ae9aad1b59f9203b09e04 Mon Sep 17 00:00:00 2001 From: Patrick Amrhein Date: Wed, 29 May 2024 22:15:49 +0200 Subject: [PATCH 4/9] 0.8.1030017 --- src/defines.h | 2 +- src/plugins/zeroExport/powermeter.h | 21 +++++++++++---------- src/plugins/zeroExport/zeroExport.h | 20 ++++++++++++-------- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/defines.h b/src/defines.h index 253b50b3..d76e68f6 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 8 -#define VERSION_PATCH 1030016 +#define VERSION_PATCH 1030017 //------------------------------------- typedef struct { uint8_t ch; diff --git a/src/plugins/zeroExport/powermeter.h b/src/plugins/zeroExport/powermeter.h index eb0e6253..bc821b6f 100644 --- a/src/plugins/zeroExport/powermeter.h +++ b/src/plugins/zeroExport/powermeter.h @@ -115,15 +115,15 @@ class powermeter { #endif } - // if (mMqtt->isConnected()) mMqtt->publish(String("zero/state/groups/" + String(group) + "/result").c_str(), String(ret).c_str(), false); - if (result) { bufferWrite(power, group); // MQTT - Powermeter +/// BUG: 002 Anfang - Muss dieser Teil raus? Führt er zu abstürzen wie BUG 001? if (mMqtt->isConnected()) { mMqtt->publish(String("zero/state/groups/" + String(group) + "/powermeter/P").c_str(), String(ah::round1(power)).c_str(), false); } +/// BUG: 002 Ende } } } @@ -218,6 +218,7 @@ class powermeter { float power = 0.0; +/// TODO: Json aktivieren // //TODO: datajson 100 enough? // // this if-statement need to check if value contains a json object. // // is it so, then deserialize it and get the values (Shelly GEN2) @@ -232,19 +233,19 @@ class powermeter { // } // } else { // //TODO: check if parse is possible here? Is that right? - power = (uint16_t)obj["val"]; + power = (float)obj["val"]; // } bufferWrite(power, group); // MQTT - Powermeter - if (mCfg->debug) { - if (mMqtt->isConnected()) { - mMqtt->publish(String("zero/state/groups/" + String(group) + "/powermeter/P").c_str(), String(ah::round1(power)).c_str(), false); - } - } - - return; +/// BUG: 001 Anfang - Dieser Teil ist deaktiviert weil er zu abstürzen der DTU führt +// if (mCfg->debug) { +// if (mMqtt->isConnected()) { +// mMqtt->publish(String("zero/state/groups/" + String(group) + "/powermeter/P").c_str(), String(ah::round1(power)).c_str(), false); +// } +// } +/// BUG: 001 Ende } #endif /*defined(ZEROEXPORT_POWERMETER_MQTT)*/ diff --git a/src/plugins/zeroExport/zeroExport.h b/src/plugins/zeroExport/zeroExport.h index 58541623..f91c2e47 100644 --- a/src/plugins/zeroExport/zeroExport.h +++ b/src/plugins/zeroExport/zeroExport.h @@ -345,9 +345,11 @@ class ZeroExport { sendLog(); // MQTT - Powermeter - if (mMqtt->isConnected()) { - mqttPublish(String("zero/state/groups/" + String(group) + "/inverter/" + String(inv)).c_str(), mDocLog.as().c_str()); - } +/// BUG: 003 Anfang +// if (mMqtt->isConnected()) { +// mqttPublish(String("zero/state/groups/" + String(group) + "/inverter/" + String(inv)).c_str(), mDocLog.as().c_str()); +// } +/// BUG: 003 Ende clearLog(); @@ -821,11 +823,13 @@ class ZeroExport { } // Log over MQTT - if (mCfg->log_over_mqtt) { - if (mMqtt->isConnected()) { - mMqtt->publish("zero/log", mDocLog.as().c_str(), false); - } - } +/// BUG: 004 Anfang +// if (mCfg->log_over_mqtt) { +// if (mMqtt->isConnected()) { +// mMqtt->publish("zero/log", mDocLog.as().c_str(), false); +// } +// } +/// BUG: 004 Ende } /** clearLog From 418c387c11081a1ea11ee9ceda0fc8d8d82ac46e Mon Sep 17 00:00:00 2001 From: DanielR92 Date: Wed, 29 May 2024 23:16:53 +0200 Subject: [PATCH 5/9] Update setup.html fix bug for battery_btn (need to discussed with lumapu) --- src/web/html/setup.html | 53 +++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/src/web/html/setup.html b/src/web/html/setup.html index 1b0a9f07..4d6ba40f 100644 --- a/src/web/html/setup.html +++ b/src/web/html/setup.html @@ -1300,9 +1300,20 @@ } function battOnOff() { + // TODO: zuerst wert setzen + // dann über ajax denn gesetzten wert zurück aus dem system holen + // damit man sieht das es erfolgreich gesetzt worden ist. + const sw = document.getElementById("battSwitch"); + if (sw.value == 0) { + sw.value = 1; + sw.innerHTML = "{#BTN_ON}"; + } else { + sw.value = 0; + sw.innerHTML = "{#BTN_OFF}"; + } + var obj = {cmd: "ze_batt_onff", token: "*"} getAjax("/api/setup", apiCbBattOnOff, "POST", JSON.stringify(obj)); -// setTimeout(function() {getAjax('/api/setup/networks', listNetworks)}, 5000); } function ZeroExportGroup_Modal(obj, ivObj) { @@ -1427,27 +1438,15 @@ ]), // Battery ml("div", {id: "div{#ZE_GROUP_TAB_BATTERY}", class: "tab-content hide"}, [ - divRow("{#ZE_GROUP_TAB_BATTERY_CFG}", - ml("select", {name: "battCfg", class: "text", id: "battCfg"}, null), - ), - divRow("{#ZE_GROUP_TAB_BATTERY_TOPIC}", - ml("input", {name: "battTopic", class: "text", type: "text", value: obj.battTopic}, null), - ), - divRow("{#ZE_GROUP_TAB_BATTERY_LIMITON}", - ml("input", {name: "battLimitOn", class: "text", type: "number", min: "0", max: "100", step: "0.1", value: obj.battLimitOn}, null), - ), - divRow("{#ZE_GROUP_TAB_BATTERY_LIMITOFF}", - ml("input", {name: "battLimitOff", class: "text", type: "number", min: "0", max: "100", step: "0.1", value: obj.battLimitOff}, null), - ), - divRow("{#ZE_GROUP_TAB_BATTERY_ONOFF}", ml("input", {name: "battSwitch", id: "battSwitch", class: "btn", type: "button", value: "{#BTN_ONOFF}", onclick: battOnOff()}, null)), + divRow("{#ZE_GROUP_TAB_BATTERY_CFG}", ml("select", {name: "battCfg", class: "text", id: "battCfg"}, null),), + divRow("{#ZE_GROUP_TAB_BATTERY_TOPIC}", ml("input", {name: "battTopic", class: "text", type: "text", value: obj.battTopic}, null),), + divRow("{#ZE_GROUP_TAB_BATTERY_LIMITON}", ml("input", {name: "battLimitOn", class: "text", type: "number", min: "0", max: "100", step: "0.1", value: obj.battLimitOn}, null),), + divRow("{#ZE_GROUP_TAB_BATTERY_LIMITOFF}", ml("input", {name: "battLimitOff", class: "text", type: "number", min: "0", max: "100", step: "0.1", value: obj.battLimitOff}, null),), + divRow("{#ZE_GROUP_TAB_BATTERY_ONOFF}", ml("input", {name: "battSwitch", id: "battSwitch", class: "btn", type: "button", value: obj.battSwitch}, null)), // TODO: Uebersetzen mit lang.json und auf die entsprechende Dokuseite verlinken - divRow("Hinweis: ", - ml("a", {href: "https://docs.ahoydtu.de/de/latest/zeroExport.html"}, "Bitte beachten Sie die Ausfüllhinweise in der Dokumentation."), - ), + divRow("Hinweis: ", ml("a", {href: "https://docs.ahoydtu.de/de/latest/zeroExport.html"}, "Bitte beachten Sie die Ausfüllhinweise in der Dokumentation."),), // TODO: Hinweis Github/Discord - Entfernen wenn erledigt - divRow("ACHTUNG: ", - ml("a", {href: "https://discord.com/channels/984173303147155506/1211365440253726851"}, "Bitte auf Github keine Issues zu Zero eröffnen, sondern direkt im Discord melden."), - ), + divRow("ACHTUNG: ", ml("a", {href: "https://discord.com/channels/984173303147155506/1211365440253726851"}, "Bitte auf Github keine Issues zu Zero eröffnen, sondern direkt im Discord melden."),), ]), // Advanced ml("div", {id: "div{#ZE_GROUP_TAB_ADVANCED}", class: "tab-content hide"}, [ @@ -1459,13 +1458,9 @@ divRow("{#ZE_GROUP_TAB_ADVANCED_KI}", ml("input", {name: "Ki", class: "text", type: "number", min: "-0.01", max: "0", step: "0.001", value: obj.Ki}, null)), divRow("{#ZE_GROUP_TAB_ADVANCED_KD}", ml("input", {name: "Kd", class: "text", type: "number", min: "-0.01", max: "0", step: "0.001", value: obj.Kd}, null)), // TODO: Uebersetzen mit lang.json und auf die entsprechende Dokuseite verlinken - divRow("Hinweis: ", - ml("a", {href: "https://docs.ahoydtu.de/de/latest/zeroExport.html"}, "Bitte beachten Sie die Ausfüllhinweise in der Dokumentation."), - ), + divRow("Hinweis: ", ml("a", {href: "https://docs.ahoydtu.de/de/latest/zeroExport.html"}, "Bitte beachten Sie die Ausfüllhinweise in der Dokumentation."),), // TODO: Hinweis Github/Discord - Entfernen wenn erledigt - divRow("ACHTUNG: ", - ml("a", {href: "https://discord.com/channels/984173303147155506/1211365440253726851"}, "Bitte auf Github keine Issues zu Zero eröffnen, sondern direkt im Discord melden."), - ), + divRow("ACHTUNG: ", ml("a", {href: "https://discord.com/channels/984173303147155506/1211365440253726851"}, "Bitte auf Github keine Issues zu Zero eröffnen, sondern direkt im Discord melden."),), ]), // Global ml("div", {class: "row mt-5"}, [ @@ -1475,6 +1470,10 @@ ]); modal("{#ZE_GROUP_EDIT_MODAL}: " + obj.id, html); + + // add addEventListener for battSwitch + const se_battswitch = document.querySelector("#battSwitch"); + se_battswitch.addEventListener("click", (event) => { battOnOff()}); // ser.dispatchEvent(new Event('change')); // Tab_Powermeter @@ -1662,6 +1661,8 @@ o.battTopic = document.getElementsByName("battTopic")[0].value; o.battLimitOn = document.getElementsByName("battLimitOn")[0].value; o.battLimitOff = document.getElementsByName("battLimitOff")[0].value; + //o.battSwitch = document.getElementsByName("battSwitch")[0].value; + // Advanced o.setPoint = document.getElementsByName("setPoint")[0].value; o.minimum = document.getElementsByName("minimum")[0].checked; From c1556906816beb12c70fa66acc7c34173430c33d Mon Sep 17 00:00:00 2001 From: DanielR92 Date: Wed, 29 May 2024 23:18:19 +0200 Subject: [PATCH 6/9] Update RestApi.h add line for batswitch if-statement remove --- src/web/RestApi.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/web/RestApi.h b/src/web/RestApi.h index 225ae105..0ffeb9b9 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -843,7 +843,7 @@ class RestApi { objGroup[F("pm_src")] = String(mConfig->plugin.zeroExport.groups[group].pm_src); objGroup[F("pm_jsonPath")] = String(mConfig->plugin.zeroExport.groups[group].pm_jsonPath); objGroup[F("pm_user")] = String(mConfig->plugin.zeroExport.groups[group].pm_user); - //objGroup[F("pm_pass")] = String(mConfig->plugin.zeroExport.groups[group].pm_pass); // for security reason + objGroup[F("pm_pass")] = String(mConfig->plugin.zeroExport.groups[group].pm_pass); objGroup[F("pm_target")] = (uint8_t)mConfig->plugin.zeroExport.groups[group].pm_target; // Inverters objGroup[F("max_inverters")] = ZEROEXPORT_GROUP_MAX_INVERTERS; @@ -861,6 +861,8 @@ class RestApi { objGroup[F("battTopic")] = String(mConfig->plugin.zeroExport.groups[group].battTopic); objGroup[F("battLimitOn")] = ah::round1((float)mConfig->plugin.zeroExport.groups[group].battLimitOn); objGroup[F("battLimitOff")] = ah::round1((float)mConfig->plugin.zeroExport.groups[group].battLimitOff); + objGroup[F("battSwitch")] = (bool)mConfig->plugin.zeroExport.groups[group].battSwitch; + // Advanced objGroup[F("setPoint")] = (int16_t)mConfig->plugin.zeroExport.groups[group].setPoint; objGroup[F("minimum")] = (bool)mConfig->plugin.zeroExport.groups[group].minimum; @@ -1145,12 +1147,7 @@ class RestApi { #if defined(PLUGIN_ZEROEXPORT) else if(F("ze_batt_onff") == jsonIn[F("cmd")]) { uint8_t group = jsonIn[F("id")]; -// if (mConfig->plugin.zeroExport.groups[group].battSwitch) { -// mConfig->plugin.zeroExport.groups[group].battSwitch = false; -// } else { - mConfig->plugin.zeroExport.groups[group].battSwitch = true; -// } -// mConfig->plugin.zeroExport.groups[group].battSwitch = jsonIn[F("battSwitch")]; + mConfig->plugin.zeroExport.groups[group].battSwitch = (bool)jsonIn[F("battSwitch")]; } else if(F("ze_save_group") == jsonIn[F("cmd")]) { // General From f167deb4d6706e4936934f9b7907ea929f1bf445 Mon Sep 17 00:00:00 2001 From: DanielR92 Date: Wed, 29 May 2024 23:18:56 +0200 Subject: [PATCH 7/9] Update lang.json --- src/web/lang.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/web/lang.json b/src/web/lang.json index 1172d670..7e156d61 100644 --- a/src/web/lang.json +++ b/src/web/lang.json @@ -979,10 +979,15 @@ "de": "Power:" }, { - "token": "BTN_ONOFF", + "token": "BTN_ON", "en": "On", "de": "Ein" }, + { + "token": "BTN_OFF", + "en": "Off", + "de": "Aus" + }, { "token": "ZE_GROUP_TAB_ADVANCED", "en": "Advanced", From 50fb5970b6357f179a8e546df35d9d2fdd69a748 Mon Sep 17 00:00:00 2001 From: DanielR92 Date: Wed, 29 May 2024 23:20:49 +0200 Subject: [PATCH 8/9] fix pm_pass --- src/web/RestApi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/RestApi.h b/src/web/RestApi.h index 0ffeb9b9..3dd96d94 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -843,7 +843,7 @@ class RestApi { objGroup[F("pm_src")] = String(mConfig->plugin.zeroExport.groups[group].pm_src); objGroup[F("pm_jsonPath")] = String(mConfig->plugin.zeroExport.groups[group].pm_jsonPath); objGroup[F("pm_user")] = String(mConfig->plugin.zeroExport.groups[group].pm_user); - objGroup[F("pm_pass")] = String(mConfig->plugin.zeroExport.groups[group].pm_pass); + //objGroup[F("pm_pass")] = String(mConfig->plugin.zeroExport.groups[group].pm_pass); // for security reason objGroup[F("pm_target")] = (uint8_t)mConfig->plugin.zeroExport.groups[group].pm_target; // Inverters objGroup[F("max_inverters")] = ZEROEXPORT_GROUP_MAX_INVERTERS; From b5433d64262e5af108505dc5213a98d6195bbb5a Mon Sep 17 00:00:00 2001 From: Patrick Amrhein Date: Wed, 29 May 2024 23:50:52 +0200 Subject: [PATCH 9/9] 0.8.1030018 --- src/defines.h | 2 +- src/platformio.ini | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/defines.h b/src/defines.h index d76e68f6..ffdbadf2 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 8 -#define VERSION_PATCH 1030017 +#define VERSION_PATCH 1030018 //------------------------------------- typedef struct { uint8_t ch; diff --git a/src/platformio.ini b/src/platformio.ini index 2c6ab3df..4b124944 100644 --- a/src/platformio.ini +++ b/src/platformio.ini @@ -28,11 +28,7 @@ lib_deps = https://github.com/esphome/ESPAsyncWebServer @ ^3.2.0 https://github.com/nRF24/RF24.git#v1.4.8 paulstoffregen/Time @ ^1.6.1 - ;https://github.com/bertmelis/espMqttClient#v1.6.0 - - ;TODO: tmp. bug fix, please change it to original later - https://github.com/bertmelis/espMqttClient.git#cb0c386 - + https://github.com/bertmelis/espMqttClient#v1.7.0 bblanchon/ArduinoJson @ ^6.21.3 https://github.com/JChristensen/Timezone @ ^1.2.4 olikraus/U8g2 @ ^2.35.9