Browse Source

Bugfix: groupSetReboot

pull/1551/head
Patrick Amrhein 10 months ago
parent
commit
5c2e151797
  1. 2
      src/config/settings.h
  2. 48
      src/plugins/zeroExport/zeroExport.h

2
src/config/settings.h

@ -271,7 +271,7 @@ typedef struct {
float dcVoltage; float dcVoltage;
bool state; bool state;
// //
bool doReboot; int8_t doReboot;
int8_t doPower; int8_t doPower;
bool doLimit; bool doLimit;
} zeroExportGroupInverter_t; } zeroExportGroupInverter_t;

48
src/plugins/zeroExport/zeroExport.h

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

Loading…
Cancel
Save