Browse Source

0.8.910012-zero

pull/1521/head
Patrick Amrhein 7 months ago
parent
commit
93164e9ef1
  1. 2
      src/defines.h
  2. 124
      src/plugins/zeroExport/zeroExport.h

2
src/defines.h

@ -13,7 +13,7 @@
//------------------------------------- //-------------------------------------
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 8 #define VERSION_MINOR 8
#define VERSION_PATCH 910011 #define VERSION_PATCH 910012
//------------------------------------- //-------------------------------------
typedef struct { typedef struct {

124
src/plugins/zeroExport/zeroExport.h

@ -66,10 +66,6 @@ class ZeroExport {
switch (mCfg->groups[group].state) { switch (mCfg->groups[group].state) {
case zeroExportState::INIT: case zeroExportState::INIT:
if (groupInit(group)) sendLog(); if (groupInit(group)) sendLog();
//#if defined(ZEROEXPORT_DEV_POWERMETER)
//mCfg->groups[group].state = zeroExportState::WAITREFRESH;
//mCfg->groups[group].stateNext = zeroExportState::WAITREFRESH;
//#endif
break; break;
case zeroExportState::WAIT: case zeroExportState::WAIT:
if (groupWait(group)) sendLog(); if (groupWait(group)) sendLog();
@ -288,7 +284,7 @@ mCfg->groups[group].lastRefresh = millis();;
mLog["B"] = bTsp; mLog["B"] = bTsp;
// Wait 60s // Wait 60s
if (mCfg->groups[group].lastRun >= (bTsp - 60000UL)) { if (bTsp <= (mCfg->groups[group].lastRun + 60000UL)) {
return result; return result;
} }
@ -327,7 +323,7 @@ mCfg->groups[group].lastRefresh = millis();;
mLog["B"] = bTsp; mLog["B"] = bTsp;
// Wait Refreshtime // Wait Refreshtime
if (mCfg->groups[group].lastRefresh + (mCfg->groups[group].refresh * 1000UL) >= bTsp) { if (bTsp <= (mCfg->groups[group].lastRefresh + (mCfg->groups[group].refresh * 1000UL))) {
return result; return result;
} }
@ -339,6 +335,7 @@ mCfg->groups[group].lastRefresh = millis();;
#if defined(ZEROEXPORT_DEV_POWERMETER) #if defined(ZEROEXPORT_DEV_POWERMETER)
mCfg->groups[group].state = zeroExportState::GETPOWERMETER; mCfg->groups[group].state = zeroExportState::GETPOWERMETER;
mCfg->groups[group].stateNext = zeroExportState::GETPOWERMETER; mCfg->groups[group].stateNext = zeroExportState::GETPOWERMETER;
mLog["next"] = "WAITREFRESH";
#else #else
mCfg->groups[group].state = zeroExportState::GETINVERTERACKS; mCfg->groups[group].state = zeroExportState::GETINVERTERACKS;
mCfg->groups[group].stateNext = zeroExportState::GETINVERTERACKS; mCfg->groups[group].stateNext = zeroExportState::GETINVERTERACKS;
@ -364,9 +361,9 @@ mCfg->groups[group].stateNext = zeroExportState::GETPOWERMETER;
mLog["type"] = "groupGetInverterAcks"; mLog["type"] = "groupGetInverterAcks";
mLog["B"] = bTsp; mLog["B"] = bTsp;
// Wait 100ms // Wait 250ms
if (mCfg->groups[group].stateLast == zeroExportState::GETINVERTERACKS) { if (mCfg->groups[group].stateLast == zeroExportState::GETINVERTERACKS) {
if (mCfg->groups[group].lastRun >= (bTsp - 100UL)) { if (bTsp <= (mCfg->groups[group].lastRun + 250UL)) {
return doLog; return doLog;
} }
} }
@ -1347,13 +1344,13 @@ result = true;
bool getPowermeterWattsShelly(JsonObject logObj, uint8_t group) { bool getPowermeterWattsShelly(JsonObject logObj, uint8_t group) {
bool result = false; bool result = false;
logObj["mod"] = "getPowermeterWattsShelly";
mCfg->groups[group].pmPower = 0; mCfg->groups[group].pmPower = 0;
mCfg->groups[group].pmPowerL1 = 0; mCfg->groups[group].pmPowerL1 = 0;
mCfg->groups[group].pmPowerL2 = 0; mCfg->groups[group].pmPowerL2 = 0;
mCfg->groups[group].pmPowerL3 = 0; mCfg->groups[group].pmPowerL3 = 0;
long int bTsp = millis();
HTTPClient http; HTTPClient http;
http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS); http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
http.setUserAgent("Ahoy-Agent"); http.setUserAgent("Ahoy-Agent");
@ -1462,7 +1459,6 @@ result = true;
} }
http.end(); http.end();
long int eTsp = millis();
logObj["P"] = mCfg->groups[group].pmPower; logObj["P"] = mCfg->groups[group].pmPower;
logObj["P1"] = mCfg->groups[group].pmPowerL1; logObj["P1"] = mCfg->groups[group].pmPowerL1;
logObj["P2"] = mCfg->groups[group].pmPowerL2; logObj["P2"] = mCfg->groups[group].pmPowerL2;
@ -1475,8 +1471,16 @@ result = true;
* getPowermeterWattsTasmota * getPowermeterWattsTasmota
*/ */
bool getPowermeterWattsTasmota(JsonObject logObj, uint8_t group) { bool getPowermeterWattsTasmota(JsonObject logObj, uint8_t group) {
bool result = false;
logObj["mod"] = "getPowermeterWattsTasmota";
mCfg->groups[group].pmPower = 0;
mCfg->groups[group].pmPowerL1 = 0;
mCfg->groups[group].pmPowerL2 = 0;
mCfg->groups[group].pmPowerL3 = 0;
// TODO: nicht komplett // TODO: nicht komplett
bool ret = false;
HTTPClient http; HTTPClient http;
http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS); http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
@ -1497,11 +1501,11 @@ result = true;
if (error) if (error)
{ {
logObj["error"] = "deserializeJson() failed: " + String(error.c_str()); logObj["error"] = "deserializeJson() failed: " + String(error.c_str());
return ret; return result;
} }
// TODO: Sum // TODO: Sum
ret = true; result = true;
// TODO: L1 // TODO: L1
@ -1528,64 +1532,100 @@ result = true;
} }
http.end(); http.end();
return ret; return result;
} }
/** /**
* getPowermeterWattsMqtt * getPowermeterWattsMqtt
*/ */
bool getPowermeterWattsMqtt(JsonObject logObj, uint8_t group) { bool getPowermeterWattsMqtt(JsonObject logObj, uint8_t group) {
// TODO: nicht komplett bool result = false;
bool ret = false;
logObj["mod"] = "getPowermeterWattsMqtt";
mCfg->groups[group].pmPower = 0;
mCfg->groups[group].pmPowerL1 = 0;
mCfg->groups[group].pmPowerL2 = 0;
mCfg->groups[group].pmPowerL3 = 0;
// Hier neuer Code - Anfang
// TODO: Noch nicht komplett
// logObj["P"] = mCfg->groups[group].pmPower; result = true;
// logObj["P1"] = mCfg->groups[group].pmPowerL1;
// logObj["P2"] = mCfg->groups[group].pmPowerL2;
// logObj["P3"] = mCfg->groups[group].pmPowerL3;
// } // Hier neuer Code - Ende
// http.end();
return ret; logObj["P"] = mCfg->groups[group].pmPower;
logObj["P1"] = mCfg->groups[group].pmPowerL1;
logObj["P2"] = mCfg->groups[group].pmPowerL2;
logObj["P3"] = mCfg->groups[group].pmPowerL3;
return result;
} }
/** /**
* getPowermeterWattsHichi * getPowermeterWattsHichi
*/ */
bool getPowermeterWattsHichi(JsonObject logObj, uint8_t group) { bool getPowermeterWattsHichi(JsonObject logObj, uint8_t group) {
// TODO: nicht komplett bool result = false;
bool ret = false;
logObj["mod"] = "getPowermeterWattsHichi";
mCfg->groups[group].pmPower = 0;
mCfg->groups[group].pmPowerL1 = 0;
mCfg->groups[group].pmPowerL2 = 0;
mCfg->groups[group].pmPowerL3 = 0;
// Hier neuer Code - Anfang
// TODO: Noch nicht komplett
result = true;
// logObj["P"] = mCfg->groups[group].pmPower;
// logObj["P1"] = mCfg->groups[group].pmPowerL1;
// logObj["P2"] = mCfg->groups[group].pmPowerL2;
// logObj["P3"] = mCfg->groups[group].pmPowerL3;
// }
// http.end();
return ret; // Hier neuer Code - Ende
logObj["P"] = mCfg->groups[group].pmPower;
logObj["P1"] = mCfg->groups[group].pmPowerL1;
logObj["P2"] = mCfg->groups[group].pmPowerL2;
logObj["P3"] = mCfg->groups[group].pmPowerL3;
return result;
} }
/** /**
* getPowermeterWattsTibber * getPowermeterWattsTibber
*/ */
bool getPowermeterWattsTibber(JsonObject logObj, uint8_t group) { bool getPowermeterWattsTibber(JsonObject logObj, uint8_t group) {
// TODO: nicht komplett bool result = false;
bool ret = false;
logObj["mod"] = "getPowermeterWattsTibber";
mCfg->groups[group].pmPower = 0;
mCfg->groups[group].pmPowerL1 = 0;
mCfg->groups[group].pmPowerL2 = 0;
mCfg->groups[group].pmPowerL3 = 0;
// Hier neuer Code - Anfang
// TODO: Noch nicht komplett
result = true;
// logObj["P"] = mCfg->groups[group].pmPower;
// logObj["P1"] = mCfg->groups[group].pmPowerL1;
// logObj["P2"] = mCfg->groups[group].pmPowerL2;
// logObj["P3"] = mCfg->groups[group].pmPowerL3;
// }
// http.end();
return ret;
// Hier neuer Code - Ende
logObj["P"] = mCfg->groups[group].pmPower;
logObj["P1"] = mCfg->groups[group].pmPowerL1;
logObj["P2"] = mCfg->groups[group].pmPowerL2;
logObj["P3"] = mCfg->groups[group].pmPowerL3;
return result;
} }
/* /*

Loading…
Cancel
Save