From 05978a01f85761aac6f0e4645677c146d644aace Mon Sep 17 00:00:00 2001 From: DanielR92 Date: Sat, 11 May 2024 23:12:42 +0200 Subject: [PATCH] some notes for tibber problems & format zeroexport --- src/platformio.ini | 46 +++++++----- src/plugins/zeroExport/powermeter.h | 7 +- src/plugins/zeroExport/zeroExport.h | 107 ++++++++++------------------ 3 files changed, 75 insertions(+), 85 deletions(-) diff --git a/src/platformio.ini b/src/platformio.ini index 8d36207c..763ac041 100644 --- a/src/platformio.ini +++ b/src/platformio.ini @@ -40,7 +40,6 @@ build_flags = build_unflags = -std=gnu++11 - [env:esp8266-minimal] platform = espressif8266 board = esp12e @@ -148,7 +147,7 @@ monitor_filters = esp8266_exception_decoder [env:esp32-wroom32-minimal] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = lolin_d32 build_flags = ${env.build_flags} -DUSE_HSPI_FOR_EPD @@ -156,7 +155,7 @@ monitor_filters = esp32_exception_decoder [env:esp32-wroom32] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = lolin_d32 build_flags = ${env:esp32-wroom32-minimal.build_flags} -DENABLE_MQTT @@ -167,7 +166,7 @@ monitor_filters = esp32_exception_decoder [env:esp32-wroom32-de] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = lolin_d32 build_flags = ${env:esp32-wroom32.build_flags} -DLANG_DE @@ -175,7 +174,7 @@ monitor_filters = esp32_exception_decoder [env:esp32-wroom32-prometheus] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = lolin_d32 build_flags = ${env:esp32-wroom32.build_flags} -DENABLE_PROMETHEUS_EP @@ -183,7 +182,7 @@ monitor_filters = esp32_exception_decoder [env:esp32-wroom32-prometheus-de] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = lolin_d32 build_flags = ${env:esp32-wroom32-prometheus.build_flags} -DLANG_DE @@ -219,7 +218,7 @@ monitor_filters = esp32_exception_decoder [env:esp32-s2-mini] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = lolin_s2_mini build_flags = ${env.build_flags} -DUSE_HSPI_FOR_EPD @@ -242,7 +241,7 @@ monitor_filters = esp32_exception_decoder [env:esp32-s2-mini-de] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = lolin_s2_mini build_flags = ${env:esp32-s2-mini.build_flags} -DLANG_DE @@ -250,7 +249,7 @@ monitor_filters = esp32_exception_decoder [env:esp32-c3-mini] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = lolin_c3_mini build_flags = ${env.build_flags} -DUSE_HSPI_FOR_EPD @@ -273,7 +272,7 @@ monitor_filters = esp32_exception_decoder [env:esp32-c3-mini-de] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = lolin_c3_mini build_flags = ${env:esp32-c3-mini.build_flags} -DLANG_DE @@ -281,7 +280,7 @@ monitor_filters = esp32_exception_decoder [env:opendtufusion-minimal] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = esp32-s3-devkitc-1 upload_protocol = esp-builtin build_flags = ${env.build_flags} @@ -306,19 +305,18 @@ monitor_filters = esp32_exception_decoder, colorize [env:opendtufusion] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = esp32-s3-devkitc-1 upload_protocol = esp-builtin build_flags = ${env:opendtufusion-minimal.build_flags} -DENABLE_MQTT -DPLUGIN_DISPLAY -DENABLE_HISTORY - -DPLUGIN_ZEROEXPORT monitor_filters = esp32_exception_decoder, colorize [env:opendtufusion-de] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = esp32-s3-devkitc-1 upload_protocol = esp-builtin build_flags = ${env:opendtufusion.build_flags} @@ -326,8 +324,24 @@ build_flags = ${env:opendtufusion.build_flags} monitor_filters = esp32_exception_decoder, colorize +[env:opendtufusion-zero_export] +platform = espressif32@6.6.0 +board = esp32-s3-devkitc-1 +upload_protocol = esp-builtin +build_flags = ${env:opendtufusion.build_flags} + -DPLUGIN_ZEROEXPORT +monitor_filters = + esp32_exception_decoder, colorize + +[env:opendtufusion-zero_export-de] +platform = espressif32@6.6.0 +board = esp32-s3-devkitc-1 +upload_protocol = esp-builtin +build_flags = ${env:opendtufusion-zero_export.build_flags} + -DLANG_DE + [env:opendtufusion-ethernet] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = esp32-s3-devkitc-1 upload_protocol = esp-builtin build_flags = ${env:opendtufusion-minimal.build_flags} @@ -347,7 +361,7 @@ monitor_filters = esp32_exception_decoder, colorize [env:opendtufusion-ethernet-de] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = esp32-s3-devkitc-1 upload_protocol = esp-builtin build_flags = ${env:opendtufusion-ethernet.build_flags} diff --git a/src/plugins/zeroExport/powermeter.h b/src/plugins/zeroExport/powermeter.h index f6053d8c..780005bc 100644 --- a/src/plugins/zeroExport/powermeter.h +++ b/src/plugins/zeroExport/powermeter.h @@ -91,6 +91,11 @@ class powermeter { break; #endif #if defined(ZEROEXPORT_POWERMETER_TIBBER) + /* Anscheinend nutzt bei mir Tibber auch diese Freq. + 862.75 MHz - keine Verbindung + 863.00 MHz - geht (standard) jedoch hat Tibber dann Probleme... => 4 & 5 Balken + 863.25 MHz - geht (ohne Tibber Probleme) => 3 & 4 Balken + */ case zeroExportPowermeterType_t::Tibber: result = getPowermeterWattsTibber(*mLog, group, &power); mPreviousTsp += 2000; // Zusätzliche Pause @@ -247,7 +252,7 @@ class powermeter { PubMqttType *mMqtt = nullptr; JsonObject *mLog; - unsigned long mPreviousTsp = 0; + unsigned long mPreviousTsp = millis(); float mPowermeterBuffer[ZEROEXPORT_MAX_GROUPS][5] = {0}; short mPowermeterBufferPos[ZEROEXPORT_MAX_GROUPS] = {0}; diff --git a/src/plugins/zeroExport/zeroExport.h b/src/plugins/zeroExport/zeroExport.h index d0c215ff..32091680 100644 --- a/src/plugins/zeroExport/zeroExport.h +++ b/src/plugins/zeroExport/zeroExport.h @@ -637,40 +637,28 @@ class ZeroExport { if (obj["path"] == "ctrl" && obj["cmd"] == "zero") { int8_t topicGroup = getGroupFromTopic(topic.c_str()); - if (topicGroup != -1) - mLog["g"] = topicGroup; int8_t topicInverter = getInverterFromTopic(topic.c_str()); - if (topicInverter == -1) - mLog["i"] = topicInverter; + + if (topicGroup != -1) mLog["g"] = topicGroup; + if (topicInverter == -1) mLog["i"] = topicInverter; + + mLog["k"] = topic; // "topic":"ctrl/zero/enabled" - if (topic.indexOf("ctrl/zero/enabled") != -1) { - mCfg->enabled = (bool)obj["val"]; - mLog["k"] = "ctrl/zero/enabled"; - mLog["v"] = mCfg->enabled; - } + if (topic.indexOf("ctrl/zero/enabled") != -1) mCfg->enabled = mLog["v"] = (bool)obj["val"]; // "topic":"ctrl/zero/sleep" - if (topic.indexOf("ctrl/zero/sleep") != -1) { - mCfg->sleep = (bool)obj["val"]; - mLog["k"] = "ctrl/zero/sleep"; - mLog["v"] = mCfg->sleep; - } + else if (topic.indexOf("ctrl/zero/sleep") != -1) mCfg->sleep = mLog["v"] = (bool)obj["val"]; + + else if ((topicGroup >= 0) && (topicGroup < ZEROEXPORT_MAX_GROUPS)) + { + String stopicGroup = String(topicGroup); - if ((topicGroup >= 0) && (topicGroup < ZEROEXPORT_MAX_GROUPS)) { // "topic":"ctrl/zero/groups/+/enabled" - if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/enabled") != -1) { - mCfg->groups[topicGroup].enabled = (bool)obj["val"]; - mLog["k"] = "ctrl/zero/groups/" + String(topicGroup) + "/enabled"; - mLog["v"] = mCfg->groups[topicGroup].enabled; - } + if (topic.endsWith("/enabled")) mCfg->groups[topicGroup].enabled = mLog["v"] = (bool)obj["val"]; // "topic":"ctrl/zero/groups/+/sleep" - if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/sleep") != -1) { - mCfg->groups[topicGroup].sleep = (bool)obj["val"]; - mLog["k"] = "ctrl/zero/groups/" + String(topicGroup) + "/sleep"; - mLog["v"] = mCfg->groups[topicGroup].sleep; - } + else if (topic.endsWith("/sleep")) mCfg->groups[topicGroup].sleep = mLog["v"] = (bool)obj["val"]; // Auf Eis gelegt, dafür 2 Gruppen mehr // 0.8.103008.2 @@ -695,55 +683,37 @@ class ZeroExport { // } // "topic":"ctrl/zero/groups/+/battery/switch" - if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/battery/switch") != -1) { - mCfg->groups[topicGroup].battSwitch = (bool)obj["val"]; - mLog["k"] = "ctrl/zero/groups/" + String(topicGroup) + "/battery/switch"; - mLog["v"] = mCfg->groups[topicGroup].battSwitch; - } + else if (topic.endsWith("/battery/switch")) mCfg->groups[topicGroup].battSwitch = mLog["v"] = (bool)obj["val"]; - // "topic":"ctrl/zero/groups/+/advanced/setPoint" - if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/advanced/setPoint") != -1) { - mCfg->groups[topicGroup].setPoint = (int16_t)obj["val"]; - mLog["k"] = "ctrl/zero/groups/" + String(topicGroup) + "/advanced/setPoint"; - mLog["v"] = mCfg->groups[topicGroup].setPoint; - } + else if (topic.indexOf("/advanced/") != -1) + { + // "topic":"ctrl/zero/groups/+/advanced/setPoint" + if (topic.endsWith("/setPoint")) mCfg->groups[topicGroup].setPoint = mLog["v"] = (int16_t)obj["val"]; - // "topic":"ctrl/zero/groups/+/advanced/powerTolerance" - if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/advanced/powerTolerance") != -1) { - mCfg->groups[topicGroup].powerTolerance = (uint8_t)obj["val"]; - mLog["k"] = "ctrl/zero/groups/" + String(topicGroup) + "/advanced/powerTolerance"; - mLog["v"] = mCfg->groups[topicGroup].powerTolerance; - } + // "topic":"ctrl/zero/groups/+/advanced/powerTolerance" + else if (topic.endsWith("/powerTolerance")) mCfg->groups[topicGroup].powerTolerance = mLog["v"] = (uint8_t)obj["val"]; - // "topic":"ctrl/zero/groups/+/advanced/powerMax" - if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/advanced/powerMax") != -1) { - mCfg->groups[topicGroup].powerMax = (uint16_t)obj["val"]; - mLog["k"] = "ctrl/zero/groups/" + String(topicGroup) + "/advanced/powerMax"; - mLog["v"] = mCfg->groups[topicGroup].powerMax; + // "topic":"ctrl/zero/groups/+/advanced/powerMax" + else if (topic.endsWith("/powerMax")) mCfg->groups[topicGroup].powerMax = mLog["v"] = (uint16_t)obj["val"]; } - - if ((topicInverter >= 0) && (topicInverter < ZEROEXPORT_GROUP_MAX_INVERTERS)) { - // "topic":"ctrl/zero/groups/+/inverter/+/enabled" - if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/inverter/" + String(topicInverter) + "/enabled") != -1) { - mCfg->groups[topicGroup].inverters[topicInverter].enabled = (bool)obj["val"]; - mLog["k"] = "ctrl/zero/groups/" + String(topicGroup) + "/inverter/" + String(topicInverter) + "/enabled"; - mLog["v"] = mCfg->groups[topicGroup].inverters[topicInverter].enabled; - } - - // "topic":"ctrl/zero/groups/+/inverter/+/powerMin" - if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/inverter/" + String(topicInverter) + "/powerMin") != -1) { - mCfg->groups[topicGroup].inverters[topicInverter].powerMin = (uint16_t)obj["val"]; - mLog["k"] = "ctrl/zero/groups/" + String(topicGroup) + "/inverter/" + String(topicInverter) + "/powerMin"; - mLog["v"] = mCfg->groups[topicGroup].inverters[topicInverter].powerMin; - } - - // "topic":"ctrl/zero/groups/+/inverter/+/powerMax" - if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/inverter/" + String(topicInverter) + "/powerMax") != -1) { - mCfg->groups[topicGroup].inverters[topicInverter].powerMax = (uint16_t)obj["val"]; - mLog["k"] = "ctrl/zero/groups/" + String(topicGroup) + "/inverter/" + String(topicInverter) + "/powerMax"; - mLog["v"] = mCfg->groups[topicGroup].inverters[topicInverter].powerMax; + else if (topic.indexOf("/inverter/") != -1) + { + if ((topicInverter >= 0) && (topicInverter < ZEROEXPORT_GROUP_MAX_INVERTERS)) + { + // "topic":"ctrl/zero/groups/+/inverter/+/enabled" + if (topic.endsWith("/enabled")) mCfg->groups[topicGroup].inverters[topicInverter].enabled = mLog["v"] = (bool)obj["val"]; + + // "topic":"ctrl/zero/groups/+/inverter/+/powerMin" + else if (topic.endsWith("/powerMin")) mCfg->groups[topicGroup].inverters[topicInverter].powerMin = mLog["v"] = (uint16_t)obj["val"]; + + // "topic":"ctrl/zero/groups/+/inverter/+/powerMax" + else if (topic.endsWith("/powerMax")) mCfg->groups[topicGroup].inverters[topicInverter].powerMax = mLog["v"] = (uint16_t)obj["val"]; + else mLog["k"] = "error"; } } + else { + mLog["k"] = "error"; + } } } @@ -791,6 +761,7 @@ class ZeroExport { while (*pGroupSection != '/' && digitsCopied < 2) strGroup[digitsCopied++] = *pGroupSection++; strGroup[digitsCopied] = '\0'; int8_t group = atoi(strGroup); + mLog["getGroupFromTopic"] = group; return group; }