Browse Source

0.8.1030018-zero

0.8.1030018-zero
pull/1656/head
tictrick 8 months ago
committed by GitHub
parent
commit
9c510d5ad2
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      src/defines.h
  2. 2
      src/platformio.ini
  3. 27
      src/plugins/zeroExport/powermeter.h
  4. 20
      src/plugins/zeroExport/zeroExport.h
  5. 11
      src/web/RestApi.h
  6. 53
      src/web/html/setup.html
  7. 7
      src/web/lang.json

2
src/defines.h

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

2
src/platformio.ini

@ -28,7 +28,7 @@ lib_deps =
https://github.com/esphome/ESPAsyncWebServer @ ^3.2.0
https://github.com/nRF24/RF24.git#v1.4.8
paulstoffregen/Time @ ^1.6.1
https://github.com/bertmelis/espMqttClient#v1.6.0
https://github.com/bertmelis/espMqttClient#v1.7.0
bblanchon/ArduinoJson @ ^6.21.3
https://github.com/JChristensen/Timezone @ ^1.2.4
olikraus/U8g2 @ ^2.35.9

27
src/plugins/zeroExport/powermeter.h

@ -115,15 +115,16 @@ class powermeter {
#endif
}
// if (mMqtt->isConnected()) mMqtt->publish(String("zero/state/groups/" + String(group) + "/result").c_str(), String(ret).c_str(), false);
if (result) {
bufferWrite(power, group);
mCfg->groups[group].power = power;
// MQTT - Powermeter
/// BUG: 002 Anfang - Muss dieser Teil raus? Führt er zu abstürzen wie BUG 001?
if (mMqtt->isConnected()) {
mMqtt->publish(String("zero/state/groups/" + String(group) + "/powermeter/P").c_str(), String(ah::round1(power)).c_str(), false);
}
/// BUG: 002 Ende
}
}
}
@ -218,6 +219,7 @@ class powermeter {
float power = 0.0;
/// TODO: Json aktivieren
// //TODO: datajson 100 enough?
// // this if-statement need to check if value contains a json object.
// // is it so, then deserialize it and get the values (Shelly GEN2)
@ -232,19 +234,20 @@ class powermeter {
// }
// } else {
// //TODO: check if parse is possible here? Is that right?
power = (uint16_t)obj["val"];
power = (float)obj["val"];
// }
bufferWrite(power, group);
mCfg->groups[group].power = power; // TODO: join two sites together (PM & MQTT)
// MQTT - Powermeter
if (mCfg->debug) {
if (mMqtt->isConnected()) {
mMqtt->publish(String("zero/state/groups/" + String(group) + "/powermeter/P").c_str(), String(ah::round1(power)).c_str(), false);
}
}
return;
/// BUG: 001 Anfang - Dieser Teil ist deaktiviert weil er zu abstürzen der DTU führt
// if (mCfg->debug) {
// if (mMqtt->isConnected()) {
// mMqtt->publish(String("zero/state/groups/" + String(group) + "/powermeter/P").c_str(), String(ah::round1(power)).c_str(), false);
// }
// }
/// BUG: 001 Ende
}
#endif /*defined(ZEROEXPORT_POWERMETER_MQTT)*/

20
src/plugins/zeroExport/zeroExport.h

@ -345,9 +345,11 @@ class ZeroExport {
sendLog();
// MQTT - Powermeter
if (mMqtt->isConnected()) {
mqttPublish(String("zero/state/groups/" + String(group) + "/inverter/" + String(inv)).c_str(), mDocLog.as<std::string>().c_str());
}
/// BUG: 003 Anfang
// if (mMqtt->isConnected()) {
// mqttPublish(String("zero/state/groups/" + String(group) + "/inverter/" + String(inv)).c_str(), mDocLog.as<std::string>().c_str());
// }
/// BUG: 003 Ende
clearLog();
@ -821,11 +823,13 @@ class ZeroExport {
}
// Log over MQTT
if (mCfg->log_over_mqtt) {
if (mMqtt->isConnected()) {
mMqtt->publish("zero/log", mDocLog.as<std::string>().c_str(), false);
}
}
/// BUG: 004 Anfang
// if (mCfg->log_over_mqtt) {
// if (mMqtt->isConnected()) {
// mMqtt->publish("zero/log", mDocLog.as<std::string>().c_str(), false);
// }
// }
/// BUG: 004 Ende
}
/** clearLog

11
src/web/RestApi.h

@ -843,7 +843,7 @@ class RestApi {
objGroup[F("pm_src")] = String(mConfig->plugin.zeroExport.groups[group].pm_src);
objGroup[F("pm_jsonPath")] = String(mConfig->plugin.zeroExport.groups[group].pm_jsonPath);
objGroup[F("pm_user")] = String(mConfig->plugin.zeroExport.groups[group].pm_user);
objGroup[F("pm_pass")] = String(mConfig->plugin.zeroExport.groups[group].pm_pass);
//objGroup[F("pm_pass")] = String(mConfig->plugin.zeroExport.groups[group].pm_pass); // for security reason
objGroup[F("pm_target")] = (uint8_t)mConfig->plugin.zeroExport.groups[group].pm_target;
// Inverters
objGroup[F("max_inverters")] = ZEROEXPORT_GROUP_MAX_INVERTERS;
@ -861,6 +861,8 @@ class RestApi {
objGroup[F("battTopic")] = String(mConfig->plugin.zeroExport.groups[group].battTopic);
objGroup[F("battLimitOn")] = ah::round1((float)mConfig->plugin.zeroExport.groups[group].battLimitOn);
objGroup[F("battLimitOff")] = ah::round1((float)mConfig->plugin.zeroExport.groups[group].battLimitOff);
objGroup[F("battSwitch")] = (bool)mConfig->plugin.zeroExport.groups[group].battSwitch;
// Advanced
objGroup[F("setPoint")] = (int16_t)mConfig->plugin.zeroExport.groups[group].setPoint;
objGroup[F("minimum")] = (bool)mConfig->plugin.zeroExport.groups[group].minimum;
@ -1145,12 +1147,7 @@ class RestApi {
#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")];
mConfig->plugin.zeroExport.groups[group].battSwitch = (bool)jsonIn[F("battSwitch")];
}
else if(F("ze_save_group") == jsonIn[F("cmd")]) {
// General

53
src/web/html/setup.html

@ -1300,9 +1300,20 @@
}
function battOnOff() {
// TODO: zuerst wert setzen
// dann über ajax denn gesetzten wert zurück aus dem system holen
// damit man sieht das es erfolgreich gesetzt worden ist.
const sw = document.getElementById("battSwitch");
if (sw.value == 0) {
sw.value = 1;
sw.innerHTML = "{#BTN_ON}";
} else {
sw.value = 0;
sw.innerHTML = "{#BTN_OFF}";
}
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) {
@ -1427,27 +1438,15 @@
]),
// Battery
ml("div", {id: "div{#ZE_GROUP_TAB_BATTERY}", class: "tab-content hide"}, [
divRow("{#ZE_GROUP_TAB_BATTERY_CFG}",
ml("select", {name: "battCfg", class: "text", id: "battCfg"}, null),
),
divRow("{#ZE_GROUP_TAB_BATTERY_TOPIC}",
ml("input", {name: "battTopic", class: "text", type: "text", value: obj.battTopic}, null),
),
divRow("{#ZE_GROUP_TAB_BATTERY_LIMITON}",
ml("input", {name: "battLimitOn", class: "text", type: "number", min: "0", max: "100", step: "0.1", value: obj.battLimitOn}, null),
),
divRow("{#ZE_GROUP_TAB_BATTERY_LIMITOFF}",
ml("input", {name: "battLimitOff", class: "text", type: "number", min: "0", max: "100", step: "0.1", value: obj.battLimitOff}, null),
),
divRow("{#ZE_GROUP_TAB_BATTERY_ONOFF}", ml("input", {name: "battSwitch", id: "battSwitch", class: "btn", type: "button", value: "{#BTN_ONOFF}", onclick: battOnOff()}, null)),
divRow("{#ZE_GROUP_TAB_BATTERY_CFG}", ml("select", {name: "battCfg", class: "text", id: "battCfg"}, null),),
divRow("{#ZE_GROUP_TAB_BATTERY_TOPIC}", ml("input", {name: "battTopic", class: "text", type: "text", value: obj.battTopic}, null),),
divRow("{#ZE_GROUP_TAB_BATTERY_LIMITON}", ml("input", {name: "battLimitOn", class: "text", type: "number", min: "0", max: "100", step: "0.1", value: obj.battLimitOn}, null),),
divRow("{#ZE_GROUP_TAB_BATTERY_LIMITOFF}", ml("input", {name: "battLimitOff", class: "text", type: "number", min: "0", max: "100", step: "0.1", value: obj.battLimitOff}, null),),
divRow("{#ZE_GROUP_TAB_BATTERY_ONOFF}", ml("input", {name: "battSwitch", id: "battSwitch", class: "btn", type: "button", value: obj.battSwitch}, null)),
// TODO: Uebersetzen mit lang.json und auf die entsprechende Dokuseite verlinken
divRow("Hinweis: ",
ml("a", {href: "https://docs.ahoydtu.de/de/latest/zeroExport.html"}, "Bitte beachten Sie die Ausf&uuml;llhinweise in der Dokumentation."),
),
divRow("Hinweis: ", ml("a", {href: "https://docs.ahoydtu.de/de/latest/zeroExport.html"}, "Bitte beachten Sie die Ausf&uuml;llhinweise in der Dokumentation."),),
// TODO: Hinweis Github/Discord - Entfernen wenn erledigt
divRow("ACHTUNG: ",
ml("a", {href: "https://discord.com/channels/984173303147155506/1211365440253726851"}, "Bitte auf Github keine Issues zu Zero er&ouml;ffnen, sondern direkt im Discord melden."),
),
divRow("ACHTUNG: ", ml("a", {href: "https://discord.com/channels/984173303147155506/1211365440253726851"}, "Bitte auf Github keine Issues zu Zero er&ouml;ffnen, sondern direkt im Discord melden."),),
]),
// Advanced
ml("div", {id: "div{#ZE_GROUP_TAB_ADVANCED}", class: "tab-content hide"}, [
@ -1459,13 +1458,9 @@
divRow("{#ZE_GROUP_TAB_ADVANCED_KI}", ml("input", {name: "Ki", class: "text", type: "number", min: "-0.01", max: "0", step: "0.001", value: obj.Ki}, null)),
divRow("{#ZE_GROUP_TAB_ADVANCED_KD}", ml("input", {name: "Kd", class: "text", type: "number", min: "-0.01", max: "0", step: "0.001", value: obj.Kd}, null)),
// TODO: Uebersetzen mit lang.json und auf die entsprechende Dokuseite verlinken
divRow("Hinweis: ",
ml("a", {href: "https://docs.ahoydtu.de/de/latest/zeroExport.html"}, "Bitte beachten Sie die Ausf&uuml;llhinweise in der Dokumentation."),
),
divRow("Hinweis: ", ml("a", {href: "https://docs.ahoydtu.de/de/latest/zeroExport.html"}, "Bitte beachten Sie die Ausf&uuml;llhinweise in der Dokumentation."),),
// TODO: Hinweis Github/Discord - Entfernen wenn erledigt
divRow("ACHTUNG: ",
ml("a", {href: "https://discord.com/channels/984173303147155506/1211365440253726851"}, "Bitte auf Github keine Issues zu Zero er&ouml;ffnen, sondern direkt im Discord melden."),
),
divRow("ACHTUNG: ", ml("a", {href: "https://discord.com/channels/984173303147155506/1211365440253726851"}, "Bitte auf Github keine Issues zu Zero er&ouml;ffnen, sondern direkt im Discord melden."),),
]),
// Global
ml("div", {class: "row mt-5"}, [
@ -1475,6 +1470,10 @@
]);
modal("{#ZE_GROUP_EDIT_MODAL}: " + obj.id, html);
// add addEventListener for battSwitch
const se_battswitch = document.querySelector("#battSwitch");
se_battswitch.addEventListener("click", (event) => { battOnOff()});
// ser.dispatchEvent(new Event('change'));
// Tab_Powermeter
@ -1662,6 +1661,8 @@
o.battTopic = document.getElementsByName("battTopic")[0].value;
o.battLimitOn = document.getElementsByName("battLimitOn")[0].value;
o.battLimitOff = document.getElementsByName("battLimitOff")[0].value;
//o.battSwitch = document.getElementsByName("battSwitch")[0].value;
// Advanced
o.setPoint = document.getElementsByName("setPoint")[0].value;
o.minimum = document.getElementsByName("minimum")[0].checked;

7
src/web/lang.json

@ -979,10 +979,15 @@
"de": "Power:"
},
{
"token": "BTN_ONOFF",
"token": "BTN_ON",
"en": "On",
"de": "Ein"
},
{
"token": "BTN_OFF",
"en": "Off",
"de": "Aus"
},
{
"token": "ZE_GROUP_TAB_ADVANCED",
"en": "Advanced",

Loading…
Cancel
Save