diff --git a/.github/workflows/compile_zero-export.yml b/.github/workflows/compile_zero-export.yml index 1c552ce1..998c8519 100644 --- a/.github/workflows/compile_zero-export.yml +++ b/.github/workflows/compile_zero-export.yml @@ -202,15 +202,15 @@ jobs: with: name: zero-* - - name: Deploy - uses: nogsantos/scp-deploy@master - with: - src: ${{ steps.version_name.outputs.name }}/ - host: ${{ secrets.FW_SSH_HOST }} - remote: ${{ secrets.FW_SSH_DIR }}/zero - port: ${{ secrets.FW_SSH_PORT }} - user: ${{ secrets.FW_SSH_USER }} - key: ${{ secrets.FW_SSH_KEY }} + #- name: Deploy + # uses: nogsantos/scp-deploy@master + # with: + # src: ${{ steps.version_name.outputs.name }}/ + # host: ${{ secrets.FW_SSH_HOST }} + # remote: ${{ secrets.FW_SSH_DIR }}/zero + # port: ${{ secrets.FW_SSH_PORT }} + # user: ${{ secrets.FW_SSH_USER }} + # key: ${{ secrets.FW_SSH_KEY }} - name: Clean elf files (7z compressed) for Artifact run: | diff --git a/src/defines.h b/src/defines.h index 24e1a30e..0cd711cf 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 8 -#define VERSION_PATCH 1230002 +#define VERSION_PATCH 1230003 //------------------------------------- typedef struct { uint8_t ch; diff --git a/src/plugins/zeroExport/powermeter.h b/src/plugins/zeroExport/powermeter.h index d590aae1..a3880e4b 100644 --- a/src/plugins/zeroExport/powermeter.h +++ b/src/plugins/zeroExport/powermeter.h @@ -219,23 +219,18 @@ 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) -// DynamicJsonDocument datajson(100); -// if (!deserializeJson(datajson, obj["val"])) -// { -// switch (mCfg->groups[group].pm_target) { -// case 0: power = datajson["a_act_power"]; break; -// case 1: power = datajson["b_act_power"]; break; -// case 2: power = datajson["c_act_power"]; break; -// case 3: power = datajson["total_act_power"]; break; -// } -// } else { -// //TODO: check if parse is possible here? Is that right? + DynamicJsonDocument datajson(512); + if (!deserializeJson(datajson, obj["val"])) + { + switch (mCfg->groups[group].pm_target) { + case 0: power = datajson["a_act_power"]; break; + case 1: power = datajson["b_act_power"]; break; + case 2: power = datajson["c_act_power"]; break; + case 3: power = datajson["total_act_power"]; break; + } + } else { power = (float)obj["val"]; -// } + } bufferWrite(power, group); mCfg->groups[group].power = power; // TODO: join two sites together (PM & MQTT) diff --git a/src/plugins/zeroExport/zeroExport.h b/src/plugins/zeroExport/zeroExport.h index fa5ce459..b522212a 100644 --- a/src/plugins/zeroExport/zeroExport.h +++ b/src/plugins/zeroExport/zeroExport.h @@ -14,7 +14,6 @@ #include "AsyncJson.h" #include "powermeter.h" - #include "utils/DynamicJsonHandler.h" template @@ -24,7 +23,7 @@ class ZeroExport { /** ZeroExport * constructor */ - ZeroExport() { } + ZeroExport() {} /** ~ZeroExport * destructor @@ -52,7 +51,6 @@ class ZeroExport { mIsInitialized = mPowermeter.setup(mApp, mCfg, mqtt, &_log); } - /*void printJson() { serializeJson(doc, Serial); Serial.println(); @@ -91,19 +89,18 @@ class ZeroExport { zeroExportGroup_t *CfgGroup = &mCfg->groups[group]; zeroExportGroupInverter_t *CfgGroupInv = &CfgGroup->inverters[inv]; Inverter<> *iv = mSys->getInverterByPos(Queue.id); - if(NULL == iv) return; + if (NULL == iv) return; - if(!CfgGroup->battSwitch && !CfgGroup->battSwitchInit) - { - if(!iv->alarmCnt) return; + if (!CfgGroup->battSwitch && !CfgGroup->battSwitchInit) { + if (!iv->alarmCnt) return; bool stb_flag = false; - for(int16_t i = 0; i < iv->alarmCnt; i++) { - if(iv->lastAlarm[i].code == 124) { + for (int16_t i = 0; i < iv->alarmCnt; i++) { + if (iv->lastAlarm[i].code == 124) { stb_flag = true; _log.addProperty("alarm1", stb_flag); - _log.addProperty("start", iv->lastAlarm[i].start ); - _log.addProperty("end", iv->lastAlarm[i].end ); + _log.addProperty("start", iv->lastAlarm[i].start); + _log.addProperty("end", iv->lastAlarm[i].end); if (iv->lastAlarm[i].end > iv->lastAlarm[i].start) { stb_flag = false; @@ -113,7 +110,7 @@ class ZeroExport { clearLog(); } } - if(!stb_flag) CfgGroup->battSwitch = true; + if (!stb_flag) CfgGroup->battSwitch = true; CfgGroup->battSwitchInit = true; } @@ -144,15 +141,14 @@ class ZeroExport { uint16_t groupPower = 0; uint16_t groupLimit = 0; for (uint8_t inv = 0; inv < ZEROEXPORT_GROUP_MAX_INVERTERS; inv++) { - groupPower += mCfg->groups[group].inverters[inv].power; // Calc Data->groupPower - groupLimit += mCfg->groups[group].inverters[inv].limit; // Calc Data->groupLimit + groupPower += mCfg->groups[group].inverters[inv].power; // Calc Data->groupPower + groupLimit += mCfg->groups[group].inverters[inv].limit; // Calc Data->groupLimit } _log.addProperty("gP", groupPower); _log.addProperty("gL", groupLimit); // Wird nur zum debuggen benötigt? - // Batteryprotection _log.addProperty("bEn", (uint8_t)CfgGroup->battCfg); @@ -172,10 +168,10 @@ class ZeroExport { CfgGroup->battSwitch = true; _log.addProperty("bA", "turn on"); } - //if ((CfgGroup->battValue > CfgGroup->battLimitOff) && (CfgGroupInv->power > 0)) { - // CfgGroup->battSwitch = true; - // _log.addProperty("bA", "turn on"); - //} + // if ((CfgGroup->battValue > CfgGroup->battLimitOff) && (CfgGroupInv->power > 0)) { + // CfgGroup->battSwitch = true; + // _log.addProperty("bA", "turn on"); + // } } else { if (CfgGroup->battValue < CfgGroup->battLimitOff) { CfgGroup->battSwitch = false; @@ -649,7 +645,7 @@ class ZeroExport { mPowermeter.onMqttConnect(); - // "topic":"userdefined battSoCTopic" + // "topic":"userdefined battSoCTopic" oder "userdefinedUTopic" for (uint8_t group = 0; group < ZEROEXPORT_MAX_GROUPS; group++) { if (!mCfg->groups[group].enabled) continue; @@ -673,7 +669,7 @@ class ZeroExport { String topic = String(obj["topic"]); - // "topic":"userdefined battSoCTopic" + // "topic":"userdefined battSoCTopic" oder "userdefinedUTopic" for (uint8_t group = 0; group < ZEROEXPORT_MAX_GROUPS; group++) { if (!mCfg->groups[group].enabled) continue; @@ -684,7 +680,6 @@ class ZeroExport { if (strcmp(mCfg->groups[group].battTopic, String(topic).c_str())) { mCfg->groups[group].battValue = (bool)obj["val"]; - _log.addProperty("k", mCfg->groups[group].battTopic); _log.addProperty("v", mCfg->groups[group].battValue); } @@ -693,7 +688,6 @@ class ZeroExport { // "topic":"ctrl/zero" if (topic.indexOf("ctrl/zero") == -1) return; - _log.addProperty("d", obj); if (obj["path"] == "ctrl" && obj["cmd"] == "zero") { @@ -721,8 +715,7 @@ class ZeroExport { mCfg->sleep = (bool)obj["val"]; } - else if ((topicGroup >= 0) && (topicGroup < ZEROEXPORT_MAX_GROUPS)) - { + else if ((topicGroup >= 0) && (topicGroup < ZEROEXPORT_MAX_GROUPS)) { String stopicGroup = String(topicGroup); // "topic":"ctrl/zero/groups/+/enabled" @@ -765,8 +758,7 @@ class ZeroExport { mCfg->groups[topicGroup].battSwitch = (bool)obj["val"]; } - else if (topic.indexOf("/advanced/") != -1) - { + else if (topic.indexOf("/advanced/") != -1) { // "topic":"ctrl/zero/groups/+/advanced/setPoint" if (topic.endsWith("/setPoint")) { _log.addProperty("v", (int16_t)obj["val"]); @@ -780,15 +772,12 @@ class ZeroExport { } // "topic":"ctrl/zero/groups/+/advanced/powerMax" - else if (topic.endsWith("/powerMax")) { + else if (topic.endsWith("/powerMax")) { _log.addProperty("v", (uint16_t)obj["val"]); mCfg->groups[topicGroup].powerMax = (uint16_t)obj["val"]; } - } - else if (topic.indexOf("/inverter/") != -1) - { - if ((topicInverter >= 0) && (topicInverter < ZEROEXPORT_GROUP_MAX_INVERTERS)) - { + } else if (topic.indexOf("/inverter/") != -1) { + if ((topicInverter >= 0) && (topicInverter < ZEROEXPORT_GROUP_MAX_INVERTERS)) { // "topic":"ctrl/zero/groups/+/inverter/+/enabled" if (topic.endsWith("/enabled")) { _log.addProperty("v", (bool)obj["val"]); @@ -804,14 +793,11 @@ class ZeroExport { else if (topic.endsWith("/powerMax")) { _log.addProperty("v", (uint16_t)obj["val"]); mCfg->groups[topicGroup].inverters[topicInverter].powerMax = (uint16_t)obj["val"]; - } - else - { + } else { _log.addProperty("k", "error"); } } - } - else { + } else { _log.addProperty("k", "error"); } }