|
@ -68,48 +68,50 @@ class ZeroExport { |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool flag = false; |
|
|
|
|
|
|
|
|
switch (mCfg->groups[group].state) { |
|
|
switch (mCfg->groups[group].state) { |
|
|
case zeroExportState::INIT: |
|
|
case zeroExportState::INIT: |
|
|
if (groupInit(group)) sendLog(); |
|
|
flag = groupInit(group); |
|
|
break; |
|
|
break; |
|
|
case zeroExportState::WAIT: |
|
|
case zeroExportState::WAIT: |
|
|
if (groupWait(group)) sendLog(); |
|
|
flag = groupWait(group); |
|
|
break; |
|
|
break; |
|
|
case zeroExportState::PUBLISH: |
|
|
case zeroExportState::PUBLISH: |
|
|
if (groupPublish(group)) sendLog(); |
|
|
flag = groupPublish(group); |
|
|
break; |
|
|
break; |
|
|
case zeroExportState::WAITREFRESH: |
|
|
case zeroExportState::WAITREFRESH: |
|
|
if (groupWaitRefresh(group)) sendLog(); |
|
|
flag = groupWaitRefresh(group); |
|
|
break; |
|
|
break; |
|
|
case zeroExportState::GETINVERTERACKS: |
|
|
case zeroExportState::GETINVERTERACKS: |
|
|
if (groupGetInverterAcks(group)) sendLog(); |
|
|
flag = groupGetInverterAcks(group); |
|
|
break; |
|
|
break; |
|
|
case zeroExportState::GETINVERTERDATA: |
|
|
case zeroExportState::GETINVERTERDATA: |
|
|
if (groupGetInverterData(group)) sendLog(); |
|
|
flag = groupGetInverterData(group); |
|
|
break; |
|
|
break; |
|
|
case zeroExportState::BATTERYPROTECTION: |
|
|
case zeroExportState::BATTERYPROTECTION: |
|
|
if (groupBatteryprotection(group)) sendLog(); |
|
|
flag = groupBatteryprotection(group); |
|
|
break; |
|
|
break; |
|
|
case zeroExportState::GETPOWERMETER: |
|
|
case zeroExportState::GETPOWERMETER: |
|
|
if (groupGetPowermeter(group)) sendLog(); |
|
|
flag = groupGetPowermeter(group); |
|
|
break; |
|
|
break; |
|
|
case zeroExportState::CONTROLLER: |
|
|
case zeroExportState::CONTROLLER: |
|
|
if (groupController(group)) sendLog(); |
|
|
flag = groupController(group); |
|
|
break; |
|
|
break; |
|
|
case zeroExportState::PROGNOSE: |
|
|
case zeroExportState::PROGNOSE: |
|
|
if (groupPrognose(group)) sendLog(); |
|
|
flag = groupPrognose(group); |
|
|
break; |
|
|
break; |
|
|
case zeroExportState::AUFTEILEN: |
|
|
case zeroExportState::AUFTEILEN: |
|
|
if (groupAufteilen(group)) sendLog(); |
|
|
flag = groupAufteilen(group); |
|
|
break; |
|
|
break; |
|
|
case zeroExportState::SETLIMIT: |
|
|
case zeroExportState::SETLIMIT: |
|
|
if (groupSetLimit(group)) sendLog(); |
|
|
flag = groupSetLimit(group); |
|
|
break; |
|
|
break; |
|
|
case zeroExportState::SETPOWER: |
|
|
case zeroExportState::SETPOWER: |
|
|
if (groupSetPower(group)) sendLog(); |
|
|
flag = groupSetPower(group); |
|
|
break; |
|
|
break; |
|
|
case zeroExportState::SETREBOOT: |
|
|
case zeroExportState::SETREBOOT: |
|
|
if (groupSetReboot(group)) sendLog(); |
|
|
flag = groupSetReboot(group); |
|
|
break; |
|
|
break; |
|
|
case zeroExportState::FINISH: |
|
|
case zeroExportState::FINISH: |
|
|
case zeroExportState::ERROR: |
|
|
case zeroExportState::ERROR: |
|
@ -121,6 +123,8 @@ class ZeroExport { |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (flag) sendLog(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -292,13 +296,19 @@ class ZeroExport { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** onMqttMessage
|
|
|
/** onMqttMessage
|
|
|
* |
|
|
* Subscribe section |
|
|
*/ |
|
|
*/ |
|
|
void onMqttMessage(JsonObject obj) { |
|
|
void onMqttMessage(JsonObject obj) { |
|
|
if ((!mIsInitialized) || (!mCfg->enabled)) { |
|
|
if ((!mIsInitialized) || (!mCfg->enabled)) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// MQTT":{"val":0,"path":"zero","cmd":"set","id":0}
|
|
|
|
|
|
if (strcmp(obj["cmd"], "set") != 0 && strcmp(obj["path"], "zero") != 0) |
|
|
|
|
|
{ |
|
|
|
|
|
mCfg->enabled = (bool)obj["val"]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
mLog["MQTT"] = obj; |
|
|
mLog["MQTT"] = obj; |
|
|
sendLog(); |
|
|
sendLog(); |
|
|
} |
|
|
} |
|
@ -460,7 +470,7 @@ class ZeroExport { |
|
|
// mCfg->groups[group].publishPower = false;
|
|
|
// mCfg->groups[group].publishPower = false;
|
|
|
obj["L1"] = mCfg->groups[group].pmPowerL1; |
|
|
obj["L1"] = mCfg->groups[group].pmPowerL1; |
|
|
obj["L2"] = mCfg->groups[group].pmPowerL2; |
|
|
obj["L2"] = mCfg->groups[group].pmPowerL2; |
|
|
obj["L2"] = mCfg->groups[group].pmPowerL3; |
|
|
obj["L3"] = mCfg->groups[group].pmPowerL3; |
|
|
obj["Sum"] = mCfg->groups[group].pmPower; |
|
|
obj["Sum"] = mCfg->groups[group].pmPower; |
|
|
mMqtt->publish("zero/state/powermeter/P", doc.as<std::string>().c_str(), false); |
|
|
mMqtt->publish("zero/state/powermeter/P", doc.as<std::string>().c_str(), false); |
|
|
doc.clear(); |
|
|
doc.clear(); |
|
|