|
@ -26,13 +26,6 @@ typedef struct { |
|
|
} OBISHandler; |
|
|
} OBISHandler; |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
typedef struct { |
|
|
|
|
|
float P; |
|
|
|
|
|
float P1; |
|
|
|
|
|
float P2; |
|
|
|
|
|
float P3; |
|
|
|
|
|
} PowermeterBuffer_t; |
|
|
|
|
|
|
|
|
|
|
|
class powermeter { |
|
|
class powermeter { |
|
|
public: |
|
|
public: |
|
|
/** powermeter
|
|
|
/** powermeter
|
|
@ -70,7 +63,8 @@ class powermeter { |
|
|
if (millis() - mPreviousTsp <= 1000) return; // skip when it is to fast
|
|
|
if (millis() - mPreviousTsp <= 1000) return; // skip when it is to fast
|
|
|
mPreviousTsp = millis(); |
|
|
mPreviousTsp = millis(); |
|
|
|
|
|
|
|
|
PowermeterBuffer_t power; |
|
|
bool result = false; |
|
|
|
|
|
float power = 0.0; |
|
|
|
|
|
|
|
|
for (u_short group = 0; group < ZEROEXPORT_MAX_GROUPS; group++) { |
|
|
for (u_short group = 0; group < ZEROEXPORT_MAX_GROUPS; group++) { |
|
|
if ((!mCfg->groups[group].enabled) || (mCfg->groups[group].sleep)) continue; |
|
|
if ((!mCfg->groups[group].enabled) || (mCfg->groups[group].sleep)) continue; |
|
@ -81,50 +75,43 @@ class powermeter { |
|
|
switch (mCfg->groups[group].pm_type) { |
|
|
switch (mCfg->groups[group].pm_type) { |
|
|
#if defined(ZEROEXPORT_POWERMETER_SHELLY) |
|
|
#if defined(ZEROEXPORT_POWERMETER_SHELLY) |
|
|
case zeroExportPowermeterType_t::Shelly: |
|
|
case zeroExportPowermeterType_t::Shelly: |
|
|
power = getPowermeterWattsShelly(*mLog, group); |
|
|
result = getPowermeterWattsShelly(*mLog, group, &power); |
|
|
break; |
|
|
break; |
|
|
#endif |
|
|
#endif |
|
|
#if defined(ZEROEXPORT_POWERMETER_TASMOTA) |
|
|
#if defined(ZEROEXPORT_POWERMETER_TASMOTA) |
|
|
case zeroExportPowermeterType_t::Tasmota: |
|
|
case zeroExportPowermeterType_t::Tasmota: |
|
|
power = getPowermeterWattsTasmota(*mLog, group); |
|
|
result = getPowermeterWattsTasmota(*mLog, group, &power); |
|
|
break; |
|
|
|
|
|
#endif |
|
|
|
|
|
#if defined(ZEROEXPORT_POWERMETER_MQTT) |
|
|
|
|
|
case zeroExportPowermeterType_t::Mqtt: |
|
|
|
|
|
/// power = getPowermeterWattsMqtt(*mLog, group);
|
|
|
|
|
|
continue; |
|
|
|
|
|
break; |
|
|
break; |
|
|
#endif |
|
|
#endif |
|
|
#if defined(ZEROEXPORT_POWERMETER_HICHI) |
|
|
#if defined(ZEROEXPORT_POWERMETER_HICHI) |
|
|
case zeroExportPowermeterType_t::Hichi: |
|
|
case zeroExportPowermeterType_t::Hichi: |
|
|
power = getPowermeterWattsHichi(*mLog, group); |
|
|
result = getPowermeterWattsHichi(*mLog, group, &power); |
|
|
break; |
|
|
break; |
|
|
#endif |
|
|
#endif |
|
|
#if defined(ZEROEXPORT_POWERMETER_TIBBER) |
|
|
#if defined(ZEROEXPORT_POWERMETER_TIBBER) |
|
|
case zeroExportPowermeterType_t::Tibber: |
|
|
case zeroExportPowermeterType_t::Tibber: |
|
|
power = getPowermeterWattsTibber(*mLog, group); |
|
|
result = getPowermeterWattsTibber(*mLog, group, &power); |
|
|
mPreviousTsp += 2000; // Zusätzliche Pause
|
|
|
mPreviousTsp += 2000; // Zusätzliche Pause
|
|
|
break; |
|
|
break; |
|
|
#endif |
|
|
#endif |
|
|
#if defined(ZEROEXPORT_POWERMETER_SHRDZM) |
|
|
#if defined(ZEROEXPORT_POWERMETER_SHRDZM) |
|
|
case zeroExportPowermeterType_t::Shrdzm: |
|
|
case zeroExportPowermeterType_t::Shrdzm: |
|
|
power = getPowermeterWattsShrdzm(*mLog, group); |
|
|
result = getPowermeterWattsShrdzm(*mLog, group, &power); |
|
|
break; |
|
|
break; |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ((power.P == 0) and (power.P1 == 0) && (power.P2 == 0) && (power.P3 == 0)) return; |
|
|
if (result) { |
|
|
|
|
|
|
|
|
bufferWrite(power, group); |
|
|
bufferWrite(power, group); |
|
|
|
|
|
|
|
|
// MQTT - Powermeter
|
|
|
// MQTT - Powermeter
|
|
|
if (mCfg->debug) { |
|
|
if (mCfg->debug) { |
|
|
if (mMqtt->isConnected()) { |
|
|
if (mMqtt->isConnected()) { |
|
|
// P
|
|
|
// P
|
|
|
mqttObj["Sum"] = ah::round1(power.P); |
|
|
mqttObj["Sum"] = ah::round1(power); |
|
|
mqttObj["L1"] = ah::round1(power.P1); |
|
|
// mqttObj["L1"] = ah::round1(power.P1);
|
|
|
mqttObj["L2"] = ah::round1(power.P2); |
|
|
// mqttObj["L2"] = ah::round1(power.P2);
|
|
|
mqttObj["L3"] = ah::round1(power.P3); |
|
|
// mqttObj["L3"] = ah::round1(power.P3);
|
|
|
mMqtt->publish(String("zero/state/groups/" + String(group) + "/powermeter/P").c_str(), mqttDoc.as<std::string>().c_str(), false); |
|
|
mMqtt->publish(String("zero/state/groups/" + String(group) + "/powermeter/P").c_str(), mqttDoc.as<std::string>().c_str(), false); |
|
|
mqttDoc.clear(); |
|
|
mqttDoc.clear(); |
|
|
|
|
|
|
|
@ -133,30 +120,40 @@ class powermeter { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** groupGetPowermeter
|
|
|
/** groupGetPowermeter
|
|
|
* Holt die Daten vom Powermeter |
|
|
* Holt die Daten vom Powermeter |
|
|
* @param group |
|
|
* @param group |
|
|
* @returns true/false |
|
|
* @returns true/false |
|
|
*/ |
|
|
*/ |
|
|
PowermeterBuffer_t getDataAVG(uint8_t group) { |
|
|
float getDataAVG(uint8_t group) { |
|
|
PowermeterBuffer_t avg; |
|
|
float avg = 0.0; |
|
|
avg.P = avg.P1 = avg.P2 = avg.P2 = avg.P3 = 0; |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 5; i++) { |
|
|
for (int i = 0; i < 5; i++) { |
|
|
avg.P += mPowermeterBuffer[group][i].P; |
|
|
avg += mPowermeterBuffer[group][i]; |
|
|
avg.P1 += mPowermeterBuffer[group][i].P1; |
|
|
|
|
|
avg.P2 += mPowermeterBuffer[group][i].P2; |
|
|
|
|
|
avg.P3 += mPowermeterBuffer[group][i].P3; |
|
|
|
|
|
} |
|
|
} |
|
|
avg.P = avg.P / 5; |
|
|
avg = avg / 5.0; |
|
|
avg.P1 = avg.P1 / 5; |
|
|
|
|
|
avg.P2 = avg.P2 / 5; |
|
|
|
|
|
avg.P3 = avg.P3 / 5; |
|
|
|
|
|
|
|
|
|
|
|
return avg; |
|
|
return avg; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** groupGetPowermeter
|
|
|
|
|
|
* Holt die Daten vom Powermeter |
|
|
|
|
|
* @param group |
|
|
|
|
|
* @returns true/false |
|
|
|
|
|
*/ |
|
|
|
|
|
float getDataMIN(uint8_t group) { |
|
|
|
|
|
float min = 0.0; |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 5; i++) { |
|
|
|
|
|
if (i == 0) min = mPowermeterBuffer[group][i]; |
|
|
|
|
|
if ( min > mPowermeterBuffer[group][i]) min = mPowermeterBuffer[group][i]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return min; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* |
|
|
* |
|
|
*/ |
|
|
*/ |
|
@ -193,11 +190,8 @@ class powermeter { |
|
|
|
|
|
|
|
|
if (strcmp(mCfg->groups[group].pm_jsonPath, String(topic).c_str())) continue; |
|
|
if (strcmp(mCfg->groups[group].pm_jsonPath, String(topic).c_str())) continue; |
|
|
|
|
|
|
|
|
PowermeterBuffer_t power; |
|
|
float power = 0.0; |
|
|
power.P = (uint16_t)obj["val"]; |
|
|
power = (uint16_t)obj["val"]; |
|
|
power.P1 = power.P2 = power.P3 = (uint16_t)obj["val"] / 3; |
|
|
|
|
|
|
|
|
|
|
|
if ((power.P == 0) and (power.P1 == 0) && (power.P2 == 0) && (power.P3 == 0)) return; |
|
|
|
|
|
|
|
|
|
|
|
bufferWrite(power, group); |
|
|
bufferWrite(power, group); |
|
|
|
|
|
|
|
@ -205,10 +199,10 @@ class powermeter { |
|
|
if (mCfg->debug) { |
|
|
if (mCfg->debug) { |
|
|
if (mMqtt->isConnected()) { |
|
|
if (mMqtt->isConnected()) { |
|
|
// P
|
|
|
// P
|
|
|
mqttObj["Sum"] = ah::round1(power.P); |
|
|
mqttObj["Sum"] = ah::round1(power); |
|
|
mqttObj["L1"] = ah::round1(power.P1); |
|
|
/// mqttObj["L1"] = ah::round1(power.P1);
|
|
|
mqttObj["L2"] = ah::round1(power.P2); |
|
|
/// mqttObj["L2"] = ah::round1(power.P2);
|
|
|
mqttObj["L3"] = ah::round1(power.P3); |
|
|
/// mqttObj["L3"] = ah::round1(power.P3);
|
|
|
mMqtt->publish(String("zero/state/groups/" + String(group) + "/powermeter/P").c_str(), mqttDoc.as<std::string>().c_str(), false); |
|
|
mMqtt->publish(String("zero/state/groups/" + String(group) + "/powermeter/P").c_str(), mqttDoc.as<std::string>().c_str(), false); |
|
|
mqttDoc.clear(); |
|
|
mqttDoc.clear(); |
|
|
|
|
|
|
|
@ -253,7 +247,7 @@ class powermeter { |
|
|
|
|
|
|
|
|
unsigned long mPreviousTsp = 0; |
|
|
unsigned long mPreviousTsp = 0; |
|
|
|
|
|
|
|
|
PowermeterBuffer_t 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}; |
|
|
|
|
|
|
|
|
StaticJsonDocument<512> mqttDoc; // DynamicJsonDocument mqttDoc(512);
|
|
|
StaticJsonDocument<512> mqttDoc; // DynamicJsonDocument mqttDoc(512);
|
|
@ -279,10 +273,7 @@ class powermeter { |
|
|
* @param group |
|
|
* @param group |
|
|
* @returns true/false |
|
|
* @returns true/false |
|
|
*/ |
|
|
*/ |
|
|
PowermeterBuffer_t getPowermeterWattsShelly(JsonObject logObj, uint8_t group) { |
|
|
bool getPowermeterWattsShelly(JsonObject logObj, uint8_t group, float *power) { |
|
|
PowermeterBuffer_t result; |
|
|
|
|
|
result.P = result.P1 = result.P2 = result.P3 = 0; |
|
|
|
|
|
|
|
|
|
|
|
logObj["mod"] = "getPowermeterWattsShelly"; |
|
|
logObj["mod"] = "getPowermeterWattsShelly"; |
|
|
|
|
|
|
|
|
setHeader(&http); |
|
|
setHeader(&http); |
|
@ -294,97 +285,69 @@ class powermeter { |
|
|
|
|
|
|
|
|
if (http.GET() == HTTP_CODE_OK) { |
|
|
if (http.GET() == HTTP_CODE_OK) { |
|
|
// Parsing
|
|
|
// Parsing
|
|
|
|
|
|
// http.getSize());
|
|
|
|
|
|
// TODO: Umstellen auf dynamische Größe
|
|
|
DynamicJsonDocument doc(2048); |
|
|
DynamicJsonDocument doc(2048); |
|
|
DeserializationError error = deserializeJson(doc, http.getString()); |
|
|
DeserializationError error = deserializeJson(doc, http.getString()); |
|
|
if (error) { |
|
|
if (error) { |
|
|
logObj["err"] = "deserializeJson: " + String(error.c_str()); |
|
|
logObj["err"] = "deserializeJson: " + String(error.c_str()); |
|
|
return result; |
|
|
return false; |
|
|
} else { |
|
|
} else { |
|
|
if (doc.containsKey(F("total_power"))) { |
|
|
switch (mCfg->groups[group].pm_target) { |
|
|
|
|
|
case zeroExportPowermeterTarget::L1: |
|
|
|
|
|
if (doc.containsKey(F("emeters"))) { |
|
|
// Shelly 3EM
|
|
|
// Shelly 3EM
|
|
|
result.P = doc["total_power"]; |
|
|
*power = doc["emeters"][0]["power"]; |
|
|
} else if (doc.containsKey(F("em:0"))) { |
|
|
} else if (doc.containsKey(F("em:0"))) { |
|
|
// Shelly pro 3EM
|
|
|
// Shelly pro 3EM
|
|
|
result.P = doc["em:0"]["total_act_power"]; |
|
|
*power = doc["em:0"]["a_act_power"]; |
|
|
} else if (doc.containsKey(F("total_act_power"))) { |
|
|
} else if (doc.containsKey(F("a_act_power"))) { |
|
|
// Shelly pro 3EM
|
|
|
// Shelly pro 3EM
|
|
|
result.P = doc["total_act_power"]; |
|
|
*power = doc["a_act_power"]; |
|
|
} else { |
|
|
|
|
|
// Keine Daten
|
|
|
|
|
|
result.P = 0; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case zeroExportPowermeterTarget::L2: |
|
|
if (doc.containsKey(F("emeters"))) { |
|
|
if (doc.containsKey(F("emeters"))) { |
|
|
// Shelly 3EM
|
|
|
// Shelly 3EM
|
|
|
result.P1 = doc["emeters"][0]["power"]; |
|
|
*power = doc["emeters"][1]["power"]; |
|
|
} else if (doc.containsKey(F("em:0"))) { |
|
|
} else if (doc.containsKey(F("em:0"))) { |
|
|
// Shelly pro 3EM
|
|
|
// Shelly pro 3EM
|
|
|
result.P1 = doc["em:0"]["a_act_power"]; |
|
|
*power = doc["em:0"]["b_act_power"]; |
|
|
} else if (doc.containsKey(F("a_act_power"))) { |
|
|
} else if (doc.containsKey(F("b_act_power"))) { |
|
|
// Shelly pro 3EM
|
|
|
// Shelly pro 3EM
|
|
|
result.P1 = doc["a_act_power"]; |
|
|
*power = doc["b_act_power"]; |
|
|
} else if (doc.containsKey(F("switch:0"))) { |
|
|
|
|
|
// Shelly plus1pm plus2pm
|
|
|
|
|
|
result.P1 = doc["switch:0"]["apower"]; |
|
|
|
|
|
result.P += result.P1; |
|
|
|
|
|
} else if (doc.containsKey(F("apower"))) { |
|
|
|
|
|
// Shelly Alternative
|
|
|
|
|
|
result.P1 = doc["apower"]; |
|
|
|
|
|
result.P += result.P1; |
|
|
|
|
|
} else { |
|
|
|
|
|
// Keine Daten
|
|
|
|
|
|
result.P1 = 0; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case zeroExportPowermeterTarget::L3: |
|
|
if (doc.containsKey(F("emeters"))) { |
|
|
if (doc.containsKey(F("emeters"))) { |
|
|
// Shelly 3EM
|
|
|
// Shelly 3EM
|
|
|
result.P2 = doc["emeters"][1]["power"]; |
|
|
*power = doc["emeters"][2]["power"]; |
|
|
} else if (doc.containsKey(F("em:0"))) { |
|
|
} else if (doc.containsKey(F("em:0"))) { |
|
|
// Shelly pro 3EM
|
|
|
// Shelly pro 3EM
|
|
|
result.P2 = doc["em:0"]["b_act_power"]; |
|
|
*power = doc["em:0"]["c_act_power"]; |
|
|
} else if (doc.containsKey(F("b_act_power"))) { |
|
|
} else if (doc.containsKey(F("c_act_power"))) { |
|
|
// Shelly pro 3EM
|
|
|
// Shelly pro 3EM
|
|
|
result.P2 = doc["b_act_power"]; |
|
|
*power = doc["c_act_power"]; |
|
|
} else if (doc.containsKey(F("switch:1"))) { |
|
|
|
|
|
// Shelly plus1pm plus2pm
|
|
|
|
|
|
result.P2 = doc["switch.1"]["apower"]; |
|
|
|
|
|
result.P += result.P2; |
|
|
|
|
|
//} else if (doc.containsKey(F("apower"))) {
|
|
|
|
|
|
// Shelly Alternative
|
|
|
|
|
|
// mCfg->groups[group].pmPowerL2 = doc["apower"];
|
|
|
|
|
|
// mCfg->groups[group].pmPower += mCfg->groups[group].pmPowerL2;
|
|
|
|
|
|
// ret = true;
|
|
|
|
|
|
} else { |
|
|
|
|
|
// Keine Daten
|
|
|
|
|
|
result.P2 = 0; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
break; |
|
|
if (doc.containsKey(F("emeters"))) { |
|
|
case zeroExportPowermeterTarget::Sum: |
|
|
|
|
|
default: |
|
|
|
|
|
if (doc.containsKey(F("total_power"))) { |
|
|
// Shelly 3EM
|
|
|
// Shelly 3EM
|
|
|
result.P3 = doc["emeters"][2]["power"]; |
|
|
*power = doc["total_power"]; |
|
|
} else if (doc.containsKey(F("em:0"))) { |
|
|
} else if (doc.containsKey(F("em:0"))) { |
|
|
// Shelly pro 3EM
|
|
|
// Shelly pro 3EM
|
|
|
result.P3 = doc["em:0"]["c_act_power"]; |
|
|
*power = doc["em:0"]["total_act_power"]; |
|
|
} else if (doc.containsKey(F("c_act_power"))) { |
|
|
} else if (doc.containsKey(F("total_act_power"))) { |
|
|
// Shelly pro 3EM
|
|
|
// Shelly pro 3EM
|
|
|
result.P3 = doc["c_act_power"]; |
|
|
*power = doc["total_act_power"]; |
|
|
} else if (doc.containsKey(F("switch:2"))) { |
|
|
} |
|
|
// Shelly plus1pm plus2pm
|
|
|
break; |
|
|
result.P3 = doc["switch:2"]["apower"]; |
|
|
|
|
|
result.P += result.P3; |
|
|
|
|
|
//} else if (doc.containsKey(F("apower"))) {
|
|
|
|
|
|
// Shelly Alternative
|
|
|
|
|
|
// mCfg->groups[group].pmPowerL3 = doc["apower"];
|
|
|
|
|
|
// mCfg->groups[group].pmPower += mCfg->groups[group].pmPowerL3;
|
|
|
|
|
|
// result = true;
|
|
|
|
|
|
} else { |
|
|
|
|
|
// Keine Daten
|
|
|
|
|
|
result.P3 = 0; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
http.end(); |
|
|
http.end(); |
|
|
return result; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
@ -395,10 +358,7 @@ class powermeter { |
|
|
* @param group |
|
|
* @param group |
|
|
* @returns true/false |
|
|
* @returns true/false |
|
|
*/ |
|
|
*/ |
|
|
PowermeterBuffer_t getPowermeterWattsTasmota(JsonObject logObj, uint8_t group) { |
|
|
bool getPowermeterWattsTasmota(JsonObject logObj, uint8_t group, float *power) { |
|
|
PowermeterBuffer_t result; |
|
|
|
|
|
result.P = result.P1 = result.P2 = result.P3 = 0; |
|
|
|
|
|
|
|
|
|
|
|
logObj["mod"] = "getPowermeterWattsTasmota"; |
|
|
logObj["mod"] = "getPowermeterWattsTasmota"; |
|
|
/*
|
|
|
/*
|
|
|
// TODO: nicht komplett
|
|
|
// TODO: nicht komplett
|
|
@ -459,31 +419,10 @@ class powermeter { |
|
|
} |
|
|
} |
|
|
http.end(); |
|
|
http.end(); |
|
|
*/ |
|
|
*/ |
|
|
return result; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
/// #if defined(ZEROEXPORT_POWERMETER_MQTT)
|
|
|
|
|
|
/// /** getPowermeterWattsMqtt
|
|
|
|
|
|
/// * ...
|
|
|
|
|
|
/// * @param logObj
|
|
|
|
|
|
/// * @param group
|
|
|
|
|
|
/// * @returns true/false
|
|
|
|
|
|
/// */
|
|
|
|
|
|
/// PowermeterBuffer_t getPowermeterWattsMqtt(JsonObject logObj, uint8_t group) {
|
|
|
|
|
|
/// PowermeterBuffer_t result;
|
|
|
|
|
|
/// result.P = result.P1 = result.P2 = result.P3 = 0;
|
|
|
|
|
|
///
|
|
|
|
|
|
/// logObj["mod"] = "getPowermeterWattsMqtt";
|
|
|
|
|
|
///
|
|
|
|
|
|
/// // topic for powermeter?
|
|
|
|
|
|
/// result.P = mCfg->groups[group].pm_P;
|
|
|
|
|
|
/// result.P1 = result.P2 = result.P3 = mCfg->groups[group].pm_P / 3;
|
|
|
|
|
|
///
|
|
|
|
|
|
/// return result;
|
|
|
|
|
|
/// }
|
|
|
|
|
|
/// #endif
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(ZEROEXPORT_POWERMETER_HICHI) |
|
|
#if defined(ZEROEXPORT_POWERMETER_HICHI) |
|
|
/** getPowermeterWattsHichi
|
|
|
/** getPowermeterWattsHichi
|
|
|
* ... |
|
|
* ... |
|
@ -491,10 +430,7 @@ class powermeter { |
|
|
* @param group |
|
|
* @param group |
|
|
* @returns true/false |
|
|
* @returns true/false |
|
|
*/ |
|
|
*/ |
|
|
PowermeterBuffer_t getPowermeterWattsHichi(JsonObject logObj, uint8_t group) { |
|
|
bool getPowermeterWattsHichi(JsonObject logObj, uint8_t group, float *power) { |
|
|
PowermeterBuffer_t result; |
|
|
|
|
|
result.P = result.P1 = result.P2 = result.P3 = 0; |
|
|
|
|
|
|
|
|
|
|
|
logObj["mod"] = "getPowermeterWattsHichi"; |
|
|
logObj["mod"] = "getPowermeterWattsHichi"; |
|
|
|
|
|
|
|
|
// Hier neuer Code - Anfang
|
|
|
// Hier neuer Code - Anfang
|
|
@ -503,7 +439,7 @@ class powermeter { |
|
|
|
|
|
|
|
|
// Hier neuer Code - Ende
|
|
|
// Hier neuer Code - Ende
|
|
|
|
|
|
|
|
|
return result; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
@ -545,11 +481,10 @@ class powermeter { |
|
|
{{0x01, 0x00, 0x01, 0x08, 0x00, 0xff}, &smlOBISWh, &_powerMeterImport}, |
|
|
{{0x01, 0x00, 0x01, 0x08, 0x00, 0xff}, &smlOBISWh, &_powerMeterImport}, |
|
|
{{0x01, 0x00, 0x02, 0x08, 0x00, 0xff}, &smlOBISWh, &_powerMeterExport}}; |
|
|
{{0x01, 0x00, 0x02, 0x08, 0x00, 0xff}, &smlOBISWh, &_powerMeterExport}}; |
|
|
|
|
|
|
|
|
PowermeterBuffer_t getPowermeterWattsTibber(JsonObject logObj, uint8_t group) { |
|
|
bool getPowermeterWattsTibber(JsonObject logObj, uint8_t group, float *power) { |
|
|
mPreviousTsp = mPreviousTsp + 2000; // Zusätzliche Pause
|
|
|
mPreviousTsp = mPreviousTsp + 2000; // Zusätzliche Pause
|
|
|
|
|
|
|
|
|
PowermeterBuffer_t result; |
|
|
bool result = false; |
|
|
result.P = result.P1 = result.P2 = result.P3 = 0; |
|
|
|
|
|
|
|
|
|
|
|
logObj["mod"] = "getPowermeterWattsTibber"; |
|
|
logObj["mod"] = "getPowermeterWattsTibber"; |
|
|
|
|
|
|
|
@ -580,14 +515,8 @@ class powermeter { |
|
|
|
|
|
|
|
|
switch (smlCurrentState) { |
|
|
switch (smlCurrentState) { |
|
|
case SML_FINAL: |
|
|
case SML_FINAL: |
|
|
result.P = _powerMeterTotal; |
|
|
*power = _powerMeterTotal; |
|
|
result.P1 = _powerMeter1Power; |
|
|
result = true; |
|
|
result.P2 = _powerMeter2Power; |
|
|
|
|
|
result.P3 = _powerMeter3Power; |
|
|
|
|
|
|
|
|
|
|
|
if (!(_powerMeter1Power && _powerMeter2Power && _powerMeter3Power)) { |
|
|
|
|
|
result.P1 = result.P2 = result.P3 = _powerMeterTotal / 3; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
break; |
|
|
case SML_LISTEND: |
|
|
case SML_LISTEND: |
|
|
// check handlers on last received list
|
|
|
// check handlers on last received list
|
|
@ -616,10 +545,7 @@ class powermeter { |
|
|
* @TODO: Username & Passwort wird mittels base64 verschlüsselt. Dies wird für die Authentizierung benötigt. Wichtig diese im WebUI unkenntlich zu machen und base64 im eeprom zu speichern, statt klartext. |
|
|
* @TODO: Username & Passwort wird mittels base64 verschlüsselt. Dies wird für die Authentizierung benötigt. Wichtig diese im WebUI unkenntlich zu machen und base64 im eeprom zu speichern, statt klartext. |
|
|
* @TODO: Abfrage Interval einbauen. Info: Datei-Size kann auch mal 0-bytes sein? |
|
|
* @TODO: Abfrage Interval einbauen. Info: Datei-Size kann auch mal 0-bytes sein? |
|
|
*/ |
|
|
*/ |
|
|
PowermeterBuffer_t getPowermeterWattsShrdzm(JsonObject logObj, uint8_t group) { |
|
|
bool getPowermeterWattsShrdzm(JsonObject logObj, uint8_t group, float *power) { |
|
|
PowermeterBuffer_t result; |
|
|
|
|
|
result.P = result.P1 = result.P2 = result.P3 = 0; |
|
|
|
|
|
|
|
|
|
|
|
logObj["mod"] = "getPowermeterWattsShrdzm"; |
|
|
logObj["mod"] = "getPowermeterWattsShrdzm"; |
|
|
|
|
|
|
|
|
setHeader(&http); |
|
|
setHeader(&http); |
|
@ -636,27 +562,23 @@ class powermeter { |
|
|
DeserializationError error = deserializeJson(doc, http.getString()); |
|
|
DeserializationError error = deserializeJson(doc, http.getString()); |
|
|
if (error) { |
|
|
if (error) { |
|
|
logObj["err"] = "deserializeJson: " + String(error.c_str()); |
|
|
logObj["err"] = "deserializeJson: " + String(error.c_str()); |
|
|
return result; |
|
|
return false; |
|
|
} else { |
|
|
} else { |
|
|
if (doc.containsKey(F("16.7.0"))) { |
|
|
if (doc.containsKey(F("16.7.0"))) { |
|
|
result.P = doc["16.7.0"]; |
|
|
*power = doc["16.7.0"]; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!(result.P1 && result.P2 && result.P3)) { |
|
|
|
|
|
result.P1 = result.P2 = result.P3 = result.P / 3; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
http.end(); |
|
|
http.end(); |
|
|
|
|
|
|
|
|
return result; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* |
|
|
* |
|
|
*/ |
|
|
*/ |
|
|
void bufferWrite(PowermeterBuffer_t raw, short group) { |
|
|
void bufferWrite(float raw, short group) { |
|
|
mPowermeterBuffer[group][mPowermeterBufferPos[group]] = raw; |
|
|
mPowermeterBuffer[group][mPowermeterBufferPos[group]] = raw; |
|
|
mPowermeterBufferPos[group]++; |
|
|
mPowermeterBufferPos[group]++; |
|
|
if (mPowermeterBufferPos[group] >= 5) mPowermeterBufferPos[group] = 0; |
|
|
if (mPowermeterBufferPos[group] >= 5) mPowermeterBufferPos[group] = 0; |
|
|