From 3e919b4d10b800f1c1c976f18adfd1952f708f90 Mon Sep 17 00:00:00 2001 From: lumapu Date: Sat, 11 Mar 2023 00:12:57 +0100 Subject: [PATCH] removed MQTT subscription `sync_ntp`, `set_time` with a value of `0` does the same #696 simplified MQTT subscription for `limit`. Check User-Manual.md for new syntax #696, #713 repaired inverter wise limit control, #713 --- User_Manual.md | 57 +++++++++---------------------- src/CHANGES.md | 3 ++ src/LICENSE | 7 ---- src/app.cpp | 2 +- src/app.h | 2 +- src/appInterface.h | 2 +- src/defines.h | 4 +-- src/main.cpp | 4 +-- src/publisher/pubMqtt.h | 38 ++++++++++++++------- src/publisher/pubMqttDefs.h | 16 ++------- src/web/html/includes/footer.html | 2 +- 11 files changed, 56 insertions(+), 81 deletions(-) delete mode 100644 src/LICENSE diff --git a/User_Manual.md b/User_Manual.md index 0a0caaed..15247155 100644 --- a/User_Manual.md +++ b/User_Manual.md @@ -91,9 +91,6 @@ The AhoyDTU will publish on the following topics ## Active Power Limit via Serial / Control Page URL: `/serial` -If you leave the field "Active Power Limit" empty during the setup and reboot the ahoy-dtu will set a value of 65535 in the setup. -That is the value you have to fill in case you want to operate the inverter without a active power limit. -If the value is 65535 or -1 after another reboot the value will be set automatically to "100" and in the drop-down menu "relative in percent persistent" will be set. Of course you can do this also by your self. You can change the setting in the following manner. Decide if you want to set @@ -115,24 +112,17 @@ Also an absolute active power limit below approx. 30 Watt seems to be not meanfu ### Generic Information -The AhoyDTU subscribes on three topics `/ctrl/#`, `/setup` and `/status`. +The AhoyDTU subscribes on following topics: + +- `/ctrl/limit/` +- `/ctrl/restart/` +- `/setup/set_time` 👆 `` can be set on setup page, default is `inverter`. 👆 `` is the number of the specific inverter in the setup page. -### Inverter Power (On / Off) -```mqtt -/ctrl/power/ -``` -with payload `1` = `ON` and `0` = `OFF` - -Example: -```mqtt -inverter/ctrl/power/0 1 -``` - ### Inverter restart ```mqtt /ctrl/restart/ @@ -142,50 +132,35 @@ Example: inverter/ctrl/restart/0 ``` -### Power Limit relative persistent [%] +### Power Limit relative (non persistent) [%] ```mqtt -/ctrl/limit_persistent_relative/ +/ctrl/limit/ ``` with a payload `[2 .. 100]` +**NOTE: optional a `%` can be sent as last character** + Example: ```mqtt -inverter/ctrl/limit_persistent_relative/0 70 +inverter/ctrl/limit/0 70 ``` -### Power Limit absolute persistent [Watts] +### Power Limit absolute (non persistent) [Watts] ```mqtt -/ctrl/limit_persistent_absolute/ +/ctrl/limit/ ``` with a payload `[0 .. 65535]` -Example: -```mqtt -inverter/ctrl/limit_persistent_absolute/0 600 -``` - -### Power Limit relative non persistent [%] -```mqtt -/ctrl/limit_nonpersistent_relative/ -``` -with a payload `[2 .. 100]` +**NOTE: the unit `W` is necessary to determine an absolute limit** Example: ```mqtt -inverter/ctrl/limit_nonpersistent_relative/0 70 -``` - -### Power Limit absolute non persistent [Watts] -```mqtt -/ctrl/limit_nonpersistent_absolute/ +inverter/ctrl/limit_nonpersistent_absolute/0 600W ``` -with a payload `[0 .. 65535]` -Example: -```mqtt -inverter/ctrl/limit_nonpersistent_absolute/0 600 -``` +### Power Limit persistent +This feature was removed. The persisten limit should not be modified cyclic by a script because of potential wearout of the flash inside the inverter. ## Control via REST API diff --git a/src/CHANGES.md b/src/CHANGES.md index dd8607ca..45179967 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -4,6 +4,9 @@ ## 0.5.98 * fix SH1106 rotation and turn off during night #756 +* removed MQTT subscription `sync_ntp`, `set_time` with a value of `0` does the same #696 +* simplified MQTT subscription for `limit`. Check [User-Manual.md](../User-Manual.md) for new syntax #696, #713 +* repaired inverter wise limit control ## 0.5.97 * Attention: re-ordered display types, check your settings! #746 diff --git a/src/LICENSE b/src/LICENSE deleted file mode 100644 index 057d1565..00000000 --- a/src/LICENSE +++ /dev/null @@ -1,7 +0,0 @@ -License - -CC-CY-NC-SA 3.0 - -https://creativecommons.org/licenses/by-nc-sa/3.0/de - -This project is for non-commercial use only! diff --git a/src/app.cpp b/src/app.cpp index d65dbe1d..a65d1f09 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -1,6 +1,6 @@ //----------------------------------------------------------------------------- // 2023 Ahoy, https://ahoydtu.de -// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ +// Creative Commons - https://creativecommons.org/licenses/by-nc-sa/4.0/deed //----------------------------------------------------------------------------- #include "app.h" diff --git a/src/app.h b/src/app.h index b68dc0c4..41a77c07 100644 --- a/src/app.h +++ b/src/app.h @@ -1,6 +1,6 @@ //----------------------------------------------------------------------------- // 2023 Ahoy, https://ahoydtu.de -// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ +// Creative Commons - https://creativecommons.org/licenses/by-nc-sa/4.0/deed //----------------------------------------------------------------------------- #ifndef __APP_H__ diff --git a/src/appInterface.h b/src/appInterface.h index 83a4f769..f9a13b03 100644 --- a/src/appInterface.h +++ b/src/appInterface.h @@ -1,6 +1,6 @@ //----------------------------------------------------------------------------- // 2022 Ahoy, https://ahoydtu.de -// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ +// Creative Commons - https://creativecommons.org/licenses/by-nc-sa/4.0/deed //----------------------------------------------------------------------------- #ifndef __IAPP_H__ diff --git a/src/defines.h b/src/defines.h index 13e525bc..6888f8a9 100644 --- a/src/defines.h +++ b/src/defines.h @@ -1,6 +1,6 @@ //----------------------------------------------------------------------------- // 2023 Ahoy, https://www.mikrocontroller.net/topic/525778 -// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ +// Creative Commons - https://creativecommons.org/licenses/by-nc-sa/4.0/deed //----------------------------------------------------------------------------- #ifndef __DEFINES_H__ @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 5 -#define VERSION_PATCH 97 +#define VERSION_PATCH 98 //------------------------------------- typedef struct { diff --git a/src/main.cpp b/src/main.cpp index c585d0f2..af10abce 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,6 @@ //----------------------------------------------------------------------------- -// 2022 Ahoy, https://www.mikrocontroller.net/topic/525778 -// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ +// 2023 Ahoy, https://ahoydtu.de +// Creative Commons - https://creativecommons.org/licenses/by-nc-sa/4.0/deed //----------------------------------------------------------------------------- #include "utils/dbg.h" diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index 4ec4c3f5..d9063c77 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -1,6 +1,6 @@ //----------------------------------------------------------------------------- // 2023 Ahoy, https://ahoydtu.de -// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ +// Creative Commons - https://creativecommons.org/licenses/by-nc-sa/4.0/deed //----------------------------------------------------------------------------- // https://bert.emelis.net/espMqttClient/ @@ -312,13 +312,14 @@ class PubMqtt { tickerMinute(); publish(mLwtTopic, mqttStr[MQTT_STR_LWT_CONN], true, false); - subscribe(subscr[MQTT_SUBS_LMT_PERI_REL]); - subscribe(subscr[MQTT_SUBS_LMT_PERI_ABS]); - subscribe(subscr[MQTT_SUBS_LMT_NONPERI_REL]); - subscribe(subscr[MQTT_SUBS_LMT_NONPERI_ABS]); + char sub[20]; + for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { + snprintf(sub, 20, "ctrl/limit/%d", i); + subscribe(sub); + snprintf(sub, 20, "ctrl/restart/%d", i); + subscribe(sub); + } subscribe(subscr[MQTT_SUBS_SET_TIME]); - subscribe(subscr[MQTT_SUBS_SYNC_NTP]); - //subscribe("status/#"); } void onDisconnect(espMqttClientTypes::DisconnectReason reason) { @@ -358,11 +359,15 @@ class PubMqtt { DynamicJsonDocument json(128); JsonObject root = json.to(); + bool limitAbs = false; if(len > 0) { char *pyld = new char[len + 1]; strncpy(pyld, (const char*)payload, len); pyld[len] = '\0'; - root["val"] = atoi(pyld); + root[F("val")] = atoi(pyld); + DPRINTLN(DBG_INFO, String(pyld) + " " + String(len)); + if(pyld[len-1] == 'W') + limitAbs = true; delete[] pyld; } @@ -377,8 +382,17 @@ class PubMqtt { tmp[pos] = '\0'; switch(elm++) { case 1: root[F("path")] = String(tmp); break; - case 2: root[F("cmd")] = String(tmp); break; - case 3: root[F("id")] = atoi(tmp); break; + case 2: + if(strncmp("limit", tmp, 5) == 0) { + if(limitAbs) + root[F("cmd")] = F("limit_nonpersistent_absolute"); + else + root[F("cmd")] = F("limit_nonpersistent_relative"); + } + else + root[F("cmd")] = String(tmp); + break; + case 3: root[F("id")] = atoi(tmp); break; default: break; } if('\0' == p[pos]) @@ -389,9 +403,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/pubMqttDefs.h b/src/publisher/pubMqttDefs.h index 64309b18..9633e2d4 100644 --- a/src/publisher/pubMqttDefs.h +++ b/src/publisher/pubMqttDefs.h @@ -1,6 +1,6 @@ //----------------------------------------------------------------------------- // 2023 Ahoy, https://ahoydtu.de -// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ +// Creative Commons - https://creativecommons.org/licenses/by-nc-sa/4.0/deed //----------------------------------------------------------------------------- #ifndef __PUB_MQTT_DEFS_H__ @@ -84,21 +84,11 @@ const char* const subtopics[] PROGMEM = { }; enum { - MQTT_SUBS_LMT_PERI_REL, - MQTT_SUBS_LMT_PERI_ABS, - MQTT_SUBS_LMT_NONPERI_REL, - MQTT_SUBS_LMT_NONPERI_ABS, - MQTT_SUBS_SET_TIME, - MQTT_SUBS_SYNC_NTP + MQTT_SUBS_SET_TIME }; const char* const subscr[] PROGMEM = { - "ctrl/limit_persistent_relative", - "ctrl/limit_persistent_absolute", - "ctrl/limit_nonpersistent_relative", - "ctrl/limit_nonpersistent_absolute", - "setup/set_time", - "setup/sync_ntp" + "setup/set_time" }; #endif /*__PUB_MQTT_DEFS_H__*/ diff --git a/src/web/html/includes/footer.html b/src/web/html/includes/footer.html index 5a2b705b..bbc4c6ce 100644 --- a/src/web/html/includes/footer.html +++ b/src/web/html/includes/footer.html @@ -10,7 +10,7 @@