Browse Source

Update zeroExport.h

Add mqttObj and remove some hints
pull/1581/head
DanielR92 10 months ago
committed by GitHub
parent
commit
dd79bd4d0d
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 34
      src/plugins/zeroExport/zeroExport.h

34
src/plugins/zeroExport/zeroExport.h

@ -68,14 +68,14 @@ class ZeroExport {
if ((!mIsInitialized) || (!mCfg->enabled)) return; if ((!mIsInitialized) || (!mCfg->enabled)) return;
bool DoLog = false; // false state ? bool DoLog = false;
unsigned long Tsp = millis(); unsigned long Tsp = millis();
mPowermeter.loop(&Tsp, &DoLog); mPowermeter.loop(&Tsp, &DoLog);
if (DoLog) sendLog(); if (DoLog) sendLog();
clearLog(); clearLog();
DoLog = false; // here again?? DoLog = false;
for (uint8_t group = 0; group < ZEROEXPORT_MAX_GROUPS; group++) { for (uint8_t group = 0; group < ZEROEXPORT_MAX_GROUPS; group++) {
zeroExportGroup_t *cfgGroup = &mCfg->groups[group]; zeroExportGroup_t *cfgGroup = &mCfg->groups[group];
@ -264,8 +264,10 @@ class ZeroExport {
if (!mIsInitialized) return; if (!mIsInitialized) return;
// Select all Inverter to reboot // Select all Inverter to reboot
for (uint8_t inv = 0; inv < ZEROEXPORT_GROUP_MAX_INVERTERS; inv++) { // shutdown for clean start environment
//@Todo: move to ahoy!
for (uint8_t group = 0; group < ZEROEXPORT_MAX_GROUPS; group++) { for (uint8_t group = 0; group < ZEROEXPORT_MAX_GROUPS; group++) {
for (uint8_t inv = 0; inv < ZEROEXPORT_GROUP_MAX_INVERTERS; inv++) {
mCfg->groups[group].inverters[inv].doReboot = 1; mCfg->groups[group].inverters[inv].doReboot = 1;
} }
} }
@ -552,7 +554,7 @@ class ZeroExport {
{ {
mLog["mqttDevice"] = "topicInverter"; mLog["mqttDevice"] = "topicInverter";
if(!topic.equals(mCfg->groups[group].pm_jsonPath)) return; if(!topic.equals(mCfg->groups[group].pm_jsonPath)) return;
mCfg->groups[group].power = (int32_t)obj["val"]; mCfg->groups[group].pm_P = (int32_t)obj["val"];
} }
} }
@ -808,6 +810,14 @@ class ZeroExport {
*doLog = true; *doLog = true;
} }
} }
// Battery
String gr = "zero/state/groups/" + String(group) + "/battery";
mqttObj["enabled"] = cfgGroup->battEnabled;
mqttObj["voltageOn"] = cfgGroup->battVoltageOn;
mqttObj["voltageOff"] = cfgGroup->battVoltageOff;
mqttObj["switch"] = cfgGroup->battSwitch;
mqttPublish(gr.c_str(), mqttDoc.as<std::string>().c_str());
mqttDoc.clear();
} else { } else {
mLog["en"] = false; mLog["en"] = false;
@ -1017,6 +1027,18 @@ class ZeroExport {
return false; return false;
} }
// Advanced
String gr = "zero/state/groups/" + String(group) + "/advanced";
mqttObj["setPoint"] = cfgGroup->setPoint;
mqttObj["refresh"] = cfgGroup->refresh;
mqttObj["powerTolerance"] = cfgGroup->powerTolerance;
mqttObj["powerMax"] = cfgGroup->powerMax;
mqttObj["Kp"] = cfgGroup->Kp;
mqttObj["Ki"] = cfgGroup->Ki;
mqttObj["Kd"] = cfgGroup->Kd;
mqttPublish(gr.c_str(), mqttDoc.as<std::string>().c_str());
mqttDoc.clear();
return true; return true;
} }
@ -1242,7 +1264,7 @@ class ZeroExport {
if ((cfgGroupInv->doReboot == 2) && (cfgGroupInv->waitAckSetReboot == 0)) { if ((cfgGroupInv->doReboot == 2) && (cfgGroupInv->waitAckSetReboot == 0)) {
cfgGroupInv->doReboot = -1; cfgGroupInv->doReboot = -1;
if (mCfg->debug) { if (mCfg->debug) {
logObj["act"] = "nothing to do"; logObj["act"] = "done";
*doLog = true; *doLog = true;
} }
continue; continue;
@ -1518,7 +1540,7 @@ class ZeroExport {
mApi->ctrlRequest(obj); mApi->ctrlRequest(obj);
// publish to mqtt when mqtt // publish to mqtt when mqtt
if(mMqtt->isConnected()) //@TODO: check if isConnected the correct way, or better bool from settings? if(mMqtt->isConnected())
{ {
String gr = "zero/state/groups/" + String(group) + "/inverters/" + String(inv); String gr = "zero/state/groups/" + String(group) + "/inverters/" + String(inv);
mqttObj["enabled"] = cfgGroupInv->enabled; mqttObj["enabled"] = cfgGroupInv->enabled;

Loading…
Cancel
Save