Browse Source

some notes for tibber problems & format zeroexport

pull/1638/head
DanielR92 8 months ago
parent
commit
05978a01f8
  1. 46
      src/platformio.ini
  2. 7
      src/plugins/zeroExport/powermeter.h
  3. 107
      src/plugins/zeroExport/zeroExport.h

46
src/platformio.ini

@ -40,7 +40,6 @@ build_flags =
build_unflags = build_unflags =
-std=gnu++11 -std=gnu++11
[env:esp8266-minimal] [env:esp8266-minimal]
platform = espressif8266 platform = espressif8266
board = esp12e board = esp12e
@ -148,7 +147,7 @@ monitor_filters =
esp8266_exception_decoder esp8266_exception_decoder
[env:esp32-wroom32-minimal] [env:esp32-wroom32-minimal]
platform = espressif32@6.5.0 platform = espressif32@6.6.0
board = lolin_d32 board = lolin_d32
build_flags = ${env.build_flags} build_flags = ${env.build_flags}
-DUSE_HSPI_FOR_EPD -DUSE_HSPI_FOR_EPD
@ -156,7 +155,7 @@ monitor_filters =
esp32_exception_decoder esp32_exception_decoder
[env:esp32-wroom32] [env:esp32-wroom32]
platform = espressif32@6.5.0 platform = espressif32@6.6.0
board = lolin_d32 board = lolin_d32
build_flags = ${env:esp32-wroom32-minimal.build_flags} build_flags = ${env:esp32-wroom32-minimal.build_flags}
-DENABLE_MQTT -DENABLE_MQTT
@ -167,7 +166,7 @@ monitor_filters =
esp32_exception_decoder esp32_exception_decoder
[env:esp32-wroom32-de] [env:esp32-wroom32-de]
platform = espressif32@6.5.0 platform = espressif32@6.6.0
board = lolin_d32 board = lolin_d32
build_flags = ${env:esp32-wroom32.build_flags} build_flags = ${env:esp32-wroom32.build_flags}
-DLANG_DE -DLANG_DE
@ -175,7 +174,7 @@ monitor_filters =
esp32_exception_decoder esp32_exception_decoder
[env:esp32-wroom32-prometheus] [env:esp32-wroom32-prometheus]
platform = espressif32@6.5.0 platform = espressif32@6.6.0
board = lolin_d32 board = lolin_d32
build_flags = ${env:esp32-wroom32.build_flags} build_flags = ${env:esp32-wroom32.build_flags}
-DENABLE_PROMETHEUS_EP -DENABLE_PROMETHEUS_EP
@ -183,7 +182,7 @@ monitor_filters =
esp32_exception_decoder esp32_exception_decoder
[env:esp32-wroom32-prometheus-de] [env:esp32-wroom32-prometheus-de]
platform = espressif32@6.5.0 platform = espressif32@6.6.0
board = lolin_d32 board = lolin_d32
build_flags = ${env:esp32-wroom32-prometheus.build_flags} build_flags = ${env:esp32-wroom32-prometheus.build_flags}
-DLANG_DE -DLANG_DE
@ -219,7 +218,7 @@ monitor_filters =
esp32_exception_decoder esp32_exception_decoder
[env:esp32-s2-mini] [env:esp32-s2-mini]
platform = espressif32@6.5.0 platform = espressif32@6.6.0
board = lolin_s2_mini board = lolin_s2_mini
build_flags = ${env.build_flags} build_flags = ${env.build_flags}
-DUSE_HSPI_FOR_EPD -DUSE_HSPI_FOR_EPD
@ -242,7 +241,7 @@ monitor_filters =
esp32_exception_decoder esp32_exception_decoder
[env:esp32-s2-mini-de] [env:esp32-s2-mini-de]
platform = espressif32@6.5.0 platform = espressif32@6.6.0
board = lolin_s2_mini board = lolin_s2_mini
build_flags = ${env:esp32-s2-mini.build_flags} build_flags = ${env:esp32-s2-mini.build_flags}
-DLANG_DE -DLANG_DE
@ -250,7 +249,7 @@ monitor_filters =
esp32_exception_decoder esp32_exception_decoder
[env:esp32-c3-mini] [env:esp32-c3-mini]
platform = espressif32@6.5.0 platform = espressif32@6.6.0
board = lolin_c3_mini board = lolin_c3_mini
build_flags = ${env.build_flags} build_flags = ${env.build_flags}
-DUSE_HSPI_FOR_EPD -DUSE_HSPI_FOR_EPD
@ -273,7 +272,7 @@ monitor_filters =
esp32_exception_decoder esp32_exception_decoder
[env:esp32-c3-mini-de] [env:esp32-c3-mini-de]
platform = espressif32@6.5.0 platform = espressif32@6.6.0
board = lolin_c3_mini board = lolin_c3_mini
build_flags = ${env:esp32-c3-mini.build_flags} build_flags = ${env:esp32-c3-mini.build_flags}
-DLANG_DE -DLANG_DE
@ -281,7 +280,7 @@ monitor_filters =
esp32_exception_decoder esp32_exception_decoder
[env:opendtufusion-minimal] [env:opendtufusion-minimal]
platform = espressif32@6.5.0 platform = espressif32@6.6.0
board = esp32-s3-devkitc-1 board = esp32-s3-devkitc-1
upload_protocol = esp-builtin upload_protocol = esp-builtin
build_flags = ${env.build_flags} build_flags = ${env.build_flags}
@ -306,19 +305,18 @@ monitor_filters =
esp32_exception_decoder, colorize esp32_exception_decoder, colorize
[env:opendtufusion] [env:opendtufusion]
platform = espressif32@6.5.0 platform = espressif32@6.6.0
board = esp32-s3-devkitc-1 board = esp32-s3-devkitc-1
upload_protocol = esp-builtin upload_protocol = esp-builtin
build_flags = ${env:opendtufusion-minimal.build_flags} build_flags = ${env:opendtufusion-minimal.build_flags}
-DENABLE_MQTT -DENABLE_MQTT
-DPLUGIN_DISPLAY -DPLUGIN_DISPLAY
-DENABLE_HISTORY -DENABLE_HISTORY
-DPLUGIN_ZEROEXPORT
monitor_filters = monitor_filters =
esp32_exception_decoder, colorize esp32_exception_decoder, colorize
[env:opendtufusion-de] [env:opendtufusion-de]
platform = espressif32@6.5.0 platform = espressif32@6.6.0
board = esp32-s3-devkitc-1 board = esp32-s3-devkitc-1
upload_protocol = esp-builtin upload_protocol = esp-builtin
build_flags = ${env:opendtufusion.build_flags} build_flags = ${env:opendtufusion.build_flags}
@ -326,8 +324,24 @@ build_flags = ${env:opendtufusion.build_flags}
monitor_filters = monitor_filters =
esp32_exception_decoder, colorize 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] [env:opendtufusion-ethernet]
platform = espressif32@6.5.0 platform = espressif32@6.6.0
board = esp32-s3-devkitc-1 board = esp32-s3-devkitc-1
upload_protocol = esp-builtin upload_protocol = esp-builtin
build_flags = ${env:opendtufusion-minimal.build_flags} build_flags = ${env:opendtufusion-minimal.build_flags}
@ -347,7 +361,7 @@ monitor_filters =
esp32_exception_decoder, colorize esp32_exception_decoder, colorize
[env:opendtufusion-ethernet-de] [env:opendtufusion-ethernet-de]
platform = espressif32@6.5.0 platform = espressif32@6.6.0
board = esp32-s3-devkitc-1 board = esp32-s3-devkitc-1
upload_protocol = esp-builtin upload_protocol = esp-builtin
build_flags = ${env:opendtufusion-ethernet.build_flags} build_flags = ${env:opendtufusion-ethernet.build_flags}

7
src/plugins/zeroExport/powermeter.h

@ -91,6 +91,11 @@ class powermeter {
break; break;
#endif #endif
#if defined(ZEROEXPORT_POWERMETER_TIBBER) #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: case zeroExportPowermeterType_t::Tibber:
result = getPowermeterWattsTibber(*mLog, group, &power); result = getPowermeterWattsTibber(*mLog, group, &power);
mPreviousTsp += 2000; // Zusätzliche Pause mPreviousTsp += 2000; // Zusätzliche Pause
@ -247,7 +252,7 @@ class powermeter {
PubMqttType *mMqtt = nullptr; PubMqttType *mMqtt = nullptr;
JsonObject *mLog; JsonObject *mLog;
unsigned long mPreviousTsp = 0; unsigned long mPreviousTsp = millis();
float mPowermeterBuffer[ZEROEXPORT_MAX_GROUPS][5] = {0}; float mPowermeterBuffer[ZEROEXPORT_MAX_GROUPS][5] = {0};
short mPowermeterBufferPos[ZEROEXPORT_MAX_GROUPS] = {0}; short mPowermeterBufferPos[ZEROEXPORT_MAX_GROUPS] = {0};

107
src/plugins/zeroExport/zeroExport.h

@ -637,40 +637,28 @@ class ZeroExport {
if (obj["path"] == "ctrl" && obj["cmd"] == "zero") { if (obj["path"] == "ctrl" && obj["cmd"] == "zero") {
int8_t topicGroup = getGroupFromTopic(topic.c_str()); int8_t topicGroup = getGroupFromTopic(topic.c_str());
if (topicGroup != -1)
mLog["g"] = topicGroup;
int8_t topicInverter = getInverterFromTopic(topic.c_str()); 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" // "topic":"ctrl/zero/enabled"
if (topic.indexOf("ctrl/zero/enabled") != -1) { if (topic.indexOf("ctrl/zero/enabled") != -1) mCfg->enabled = mLog["v"] = (bool)obj["val"];
mCfg->enabled = (bool)obj["val"];
mLog["k"] = "ctrl/zero/enabled";
mLog["v"] = mCfg->enabled;
}
// "topic":"ctrl/zero/sleep" // "topic":"ctrl/zero/sleep"
if (topic.indexOf("ctrl/zero/sleep") != -1) { else if (topic.indexOf("ctrl/zero/sleep") != -1) mCfg->sleep = mLog["v"] = (bool)obj["val"];
mCfg->sleep = (bool)obj["val"];
mLog["k"] = "ctrl/zero/sleep"; else if ((topicGroup >= 0) && (topicGroup < ZEROEXPORT_MAX_GROUPS))
mLog["v"] = mCfg->sleep; {
} String stopicGroup = String(topicGroup);
if ((topicGroup >= 0) && (topicGroup < ZEROEXPORT_MAX_GROUPS)) {
// "topic":"ctrl/zero/groups/+/enabled" // "topic":"ctrl/zero/groups/+/enabled"
if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/enabled") != -1) { if (topic.endsWith("/enabled")) mCfg->groups[topicGroup].enabled = mLog["v"] = (bool)obj["val"];
mCfg->groups[topicGroup].enabled = (bool)obj["val"];
mLog["k"] = "ctrl/zero/groups/" + String(topicGroup) + "/enabled";
mLog["v"] = mCfg->groups[topicGroup].enabled;
}
// "topic":"ctrl/zero/groups/+/sleep" // "topic":"ctrl/zero/groups/+/sleep"
if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/sleep") != -1) { else if (topic.endsWith("/sleep")) mCfg->groups[topicGroup].sleep = mLog["v"] = (bool)obj["val"];
mCfg->groups[topicGroup].sleep = (bool)obj["val"];
mLog["k"] = "ctrl/zero/groups/" + String(topicGroup) + "/sleep";
mLog["v"] = mCfg->groups[topicGroup].sleep;
}
// Auf Eis gelegt, dafür 2 Gruppen mehr // Auf Eis gelegt, dafür 2 Gruppen mehr
// 0.8.103008.2 // 0.8.103008.2
@ -695,55 +683,37 @@ class ZeroExport {
// } // }
// "topic":"ctrl/zero/groups/+/battery/switch" // "topic":"ctrl/zero/groups/+/battery/switch"
if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/battery/switch") != -1) { else if (topic.endsWith("/battery/switch")) mCfg->groups[topicGroup].battSwitch = mLog["v"] = (bool)obj["val"];
mCfg->groups[topicGroup].battSwitch = (bool)obj["val"];
mLog["k"] = "ctrl/zero/groups/" + String(topicGroup) + "/battery/switch";
mLog["v"] = mCfg->groups[topicGroup].battSwitch;
}
// "topic":"ctrl/zero/groups/+/advanced/setPoint" else if (topic.indexOf("/advanced/") != -1)
if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/advanced/setPoint") != -1) { {
mCfg->groups[topicGroup].setPoint = (int16_t)obj["val"]; // "topic":"ctrl/zero/groups/+/advanced/setPoint"
mLog["k"] = "ctrl/zero/groups/" + String(topicGroup) + "/advanced/setPoint"; if (topic.endsWith("/setPoint")) mCfg->groups[topicGroup].setPoint = mLog["v"] = (int16_t)obj["val"];
mLog["v"] = mCfg->groups[topicGroup].setPoint;
}
// "topic":"ctrl/zero/groups/+/advanced/powerTolerance" // "topic":"ctrl/zero/groups/+/advanced/powerTolerance"
if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/advanced/powerTolerance") != -1) { else if (topic.endsWith("/powerTolerance")) mCfg->groups[topicGroup].powerTolerance = mLog["v"] = (uint8_t)obj["val"];
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/powerMax" // "topic":"ctrl/zero/groups/+/advanced/powerMax"
if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/advanced/powerMax") != -1) { else if (topic.endsWith("/powerMax")) mCfg->groups[topicGroup].powerMax = mLog["v"] = (uint16_t)obj["val"];
mCfg->groups[topicGroup].powerMax = (uint16_t)obj["val"];
mLog["k"] = "ctrl/zero/groups/" + String(topicGroup) + "/advanced/powerMax";
mLog["v"] = mCfg->groups[topicGroup].powerMax;
} }
else if (topic.indexOf("/inverter/") != -1)
if ((topicInverter >= 0) && (topicInverter < ZEROEXPORT_GROUP_MAX_INVERTERS)) { {
// "topic":"ctrl/zero/groups/+/inverter/+/enabled" if ((topicInverter >= 0) && (topicInverter < ZEROEXPORT_GROUP_MAX_INVERTERS))
if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/inverter/" + String(topicInverter) + "/enabled") != -1) { {
mCfg->groups[topicGroup].inverters[topicInverter].enabled = (bool)obj["val"]; // "topic":"ctrl/zero/groups/+/inverter/+/enabled"
mLog["k"] = "ctrl/zero/groups/" + String(topicGroup) + "/inverter/" + String(topicInverter) + "/enabled"; if (topic.endsWith("/enabled")) mCfg->groups[topicGroup].inverters[topicInverter].enabled = mLog["v"] = (bool)obj["val"];
mLog["v"] = mCfg->groups[topicGroup].inverters[topicInverter].enabled;
} // "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/+/powerMin"
if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/inverter/" + String(topicInverter) + "/powerMin") != -1) { // "topic":"ctrl/zero/groups/+/inverter/+/powerMax"
mCfg->groups[topicGroup].inverters[topicInverter].powerMin = (uint16_t)obj["val"]; else if (topic.endsWith("/powerMax")) mCfg->groups[topicGroup].inverters[topicInverter].powerMax = mLog["v"] = (uint16_t)obj["val"];
mLog["k"] = "ctrl/zero/groups/" + String(topicGroup) + "/inverter/" + String(topicInverter) + "/powerMin"; else mLog["k"] = "error";
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 {
mLog["k"] = "error";
}
} }
} }
@ -791,6 +761,7 @@ class ZeroExport {
while (*pGroupSection != '/' && digitsCopied < 2) strGroup[digitsCopied++] = *pGroupSection++; while (*pGroupSection != '/' && digitsCopied < 2) strGroup[digitsCopied++] = *pGroupSection++;
strGroup[digitsCopied] = '\0'; strGroup[digitsCopied] = '\0';
int8_t group = atoi(strGroup); int8_t group = atoi(strGroup);
mLog["getGroupFromTopic"] = group;
return group; return group;
} }

Loading…
Cancel
Save