diff --git a/src/config/settings.h b/src/config/settings.h index 891a6555..70779662 100644 --- a/src/config/settings.h +++ b/src/config/settings.h @@ -271,7 +271,7 @@ typedef struct { float dcVoltage; bool state; // - bool doReboot; + int8_t doReboot; int8_t doPower; bool doLimit; } zeroExportGroupInverter_t; diff --git a/src/plugins/zeroExport/zeroExport.h b/src/plugins/zeroExport/zeroExport.h index 41bb8b2a..b3941edd 100644 --- a/src/plugins/zeroExport/zeroExport.h +++ b/src/plugins/zeroExport/zeroExport.h @@ -20,7 +20,7 @@ template class ZeroExport { public: /** ZeroExport - * Konstruktor + * constructor */ ZeroExport() { mIsInitialized = false; @@ -32,7 +32,7 @@ class ZeroExport { } /** ~ZeroExport - * Destruktor + * destructor */ ~ZeroExport() {} @@ -1066,42 +1066,53 @@ class ZeroExport { * @returns true/false */ bool groupSetReboot(uint8_t group, unsigned long *tsp, bool *doLog) { + zeroExportGroup_t *cfgGroup = &mCfg->groups[group]; bool result = true; if (mCfg->debug) mLog["t"] = "groupSetReboot"; - mCfg->groups[group].lastRun = *tsp; + cfgGroup->lastRun = *tsp; JsonArray logArr = mLog.createNestedArray("ix"); for (uint8_t inv = 0; inv < ZEROEXPORT_GROUP_MAX_INVERTERS; inv++) { JsonObject logObj = logArr.createNestedObject(); logObj["i"] = inv; + zeroExportGroupInverter_t *cfgGroupInv = &cfgGroup->inverters[inv]; + // Inverter not enabled or not selected -> ignore if (NotEnabledOrNotSelected(group, inv)) continue; - // Reset - if ((mCfg->groups[group].inverters[inv].doReboot) && (mCfg->groups[group].inverters[inv].waitRebootAck == 0)) { + // Inverter not available -> ignore + if (!mIv[group][inv]->isAvailable()) { + logObj["a"] = false; result = false; - mCfg->groups[group].inverters[inv].doReboot = false; continue; } - // Wait - if (mCfg->groups[group].inverters[inv].waitRebootAck > 0) { + // Reset + if ((cfgGroupInv->doReboot == 2) && (cfgGroupInv->waitRebootAck == 0)) { result = false; + cfgGroupInv->doReboot = 0; + logObj["act"] = "done"; continue; } - // Inverter nothing to do -> ignore - if (!mCfg->groups[group].inverters[inv].doReboot) { + // Calculate + if (cfgGroupInv->doReboot == 1) { + cfgGroupInv->doReboot = 2; + } + + // Wait + if (cfgGroupInv->waitRebootAck > 0) { + logObj["w"] = cfgGroupInv->waitRebootAck; + result = false; continue; } - // Inverter not available -> ignore - if (!mIv[group][inv]->isAvailable()) { - result = false; - logObj["err"] = "is not Available"; + // Inverter nothing to do -> ignore + if (cfgGroupInv->doReboot == 0) { + logObj["act"] = "nothing to do"; continue; } @@ -1109,20 +1120,19 @@ class ZeroExport { *doLog = true; - logObj["act"] = String("reboot"); + if (!mCfg->debug) logObj["act"] = cfgGroupInv->doReboot; // wait for Ack - mCfg->groups[group].inverters[inv].waitRebootAck = 120; - logObj["wR"] = mCfg->groups[group].inverters[inv].waitRebootAck; + cfgGroupInv->waitRebootAck = 120; + logObj["wR"] = cfgGroupInv->waitRebootAck; // send Command DynamicJsonDocument doc(512); JsonObject obj = doc.to(); - obj["id"] = mCfg->groups[group].inverters[inv].id; + obj["id"] = cfgGroupInv->id; obj["path"] = "ctrl"; obj["cmd"] = "restart"; mApi->ctrlRequest(obj); - logObj["d"] = obj; }