Browse Source

0.8.1030006

pull/1615/head
Patrick Amrhein 9 months ago
parent
commit
99d274c257
  1. 2
      src/defines.h
  2. 41
      src/plugins/zeroExport/zeroExport.h

2
src/defines.h

@ -13,7 +13,7 @@
//------------------------------------- //-------------------------------------
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 8 #define VERSION_MINOR 8
#define VERSION_PATCH 1030005 #define VERSION_PATCH 1030006
//------------------------------------- //-------------------------------------
typedef struct { typedef struct {
uint8_t ch; uint8_t ch;

41
src/plugins/zeroExport/zeroExport.h

@ -212,6 +212,7 @@ class ZeroExport {
float Ki = CfgGroup->Ki; float Ki = CfgGroup->Ki;
float Kd = CfgGroup->Kd; float Kd = CfgGroup->Kd;
unsigned long Ta = Tsp - CfgGroup->lastRefresh; unsigned long Ta = Tsp - CfgGroup->lastRefresh;
CfgGroup->lastRefresh = Tsp;
int16_t yP = Kp * e; int16_t yP = Kp * e;
CfgGroup->eSum += e; CfgGroup->eSum += e;
int16_t yI = Ki * Ta * CfgGroup->eSum; int16_t yI = Ki * Ta * CfgGroup->eSum;
@ -250,7 +251,9 @@ class ZeroExport {
// Check // Check
if (CfgGroupInv->action == zeroExportAction_t::doNone) { if (CfgGroupInv->action == zeroExportAction_t::doNone) {
if ((CfgGroup->battSwitch == true) && (CfgGroupInv->limitNew > CfgGroupInv->powerMin) && (CfgGroupInv->power == 0) && (!mCfg->sleep) && (!CfgGroup->sleep)) { // if ((CfgGroup->battSwitch == true) && (CfgGroupInv->limitNew > CfgGroupInv->powerMin) && (CfgGroupInv->power == 0) && (mCfg->sleep != true) && (CfgGroup->sleep != true)) {
// TODO: Schlägt fehl, weil wenn MaxPower = 0 wird y auf 0 gesetzt und damit ist limitNew = powerMin
if ((CfgGroup->battSwitch == true) && (CfgGroupInv->power == 0) && (mCfg->sleep != true) && (CfgGroup->sleep != true)) {
CfgGroupInv->action = zeroExportAction_t::doTurnOn; CfgGroupInv->action = zeroExportAction_t::doTurnOn;
mLog["do"] = "doTurnOn"; mLog["do"] = "doTurnOn";
} }
@ -260,7 +263,7 @@ class ZeroExport {
mLog["do"] = "doTurnOff"; mLog["do"] = "doTurnOff";
} }
if ((mCfg->sleep || CfgGroup->sleep) && CfgGroupInv->power > 0) { if (((mCfg->sleep == true) || (CfgGroup->sleep == true)) && (CfgGroupInv->power > 0)) {
CfgGroupInv->action = zeroExportAction_t::doTurnOff; CfgGroupInv->action = zeroExportAction_t::doTurnOff;
mLog["do"] = "sleep"; mLog["do"] = "sleep";
} }
@ -347,8 +350,6 @@ class ZeroExport {
break; break;
} }
CfgGroup->lastRefresh = Tsp;
sendLog(); sendLog();
// MQTT - Powermeter // MQTT - Powermeter
@ -589,34 +590,32 @@ class ZeroExport {
mCfg->enabled = (bool)obj["val"]; mCfg->enabled = (bool)obj["val"];
mLog["k"] = "ctrl/zero/enabled"; mLog["k"] = "ctrl/zero/enabled";
mLog["v"] = mCfg->enabled; mLog["v"] = mCfg->enabled;
return;
} }
// "topic":"ctrl/zero/sleep" // "topic":"ctrl/zero/sleep"
if (topic.indexOf("/ctrl/zero/sleep") != -1) { if (topic.indexOf("ctrl/zero/sleep") != -1) {
mCfg->sleep = (bool)obj["val"]; mCfg->sleep = (bool)obj["val"];
mLog["k"] = "ctrl/zero/sleep"; mLog["k"] = "ctrl/zero/sleep";
mLog["v"] = mCfg->sleep; mLog["v"] = mCfg->sleep;
return;
} }
if ((topicGroup >= 0) && (topicGroup < ZEROEXPORT_MAX_GROUPS)) { if ((topicGroup >= 0) && (topicGroup < ZEROEXPORT_MAX_GROUPS)) {
// "topic":"ctrl/zero/groups/+/enabled" // "topic":"ctrl/zero/groups/+/enabled"
if (topic.indexOf("/ctrl/zero/groups/" + String(topicGroup) + "/enabled") != -1) { if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/enabled") != -1) {
mCfg->groups[topicGroup].enabled = (bool)obj["val"]; mCfg->groups[topicGroup].enabled = (bool)obj["val"];
mLog["k"] = "/ctrl/zero/groups/" + String(topicGroup) + "/enabled"; mLog["k"] = "ctrl/zero/groups/" + String(topicGroup) + "/enabled";
mLog["v"] = mCfg->groups[topicGroup].enabled; mLog["v"] = mCfg->groups[topicGroup].enabled;
} }
// "topic":"ctrl/zero/groups/+/sleep" // "topic":"ctrl/zero/groups/+/sleep"
if (topic.indexOf("/ctrl/zero/groups/" + String(topicGroup) + "/sleep") != -1) { if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/sleep") != -1) {
mCfg->groups[topicGroup].sleep = (bool)obj["val"]; mCfg->groups[topicGroup].sleep = (bool)obj["val"];
mLog["k"] = "/ctrl/zero/groups/" + String(topicGroup) + "/sleep"; mLog["k"] = "ctrl/zero/groups/" + String(topicGroup) + "/sleep";
mLog["v"] = mCfg->groups[topicGroup].sleep; mLog["v"] = mCfg->groups[topicGroup].sleep;
} }
// "topic":"ctrl/zero/groups/+/pm_ip" // "topic":"ctrl/zero/groups/+/pm_ip"
if (topic.indexOf("/ctrl/zero/groups/" + String(topicGroup) + "/pm_ip") != -1) { if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/pm_ip") != -1) {
// snprintf(mCfg->groups[topicGroup].pm_url, ZEROEXPORT_GROUP_MAX_LEN_PM_URL, "%s", obj[F("val")].as<const char *>()); // snprintf(mCfg->groups[topicGroup].pm_url, ZEROEXPORT_GROUP_MAX_LEN_PM_URL, "%s", obj[F("val")].as<const char *>());
// mLog["g_powermeter_pm_ip"] = mCfg->groups[topicGroup].pm_url; // mLog["g_powermeter_pm_ip"] = mCfg->groups[topicGroup].pm_url;
// snprintf(mCfg->groups[5].pm_url, ZEROEXPORT_GROUP_MAX_LEN_PM_URL, "%s", obj[F("val")].as<const char *>()); // snprintf(mCfg->groups[5].pm_url, ZEROEXPORT_GROUP_MAX_LEN_PM_URL, "%s", obj[F("val")].as<const char *>());
@ -624,36 +623,36 @@ class ZeroExport {
} }
// "topic":"ctrl/zero/groups/+/pm_jsonPath" // "topic":"ctrl/zero/groups/+/pm_jsonPath"
if (topic.indexOf("/ctrl/zero/groups/" + String(topicGroup) + "/pm_jsonPath") != -1) { if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/pm_jsonPath") != -1) {
// snprintf(mCfg->groups[topicGroup].pm_jsonPath, ZEROEXPORT_GROUP_MAX_LEN_PM_JSONPATH, "%s", obj[F("val")].as<const char *>()); // snprintf(mCfg->groups[topicGroup].pm_jsonPath, ZEROEXPORT_GROUP_MAX_LEN_PM_JSONPATH, "%s", obj[F("val")].as<const char *>());
// mLog["g_powermeter_pm_jsonPath"] = mCfg->groups[topicGroup].pm_jsonPath; // mLog["g_powermeter_pm_jsonPath"] = mCfg->groups[topicGroup].pm_jsonPath;
} }
// "topic":"ctrl/zero/groups/+/battery/switch" // "topic":"ctrl/zero/groups/+/battery/switch"
if (topic.indexOf("/ctrl/zero/groups/" + String(topicGroup) + "/battery/switch") != -1) { if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/battery/switch") != -1) {
mCfg->groups[topicGroup].battSwitch = (bool)obj["val"]; mCfg->groups[topicGroup].battSwitch = (bool)obj["val"];
mLog["k"] = "/ctrl/zero/groups/" + String(topicGroup) + "/battery/switch"; mLog["k"] = "ctrl/zero/groups/" + String(topicGroup) + "/battery/switch";
mLog["v"] = mCfg->groups[topicGroup].battSwitch; mLog["v"] = mCfg->groups[topicGroup].battSwitch;
} }
// "topic":"ctrl/zero/groups/+/advanced/setPoint" // "topic":"ctrl/zero/groups/+/advanced/setPoint"
if (topic.indexOf("/ctrl/zero/groups/" + String(topicGroup) + "/advanced/setPoint") != -1) { if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/advanced/setPoint") != -1) {
mCfg->groups[topicGroup].setPoint = (int16_t)obj["val"]; mCfg->groups[topicGroup].setPoint = (int16_t)obj["val"];
mLog["k"] = "/ctrl/zero/groups/" + String(topicGroup) + "/advanced/setPoint"; mLog["k"] = "ctrl/zero/groups/" + String(topicGroup) + "/advanced/setPoint";
mLog["v"] = mCfg->groups[topicGroup].setPoint; mLog["v"] = mCfg->groups[topicGroup].setPoint;
} }
// "topic":"ctrl/zero/groups/+/advanced/powerTolerance" // "topic":"ctrl/zero/groups/+/advanced/powerTolerance"
if (topic.indexOf("/ctrl/zero/groups/" + String(topicGroup) + "/advanced/powerTolerance") != -1) { if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/advanced/powerTolerance") != -1) {
mCfg->groups[topicGroup].powerTolerance = (uint8_t)obj["val"]; mCfg->groups[topicGroup].powerTolerance = (uint8_t)obj["val"];
mLog["k"] = "/ctrl/zero/groups/" + String(topicGroup) + "/advanced/powerTolerance"; mLog["k"] = "ctrl/zero/groups/" + String(topicGroup) + "/advanced/powerTolerance";
mLog["v"] = mCfg->groups[topicGroup].powerTolerance; mLog["v"] = mCfg->groups[topicGroup].powerTolerance;
} }
// "topic":"ctrl/zero/groups/+/advanced/powerMax" // "topic":"ctrl/zero/groups/+/advanced/powerMax"
if (topic.indexOf("/ctrl/zero/groups/" + String(topicGroup) + "/advanced/powerMax") != -1) { if (topic.indexOf("ctrl/zero/groups/" + String(topicGroup) + "/advanced/powerMax") != -1) {
mCfg->groups[topicGroup].powerMax = (uint16_t)obj["val"]; mCfg->groups[topicGroup].powerMax = (uint16_t)obj["val"];
mLog["k"] = "/ctrl/zero/groups/" + String(topicGroup) + "/advanced/powerMax"; mLog["k"] = "ctrl/zero/groups/" + String(topicGroup) + "/advanced/powerMax";
mLog["v"] = mCfg->groups[topicGroup].powerMax; mLog["v"] = mCfg->groups[topicGroup].powerMax;
} }

Loading…
Cancel
Save