From 93999ade0f0851285ecad497ff6864b827d948be Mon Sep 17 00:00:00 2001 From: Gerald Date: Mon, 31 Jul 2023 19:52:36 +0200 Subject: [PATCH 1/4] =?UTF-8?q?Prevent=20line=20break=20between=20power=20?= =?UTF-8?q?limit=20value=20and=20its=20unit=20("%")=20and=20remove=20the?= =?UTF-8?q?=20space=20between=20"=C2=B0=20C".?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- User_Manual.md | 2 +- src/web/html/api.js | 3 +-- src/web/html/visualization.html | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/User_Manual.md b/User_Manual.md index a7be8f80..4d566474 100644 --- a/User_Manual.md +++ b/User_Manual.md @@ -63,7 +63,7 @@ The AhoyDTU will publish on the following topics |Q_AC | 21.200| actual AC reactive power in var| |F_AC | 49.990| actual AC Frequency in Hz| |PF_AC | 95.800| actual AC Power factor| -|Temp | 19.800|Temperature of inverter in Celsius| +|Temp | 19.800|Temperature of inverter in degree Celsius| |EVT | 9.000|Last Event/Alarm Message Index| |YieldDay | 51.000|Energy converted to AC per day in Watt hours (measured on DC)| |YieldTotal | 465.294|Energy converted to AC since reset Watt hours (measured on DC)| diff --git a/src/web/html/api.js b/src/web/html/api.js index 13ca50b5..5e99f58f 100644 --- a/src/web/html/api.js +++ b/src/web/html/api.js @@ -52,8 +52,7 @@ function ml(tagName, ...args) { function nester(el, n) { if (typeof n === "string") { - var t = document.createTextNode(n); - el.appendChild(t); + el.innerHTML = n; } else if (n instanceof Array) { for(var i = 0; i < n.length; i++) { if (typeof n[i] === "string") { diff --git a/src/web/html/visualization.html b/src/web/html/visualization.html index de5b0069..431dadd9 100644 --- a/src/web/html/visualization.html +++ b/src/web/html/visualization.html @@ -93,13 +93,13 @@ total[2] += obj.ch[0][6]; // YieldTotal total[3] += obj.ch[0][8]; // P_DC total[4] += obj.ch[0][10]; // Q_AC - var t = span(" ° C"); + var t = span(" °C"); return ml("div", {class: "row mt-2"}, ml("div", {class: "col"}, [ ml("div", {class: "p-2 iv-h"}, ml("div", {class: "row"}, [ ml("div", {class: "col mx-2 mx-md-1"}, obj.name), - ml("div", {class: "col a-c"}, "Power limit " + ((obj.power_limit_read == 65535) ? "n/a" : (obj.power_limit_read + " %"))), + ml("div", {class: "col a-c"}, "Power limit " + ((obj.power_limit_read == 65535) ? "n/a" : (obj.power_limit_read + " %"))), ml("div", {class: "col a-r mx-2 mx-md-1"}, String(obj.ch[0][5]) + t.innerHTML) ]) ), From d7d25303c3c87c27398fcd21140a34f1dce6f32a Mon Sep 17 00:00:00 2001 From: Gerald Date: Mon, 31 Jul 2023 19:56:41 +0200 Subject: [PATCH 2/4] Use a non-breaking space between the inverter temperature value and its unit. --- src/web/html/visualization.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/web/html/visualization.html b/src/web/html/visualization.html index 431dadd9..538c732b 100644 --- a/src/web/html/visualization.html +++ b/src/web/html/visualization.html @@ -93,14 +93,14 @@ total[2] += obj.ch[0][6]; // YieldTotal total[3] += obj.ch[0][8]; // P_DC total[4] += obj.ch[0][10]; // Q_AC - var t = span(" °C"); + var t = span(" °C"); return ml("div", {class: "row mt-2"}, ml("div", {class: "col"}, [ ml("div", {class: "p-2 iv-h"}, ml("div", {class: "row"}, [ ml("div", {class: "col mx-2 mx-md-1"}, obj.name), ml("div", {class: "col a-c"}, "Power limit " + ((obj.power_limit_read == 65535) ? "n/a" : (obj.power_limit_read + " %"))), - ml("div", {class: "col a-r mx-2 mx-md-1"}, String(obj.ch[0][5]) + t.innerHTML) + ml("div", {class: "col a-r mx-2 mx-md-1"}, String(obj.ch[0][5]) + t.innerText) ]) ), ml("div", {class: "p-2 iv-bg"}, [ From 47c4ca6551b4e402c0030515b6920daf05bb107e Mon Sep 17 00:00:00 2001 From: lumapu Date: Fri, 4 Aug 2023 18:26:42 +0200 Subject: [PATCH 3/4] 0.7.22 * attempt to fix homeassistant auto discovery #1066 --- src/CHANGES.md | 3 +++ src/defines.h | 2 +- src/publisher/pubMqtt.h | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index 731cd479..e997d1cb 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,8 @@ # Development Changes +## 0.7.22 - 2023-08-04 +* attempt to fix homeassistant auto discovery #1066 + ## 0.7.21 - 2023-07-30 * fix MqTT YieldDay Total goes to 0 serveral times #1016 diff --git a/src/defines.h b/src/defines.h index 579a2d8f..57b367bb 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 7 -#define VERSION_PATCH 21 +#define VERSION_PATCH 22 //------------------------------------- typedef struct { diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index fa12e969..771b1ee8 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -391,9 +391,9 @@ class PubMqtt { const char *devCls, *stateCls; if (!total) { if (rec->assign[mDiscovery.sub].ch == CH0) - snprintf(name, 32, "%s %s", iv->config->name, iv->getFieldName(mDiscovery.sub, rec)); + snprintf(name, 32, "%s %s", iv->getFieldName(mDiscovery.sub, rec)); else - snprintf(name, 32, "%s CH%d %s", iv->config->name, rec->assign[mDiscovery.sub].ch, iv->getFieldName(mDiscovery.sub, rec)); + snprintf(name, 32, "CH%d_%s", rec->assign[mDiscovery.sub].ch, iv->getFieldName(mDiscovery.sub, rec)); snprintf(topic, 64, "/ch%d/%s", rec->assign[mDiscovery.sub].ch, iv->getFieldName(mDiscovery.sub, rec)); snprintf(uniq_id, 32, "ch%d_%s", rec->assign[mDiscovery.sub].ch, iv->getFieldName(mDiscovery.sub, rec)); From 3a944d182bc3390e2f5cde2ab90a101d3fea8da5 Mon Sep 17 00:00:00 2001 From: lumapu Date: Sat, 5 Aug 2023 00:50:24 +0200 Subject: [PATCH 4/4] 0.7.23 * merge PR #1056, visualization html * update MqTT library to 1.4.4 * update RF24 library to 1.4.7 * update ArduinoJson library to 6.21.3 * set minimum invervall for `/live` to 5 seconds --- src/CHANGES.md | 7 ++++ src/app.h | 3 +- src/defines.h | 2 +- src/hm/hmPayload.h | 2 +- src/platformio.ini | 74 ++++++++++++++++++--------------- src/publisher/pubMqtt.h | 20 +++------ src/web/html/visualization.html | 6 ++- 7 files changed, 61 insertions(+), 53 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index e997d1cb..c48c834e 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,12 @@ # Development Changes +## 0.7.23 - 2023-08-04 +* merge PR #1056, visualization html +* update MqTT library to 1.4.4 +* update RF24 library to 1.4.7 +* update ArduinoJson library to 6.21.3 +* set minimum invervall for `/live` to 5 seconds + ## 0.7.22 - 2023-08-04 * attempt to fix homeassistant auto discovery #1066 diff --git a/src/app.h b/src/app.h index 585147b2..85624c9c 100644 --- a/src/app.h +++ b/src/app.h @@ -8,7 +8,6 @@ #include #include -#include #include "appInterface.h" #include "config/settings.h" @@ -30,6 +29,8 @@ #include "web/web.h" #include "wifi/ahoywifi.h" +#include // position is relevant since version 1.4.7 of this library + // convert degrees and radians for sun calculation #define SIN(x) (sin(radians(x))) #define COS(x) (cos(radians(x))) diff --git a/src/defines.h b/src/defines.h index 57b367bb..d060515b 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 7 -#define VERSION_PATCH 22 +#define VERSION_PATCH 23 //------------------------------------- typedef struct { diff --git a/src/hm/hmPayload.h b/src/hm/hmPayload.h index 2b59cd69..ce8268c8 100644 --- a/src/hm/hmPayload.h +++ b/src/hm/hmPayload.h @@ -92,7 +92,7 @@ class HmPayload { yield(); } iv->doCalculations(); - notify(0x0b); + notify(0x0b, iv); }*/ void ivSendHighPrio(Inverter<> *iv) { diff --git a/src/platformio.ini b/src/platformio.ini index c05908f0..1bcd60f5 100644 --- a/src/platformio.ini +++ b/src/platformio.ini @@ -24,10 +24,10 @@ extra_scripts = lib_deps = https://github.com/yubox-node-org/ESPAsyncWebServer - nrf24/RF24 @ 1.4.5 + nrf24/RF24 @ 1.4.7 paulstoffregen/Time @ ^1.6.1 - https://github.com/bertmelis/espMqttClient#v1.4.2 - bblanchon/ArduinoJson @ ^6.21.2 + https://github.com/bertmelis/espMqttClient#v1.4.4 + bblanchon/ArduinoJson @ ^6.21.3 https://github.com/JChristensen/Timezone @ ^1.2.4 olikraus/U8g2 @ ^2.34.17 zinggjm/GxEPD2 @ ^1.5.2 @@ -37,12 +37,12 @@ lib_deps = platform = espressif8266 board = esp12e board_build.f_cpu = 80000000L -build_flags = -D RELEASE -std=gnu++17 +build_flags = + -D RELEASE + -std=gnu++17 + -DEMC_MIN_FREE_MEMORY=4096 ;-Wl,-Map,output.map monitor_filters = - ;default ; Remove typical terminal control codes from input - ;time ; Add timestamp with milliseconds for each new line - ;log2file ; Log data to a file “platformio-device-monitor-*.log” located in the current working directory esp8266_exception_decoder @@ -50,21 +50,31 @@ monitor_filters = platform = espressif8266 board = esp12e board_build.f_cpu = 80000000L -build_flags = -D RELEASE -std=gnu++17 -DENABLE_PROMETHEUS_EP +build_flags = + -D RELEASE + -std=gnu++17 + -DENABLE_PROMETHEUS_EP + -DEMC_MIN_FREE_MEMORY=4096 monitor_filters = - ;default ; Remove typical terminal control codes from input - ;time ; Add timestamp with milliseconds for each new line - ;log2file ; Log data to a file “platformio-device-monitor-*.log” located in the current working directory esp8266_exception_decoder [env:esp8266-debug] platform = espressif8266 board = esp12e board_build.f_cpu = 80000000L -build_flags = -DDEBUG_LEVEL=DBG_DEBUG -std=gnu++17 -DDEBUG_ESP_CORE -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_OOM -DDEBUG_ESP_PORT=Serial -DPIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48 +build_flags = + -DDEBUG_LEVEL=DBG_DEBUG + -std=gnu++17 + -DEMC_MIN_FREE_MEMORY=4096 + -DDEBUG_ESP_CORE + -DDEBUG_ESP_WIFI + -DDEBUG_ESP_HTTP_CLIENT + -DDEBUG_ESP_HTTP_SERVER + -DDEBUG_ESP_OOM + -DDEBUG_ESP_PORT=Serial + -DPIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48 build_type = debug monitor_filters = - ;default ; Remove typical terminal control codes from input time ; Add timestamp with milliseconds for each new line log2file ; Log data to a file “platformio-device-monitor-*.log” located in the current working directory @@ -73,18 +83,21 @@ platform = espressif8266 board = esp8285 board_build.ldscript = eagle.flash.1m64.ld board_build.f_cpu = 80000000L -build_flags = -D RELEASE -std=gnu++17 +build_flags = + -D RELEASE + -std=gnu++17 + -DEMC_MIN_FREE_MEMORY=4096 monitor_filters = - ;default ; Remove typical terminal control codes from input time ; Add timestamp with milliseconds for each new line - ;log2file ; Log data to a file “platformio-device-monitor-*.log” located in the current working directory [env:esp8285-debug] platform = espressif8266 board = esp8285 board_build.ldscript = eagle.flash.1m64.ld board_build.f_cpu = 80000000L -build_flags = -DDEBUG_LEVEL=DBG_DEBUG +build_flags = + -DDEBUG_LEVEL=DBG_DEBUG + -DEMC_MIN_FREE_MEMORY=4096 -DDEBUG_ESP_CORE -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_CLIENT @@ -93,38 +106,35 @@ build_flags = -DDEBUG_LEVEL=DBG_DEBUG -DDEBUG_ESP_PORT=Serial build_type = debug monitor_filters = - ;default ; Remove typical terminal control codes from input time ; Add timestamp with milliseconds for each new line log2file ; Log data to a file “platformio-device-monitor-*.log” located in the current working directory [env:esp32-wroom32-release] platform = espressif32@6.1.0 board = lolin_d32 -build_flags = -D RELEASE -std=gnu++17 +build_flags = + -D RELEASE + -std=gnu++17 build_unflags = -std=gnu++11 monitor_filters = - ;default ; Remove typical terminal control codes from input - ;time ; Add timestamp with milliseconds for each new line - ;log2file ; Log data to a file “platformio-device-monitor-*.log” located in the current working directory esp32_exception_decoder [env:esp32-wroom32-release-prometheus] platform = espressif32@6.1.0 board = lolin_d32 -build_flags = -D RELEASE +build_flags = + -D RELEASE -std=gnu++17 -DENABLE_PROMETHEUS_EP build_unflags = -std=gnu++11 monitor_filters = - ;default ; Remove typical terminal control codes from input - ;time ; Add timestamp with milliseconds for each new line - ;log2file ; Log data to a file “platformio-device-monitor-*.log” located in the current working directory esp32_exception_decoder [env:esp32-wroom32-debug] platform = espressif32@6.1.0 board = lolin_d32 -build_flags = -DDEBUG_LEVEL=DBG_DEBUG +build_flags = + -DDEBUG_LEVEL=DBG_DEBUG -DDEBUG_ESP_CORE -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_CLIENT @@ -135,7 +145,6 @@ build_flags = -DDEBUG_LEVEL=DBG_DEBUG build_unflags = -std=gnu++11 build_type = debug monitor_filters = - ;default ; Remove typical terminal control codes from input time ; Add timestamp with milliseconds for each new line log2file ; Log data to a file “platformio-device-monitor-*.log” located in the current working directory @@ -143,12 +152,11 @@ monitor_filters = platform = espressif32@6.1.0 board = esp32-s3-devkitc-1 upload_protocol = esp-builtin -upload_speed = 115200 debug_tool = esp-builtin debug_speed = 12000 -build_flags = -D RELEASE -std=gnu++17 +build_flags = + -D RELEASE + -std=gnu++17 build_unflags = -std=gnu++11 monitor_filters = - ;default ; Remove typical terminal control codes from input - time ; Add timestamp with milliseconds for each new line - ;log2file ; Log data to a file “platformio-device-monitor-*.log” located in the current working directory + time ; Add timestamp with milliseconds for each new line \ No newline at end of file diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index 771b1ee8..0e160f73 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -184,23 +184,13 @@ class PubMqtt { if(!mClient.connected()) return; - if(addTopic){ + if(addTopic) snprintf(mTopic, MQTT_TOPIC_LEN + 32 + MAX_NAME_LENGTH + 1, "%s/%s", mCfgMqtt->topic, subTopic); - } else { + else snprintf(mTopic, MQTT_TOPIC_LEN + 32 + MAX_NAME_LENGTH + 1, "%s", subTopic); - } - - do { - if(0 != mClient.publish(mTopic, QOS_0, retained, payload)) - break; - if(!mClient.connected()) - break; - #if defined(ESP8266) - mClient.loop(); - #endif - yield(); - } while(1); + mClient.publish(mTopic, QOS_0, retained, payload); + yield(); mTxCnt++; } @@ -391,7 +381,7 @@ class PubMqtt { const char *devCls, *stateCls; if (!total) { if (rec->assign[mDiscovery.sub].ch == CH0) - snprintf(name, 32, "%s %s", iv->getFieldName(mDiscovery.sub, rec)); + snprintf(name, 32, "%s", iv->getFieldName(mDiscovery.sub, rec)); else snprintf(name, 32, "CH%d_%s", rec->assign[mDiscovery.sub].ch, iv->getFieldName(mDiscovery.sub, rec)); snprintf(topic, 64, "/ch%d/%s", rec->assign[mDiscovery.sub].ch, iv->getFieldName(mDiscovery.sub, rec)); diff --git a/src/web/html/visualization.html b/src/web/html/visualization.html index b9914af4..d7a4ab0e 100644 --- a/src/web/html/visualization.html +++ b/src/web/html/visualization.html @@ -221,9 +221,11 @@ break; } } - document.getElementById("refresh").innerHTML = obj["refresh"]; + if(obj.refresh < 5) + obj.refresh = 5; + document.getElementById("refresh").innerHTML = obj.refresh; if(true == exeOnce) { - window.setInterval("getAjax('/api/live', parse)", obj["refresh"] * 1000); + window.setInterval("getAjax('/api/live', parse)", obj.refresh * 1000); exeOnce = false; } }