mirror of
https://github.com/lumapu/ahoy.git
synced 2025-06-09 22:21:39 +02:00
Bugfix: groupSetReboot
This commit is contained in:
parent
37e261ddaf
commit
5c2e151797
2 changed files with 31 additions and 21 deletions
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset
|
||||||
|
if ((cfgGroupInv->doReboot == 2) && (cfgGroupInv->waitRebootAck == 0)) {
|
||||||
|
result = false;
|
||||||
|
cfgGroupInv->doReboot = 0;
|
||||||
|
logObj["act"] = "done";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate
|
||||||
|
if (cfgGroupInv->doReboot == 1) {
|
||||||
|
cfgGroupInv->doReboot = 2;
|
||||||
|
}
|
||||||
|
|
||||||
// Wait
|
// Wait
|
||||||
if (mCfg->groups[group].inverters[inv].waitRebootAck > 0) {
|
if (cfgGroupInv->waitRebootAck > 0) {
|
||||||
|
logObj["w"] = cfgGroupInv->waitRebootAck;
|
||||||
result = false;
|
result = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inverter nothing to do -> ignore
|
// Inverter nothing to do -> ignore
|
||||||
if (!mCfg->groups[group].inverters[inv].doReboot) {
|
if (cfgGroupInv->doReboot == 0) {
|
||||||
continue;
|
logObj["act"] = "nothing to do";
|
||||||
}
|
|
||||||
|
|
||||||
// Inverter not available -> ignore
|
|
||||||
if (!mIv[group][inv]->isAvailable()) {
|
|
||||||
result = false;
|
|
||||||
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…
Add table
Add a link
Reference in a new issue