mirror of
https://github.com/lumapu/ahoy.git
synced 2025-04-30 10:46:24 +02:00
Update zeroExport.h
Add mqttObj and remove some hints
This commit is contained in:
parent
e7095bf398
commit
dd79bd4d0d
1 changed files with 30 additions and 8 deletions
|
@ -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];
|
||||||
|
@ -263,9 +263,11 @@ class ZeroExport {
|
||||||
void tickMidnight(void) {
|
void tickMidnight(void) {
|
||||||
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
|
||||||
for (uint8_t group = 0; group < ZEROEXPORT_MAX_GROUPS; group++) {
|
//@Todo: move to ahoy!
|
||||||
|
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…
Add table
Reference in a new issue