Browse Source

0.8.910011-zero

pull/1521/head
Patrick Amrhein 11 months ago
parent
commit
40ad725bab
  1. 1
      src/config/settings.h
  2. 2
      src/defines.h
  3. 70
      src/plugins/zeroExport/zeroExport.h
  4. 9
      src/web/RestApi.h
  5. 18
      src/web/html/setup.html
  6. 10
      src/web/lang.json

1
src/config/settings.h

@ -188,6 +188,7 @@ typedef struct {
// Plugin ZeroExport
#if defined(PLUGIN_ZEROEXPORT)
#define ZEROEXPORT_DEV_POWERMETER
#define ZEROEXPORT_MAX_GROUPS 6
#define ZEROEXPORT_GROUP_MAX_LEN_NAME 25
#define ZEROEXPORT_GROUP_MAX_LEN_PM_URL 100

2
src/defines.h

@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 8
#define VERSION_PATCH 910010
#define VERSION_PATCH 910011
//-------------------------------------
typedef struct {

70
src/plugins/zeroExport/zeroExport.h

@ -46,7 +46,6 @@ class ZeroExport {
mApi = api;
mMqtt = mqtt;
// mIsInitialized = true;
// TODO: Sicherheitsreturn weil noch Sicherheitsfunktionen fehlen.
mIsInitialized = false;
}
@ -67,6 +66,10 @@ class ZeroExport {
switch (mCfg->groups[group].state) {
case zeroExportState::INIT:
if (groupInit(group)) sendLog();
//#if defined(ZEROEXPORT_DEV_POWERMETER)
//mCfg->groups[group].state = zeroExportState::WAITREFRESH;
//mCfg->groups[group].stateNext = zeroExportState::WAITREFRESH;
//#endif
break;
case zeroExportState::WAIT:
if (groupWait(group)) sendLog();
@ -85,6 +88,11 @@ class ZeroExport {
break;
case zeroExportState::GETPOWERMETER:
if (groupGetPowermeter(group)) sendLog();
#if defined(ZEROEXPORT_DEV_POWERMETER)
mCfg->groups[group].state = zeroExportState::WAITREFRESH;
mCfg->groups[group].stateNext = zeroExportState::WAITREFRESH;
mCfg->groups[group].lastRefresh = millis();;
#endif
break;
case zeroExportState::CONTROLLER:
if (groupController(group)) sendLog();
@ -100,9 +108,17 @@ class ZeroExport {
break;
case zeroExportState::SETPOWER:
if (groupSetPower(group)) sendLog();
// waitForAck fehlt noch
mCfg->groups[group].state = zeroExportState::WAIT;
mCfg->groups[group].stateNext = zeroExportState::WAIT;
mCfg->groups[group].lastRefresh = millis();;
break;
case zeroExportState::SETREBOOT:
if (groupSetReboot(group)) sendLog();
// waitForAck fehlt noch
mCfg->groups[group].lastRefresh = millis();;
mCfg->groups[group].state = zeroExportState::WAIT;
mCfg->groups[group].stateNext = zeroExportState::WAIT;
break;
case zeroExportState::FINISH:
mCfg->groups[group].state = zeroExportState::WAITREFRESH;
@ -110,9 +126,6 @@ class ZeroExport {
mCfg->groups[group].lastRefresh = millis();;
break;
case zeroExportState::ERROR:
mCfg->groups[group].state = zeroExportState::INIT;
mCfg->groups[group].stateNext = zeroExportState::INIT;
break;
default:
mCfg->groups[group].state = zeroExportState::INIT;
mCfg->groups[group].stateNext = zeroExportState::INIT;
@ -258,6 +271,7 @@ mCfg->groups[group].lastRefresh = millis();;
mLog["E"] = eTsp;
mLog["D"] = eTsp - bTsp;
mCfg->groups[group].lastRun = eTsp;
mCfg->groups[group].lastRefresh = eTsp;
return doLog;
}
@ -296,6 +310,7 @@ mCfg->groups[group].lastRefresh = millis();;
mLog["E"] = eTsp;
mLog["D"] = eTsp - bTsp;
mCfg->groups[group].lastRun = eTsp;
mCfg->groups[group].lastRefresh = eTsp;
return result;
}
@ -312,7 +327,7 @@ mCfg->groups[group].lastRefresh = millis();;
mLog["B"] = bTsp;
// Wait Refreshtime
if (mCfg->groups[group].lastRefresh >= (bTsp - (mCfg->groups[group].refresh * 1000UL))) {
if (mCfg->groups[group].lastRefresh + (mCfg->groups[group].refresh * 1000UL) >= bTsp) {
return result;
}
@ -321,14 +336,18 @@ mCfg->groups[group].lastRefresh = millis();;
result = true;
// Next
#if defined(ZEROEXPORT_DEV_POWERMETER)
mCfg->groups[group].state = zeroExportState::GETPOWERMETER;
mCfg->groups[group].stateNext = zeroExportState::GETPOWERMETER;
#else
mCfg->groups[group].state = zeroExportState::GETINVERTERACKS;
mCfg->groups[group].stateNext = zeroExportState::GETINVERTERACKS;
mLog["next"] = "GETINVERTERACKS";
#endif
unsigned long eTsp = millis();
mLog["E"] = eTsp;
mLog["D"] = eTsp - bTsp;
// mCfg->groups[group].lastRefresh = eTsp;
mCfg->groups[group].lastRun = eTsp;
return result;
}
@ -393,11 +412,11 @@ mCfg->groups[group].lastRefresh = millis();;
}
}
if (wait) {
if (mCfg->groups[group].lastRun > (millis() - 30000UL)) {
wait = false;
}
}
// if (wait) {
// if (mCfg->groups[group].lastRun > (millis() - 30000UL)) {
// wait = false;
// }
// }
mLog["wait"] = wait;
@ -446,6 +465,11 @@ mCfg->groups[group].lastRefresh = millis();;
continue;
}
if (!mIv[group][inv]->isAvailable())
{
continue;
}
// Get Pac
record_t<> *rec;
rec = mIv[group][inv]->getRecordStruct(RealTimeRunData_Debug);
@ -479,6 +503,8 @@ mCfg->groups[group].lastRefresh = millis();;
mLog["B"] = bTsp;
mCfg->groups[group].stateLast = zeroExportState::BATTERYPROTECTION;
mCfg->groups[group].state = zeroExportState::GETPOWERMETER;
mCfg->groups[group].stateNext = zeroExportState::GETPOWERMETER;
doLog = true;
@ -521,6 +547,15 @@ mCfg->groups[group].lastRefresh = millis();;
continue;
}
if (!mIv[group][inv]->isAvailable()) {
if (U > 0) {
continue;
}
U = 0;
id = cfgGroupInv->id;
continue;
}
// Get U
record_t<> *rec;
rec = mIv[group][inv]->getRecordStruct(RealTimeRunData_Debug);
@ -542,12 +577,16 @@ mCfg->groups[group].lastRefresh = millis();;
if (U > mCfg->groups[group].battVoltageOn) {
mCfg->groups[group].battSwitch = true;
mLog["action"] = "On";
mCfg->groups[group].state = zeroExportState::SETPOWER;
mCfg->groups[group].stateNext = zeroExportState::SETPOWER;
}
// Switch to OFF
if (U < mCfg->groups[group].battVoltageOff) {
mCfg->groups[group].battSwitch = false;
mLog["action"] = "Off";
mCfg->groups[group].state = zeroExportState::SETPOWER;
mCfg->groups[group].stateNext = zeroExportState::SETPOWER;
}
} else {
mLog["en"] = false;
@ -557,9 +596,9 @@ mCfg->groups[group].lastRefresh = millis();;
mLog["sw"] = mCfg->groups[group].battSwitch;
// Next
mCfg->groups[group].state = zeroExportState::GETPOWERMETER;
mCfg->groups[group].stateNext = zeroExportState::GETPOWERMETER;
// // Next
// mCfg->groups[group].state = zeroExportState::GETPOWERMETER;
// mCfg->groups[group].stateNext = zeroExportState::GETPOWERMETER;
unsigned long eTsp = millis();
mLog["E"] = eTsp;
@ -1424,9 +1463,6 @@ result = true;
http.end();
long int eTsp = millis();
logObj["b"] = bTsp;
logObj["e"] = eTsp;
logObj["d"] = eTsp - bTsp;
logObj["P"] = mCfg->groups[group].pmPower;
logObj["P1"] = mCfg->groups[group].pmPowerL1;
logObj["P2"] = mCfg->groups[group].pmPowerL2;

9
src/web/RestApi.h

@ -992,6 +992,15 @@ class RestApi {
}
// Plugin ZeroExport
#if defined(PLUGIN_ZEROEXPORT)
else if(F("ze_batt_onff") == jsonIn[F("cmd")]) {
uint8_t group = jsonIn[F("id")];
// if (mConfig->plugin.zeroExport.groups[group].battSwitch) {
// mConfig->plugin.zeroExport.groups[group].battSwitch = false;
// } else {
mConfig->plugin.zeroExport.groups[group].battSwitch = true;
// }
// mConfig->plugin.zeroExport.groups[group].battSwitch = jsonIn[F("battSwitch")];
}
else if(F("ze_save_group") == jsonIn[F("cmd")]) {
// General
uint8_t group = jsonIn[F("id")];

18
src/web/html/setup.html

@ -1266,6 +1266,22 @@
}
/*IF_PLUGIN_ZEROEXPORT*/
function apiCbBattOnOff(obj) {
// var e = document.getElementById("battSwitch");
// e.value = "88";
// selDelAllOpt(e);
// if(obj["success"])
// e.appendChild(opt("-1", "{#NETWORK_SCANNING}"))
// else
// e.appendChild(opt("-1", "{#ERROR} " + obj["error"]));
}
function battOnOff() {
var obj = {cmd: "ze_batt_onff", token: "*"}
getAjax("/api/setup", apiCbBattOnOff, "POST", JSON.stringify(obj));
// setTimeout(function() {getAjax('/api/setup/networks', listNetworks)}, 5000);
}
function ZeroExportGroup_Modal(obj, ivObj) {
// Tab_General
@ -1371,7 +1387,7 @@
divRow("{#ZE_GROUP_TAB_BATTERY_BATTENABLED}", cb_battEnabled),
divRow("{#ZE_GROUP_TAB_BATTERY_BATTVOLTAGEON}", ml("input", {name: "battVoltageOn", class: "text", type: "number", min: "0", max: "100", step: "0.1", value: obj.battVoltageOn}, null)),
divRow("{#ZE_GROUP_TAB_BATTERY_BATTVOLTAGEOFF}", ml("input", {name: "battVoltageOff", class: "text", type: "number", min: "0", max: "100", step: "0.1", value: obj.battVoltageOff}, null)),
// TODO: Hier muss ein Button hin, mit dem Switch ein/ausgeschaltet werden kann.
divRow("{#ZE_GROUP_TAB_BATTERY_ONOFF}", ml("input", {name: "battSwitch", id: "battSwitch", class: "btn", type: "button", value: "{#BTN_ONOFF}", onclick: battOnOff()}, null)),
]),
// Advanced
ml("div", {id: "div{#ZE_GROUP_TAB_ADVANCED}", class: "tab-content hide"}, [

10
src/web/lang.json

@ -923,6 +923,16 @@
"en": "Voltage off (Volt):",
"de": "Spannung Aus (Volt):"
},
{
"token": "ZE_GROUP_TAB_BATTERY_ONOFF",
"en": "Power:",
"de": "Power:"
},
{
"token": "BTN_ONOFF",
"en": "On",
"de": "Ein"
},
{
"token": "ZE_GROUP_TAB_ADVANCED",
"en": "Advanced",

Loading…
Cancel
Save