mirror of
https://github.com/lumapu/ahoy.git
synced 2025-06-03 19:21:38 +02:00
0.8.103..15
This commit is contained in:
parent
e363422e97
commit
58f6a5f4fc
7 changed files with 45 additions and 63 deletions
|
@ -206,7 +206,7 @@ typedef struct {
|
|||
#define ZEROEXPORT_MAX_QUEUE_ENTRIES 64
|
||||
#define ZEROEXPORT_MAX_GROUPS 8
|
||||
#define ZEROEXPORT_GROUP_MAX_LEN_NAME 25
|
||||
#define ZEROEXPORT_GROUP_MAX_LEN_PM_URL 100
|
||||
#define ZEROEXPORT_GROUP_MAX_LEN_PM_SRC 100
|
||||
#define ZEROEXPORT_GROUP_MAX_LEN_PM_JSONPATH 100
|
||||
#define ZEROEXPORT_GROUP_MAX_LEN_PM_USER 25
|
||||
#define ZEROEXPORT_GROUP_MAX_LEN_PM_PASS 25
|
||||
|
@ -288,7 +288,7 @@ typedef struct {
|
|||
uint8_t pm_refresh;
|
||||
unsigned long pm_peviousTsp;
|
||||
uint8_t pm_type;
|
||||
char pm_url[ZEROEXPORT_GROUP_MAX_LEN_PM_URL];
|
||||
char pm_src[ZEROEXPORT_GROUP_MAX_LEN_PM_SRC];
|
||||
char pm_jsonPath[ZEROEXPORT_GROUP_MAX_LEN_PM_JSONPATH];
|
||||
char pm_user[ZEROEXPORT_GROUP_MAX_LEN_PM_USER];
|
||||
char pm_pass[ZEROEXPORT_GROUP_MAX_LEN_PM_PASS];
|
||||
|
@ -674,7 +674,7 @@ class settings {
|
|||
mCfg.plugin.zeroExport.groups[group].pm_refresh = 5;
|
||||
mCfg.plugin.zeroExport.groups[group].pm_peviousTsp = 0;
|
||||
mCfg.plugin.zeroExport.groups[group].pm_type = zeroExportPowermeterType_t::None;
|
||||
snprintf(mCfg.plugin.zeroExport.groups[group].pm_url, ZEROEXPORT_GROUP_MAX_LEN_PM_URL, "%s", DEF_ZEXPORT);
|
||||
snprintf(mCfg.plugin.zeroExport.groups[group].pm_src, ZEROEXPORT_GROUP_MAX_LEN_PM_SRC, "%s", DEF_ZEXPORT);
|
||||
snprintf(mCfg.plugin.zeroExport.groups[group].pm_jsonPath, ZEROEXPORT_GROUP_MAX_LEN_PM_JSONPATH, "%s", DEF_ZEXPORT);
|
||||
snprintf(mCfg.plugin.zeroExport.groups[group].pm_user, ZEROEXPORT_GROUP_MAX_LEN_PM_USER, "%s", DEF_ZEXPORT);
|
||||
snprintf(mCfg.plugin.zeroExport.groups[group].pm_pass, ZEROEXPORT_GROUP_MAX_LEN_PM_PASS, "%s", DEF_ZEXPORT);
|
||||
|
@ -1033,7 +1033,7 @@ class settings {
|
|||
// Powermeter
|
||||
obj[F("pm_refresh")] = mCfg.plugin.zeroExport.groups[group].pm_refresh;
|
||||
obj[F("pm_type")] = mCfg.plugin.zeroExport.groups[group].pm_type;
|
||||
obj[F("pm_url")] = mCfg.plugin.zeroExport.groups[group].pm_url;
|
||||
obj[F("pm_src")] = mCfg.plugin.zeroExport.groups[group].pm_src;
|
||||
obj[F("pm_jsonPath")] = mCfg.plugin.zeroExport.groups[group].pm_jsonPath;
|
||||
obj[F("pm_user")] = mCfg.plugin.zeroExport.groups[group].pm_user;
|
||||
obj[F("pm_pass")] = mCfg.plugin.zeroExport.groups[group].pm_pass;
|
||||
|
@ -1067,8 +1067,8 @@ class settings {
|
|||
getVal<uint8_t>(obj, F("pm_refresh"), &mCfg.plugin.zeroExport.groups[group].pm_refresh);
|
||||
if (obj.containsKey(F("pm_type")))
|
||||
getVal<uint8_t>(obj, F("pm_type"), &mCfg.plugin.zeroExport.groups[group].pm_type);
|
||||
if (obj.containsKey(F("pm_url")))
|
||||
getChar(obj, F("pm_url"), mCfg.plugin.zeroExport.groups[group].pm_url, ZEROEXPORT_GROUP_MAX_LEN_PM_URL);
|
||||
if (obj.containsKey(F("pm_src")))
|
||||
getChar(obj, F("pm_src"), mCfg.plugin.zeroExport.groups[group].pm_src, ZEROEXPORT_GROUP_MAX_LEN_PM_SRC );
|
||||
if (obj.containsKey(F("pm_jsonPath")))
|
||||
getChar(obj, F("pm_jsonPath"), mCfg.plugin.zeroExport.groups[group].pm_jsonPath, ZEROEXPORT_GROUP_MAX_LEN_PM_JSONPATH);
|
||||
if (obj.containsKey(F("pm_user")))
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
//-------------------------------------
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 8
|
||||
#define VERSION_PATCH 1030014
|
||||
#define VERSION_PATCH 1030015
|
||||
//-------------------------------------
|
||||
typedef struct {
|
||||
uint8_t ch;
|
||||
|
|
|
@ -116,15 +116,7 @@ class powermeter {
|
|||
// MQTT - Powermeter
|
||||
// if (mCfg->debug) {
|
||||
if (mMqtt->isConnected()) {
|
||||
// P
|
||||
// mqttObj["Sum"] = ah::round1(power);
|
||||
// mqttObj["L1"] = ah::round1(power.P1);
|
||||
// mqttObj["L2"] = ah::round1(power.P2);
|
||||
// mqttObj["L3"] = ah::round1(power.P3);
|
||||
mMqtt->publish(String("zero/state/groups/" + String(group) + "/powermeter/P").c_str(), String(ah::round1(power)).c_str(), false);
|
||||
// mqttDoc.clear();
|
||||
|
||||
// W (TODO)
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
@ -156,8 +148,10 @@ class powermeter {
|
|||
float min = 0.0;
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (i == 0) min = mPowermeterBuffer[group][i];
|
||||
if ( min > mPowermeterBuffer[group][i]) min = mPowermeterBuffer[group][i];
|
||||
if (i == 0)
|
||||
min = mPowermeterBuffer[group][i];
|
||||
if (min > mPowermeterBuffer[group][i])
|
||||
min = mPowermeterBuffer[group][i];
|
||||
}
|
||||
|
||||
return min;
|
||||
|
@ -170,12 +164,12 @@ class powermeter {
|
|||
#if defined(ZEROEXPORT_POWERMETER_MQTT)
|
||||
|
||||
for (uint8_t group = 0; group < ZEROEXPORT_MAX_GROUPS; group++) {
|
||||
if (!strcmp(mCfg->groups[group].pm_jsonPath, "")) continue;
|
||||
if (!strcmp(mCfg->groups[group].pm_src, "")) continue;
|
||||
|
||||
if (!mCfg->groups[group].enabled) continue;
|
||||
|
||||
if (mCfg->groups[group].pm_type == zeroExportPowermeterType_t::Mqtt) {
|
||||
mMqtt->subscribeExtern(String(mCfg->groups[group].pm_jsonPath).c_str(), QOS_2);
|
||||
mMqtt->subscribeExtern(String(mCfg->groups[group].pm_src).c_str(), QOS_2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -195,9 +189,9 @@ class powermeter {
|
|||
|
||||
if (!mCfg->groups[group].pm_type == zeroExportPowermeterType_t::Mqtt) continue;
|
||||
|
||||
if (!strcmp(mCfg->groups[group].pm_jsonPath, "")) continue;
|
||||
if (!strcmp(mCfg->groups[group].pm_src, "")) continue;
|
||||
|
||||
if (strcmp(mCfg->groups[group].pm_jsonPath, String(topic).c_str())) continue;
|
||||
if (strcmp(mCfg->groups[group].pm_src, String(topic).c_str())) continue;
|
||||
|
||||
float power = 0.0;
|
||||
power = (uint16_t)obj["val"];
|
||||
|
@ -207,15 +201,7 @@ class powermeter {
|
|||
// MQTT - Powermeter
|
||||
if (mCfg->debug) {
|
||||
if (mMqtt->isConnected()) {
|
||||
// P
|
||||
mqttObj["Sum"] = ah::round1(power);
|
||||
/// mqttObj["L1"] = ah::round1(power.P1);
|
||||
/// mqttObj["L2"] = ah::round1(power.P2);
|
||||
/// mqttObj["L3"] = ah::round1(power.P3);
|
||||
mMqtt->publish(String("zero/state/groups/" + String(group) + "/powermeter/P").c_str(), mqttDoc.as<std::string>().c_str(), false);
|
||||
mqttDoc.clear();
|
||||
|
||||
// W (TODO)
|
||||
mMqtt->publish(String("zero/state/groups/" + String(group) + "/powermeter/P").c_str(), String(ah::round1(power)).c_str(), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,7 +273,7 @@ class powermeter {
|
|||
|
||||
setHeader(&http);
|
||||
|
||||
String url = String("http://") + String(mCfg->groups[group].pm_url) + String("/") + String(mCfg->groups[group].pm_jsonPath);
|
||||
String url = String("http://") + String(mCfg->groups[group].pm_src) + String("/") + String(mCfg->groups[group].pm_jsonPath);
|
||||
logObj["HTTP_URL"] = url;
|
||||
|
||||
http.begin(url);
|
||||
|
@ -380,8 +366,8 @@ class powermeter {
|
|||
http.addHeader("Content-Type", "application/json");
|
||||
http.addHeader("Accept", "application/json");
|
||||
|
||||
// String url = String("http://") + String(mCfg->groups[group].pm_url) + String("/") + String(mCfg->groups[group].pm_jsonPath);
|
||||
String url = String(mCfg->groups[group].pm_url);
|
||||
// String url = String("http://") + String(mCfg->groups[group].pm_src) + String("/") + String(mCfg->groups[group].pm_jsonPath);
|
||||
String url = String(mCfg->groups[group].pm_src);
|
||||
logObj["HTTP_URL"] = url;
|
||||
|
||||
http.begin(url);
|
||||
|
@ -505,7 +491,7 @@ class powermeter {
|
|||
auth = mCfg->groups[group].pm_pass;
|
||||
}
|
||||
|
||||
String url = String("http://") + mCfg->groups[group].pm_url + String("/") + String(mCfg->groups[group].pm_jsonPath);
|
||||
String url = String("http://") + mCfg->groups[group].pm_src + String("/") + String(mCfg->groups[group].pm_jsonPath);
|
||||
|
||||
setHeader(&http);
|
||||
http.begin(url);
|
||||
|
@ -558,7 +544,7 @@ class powermeter {
|
|||
setHeader(&http);
|
||||
|
||||
String url =
|
||||
String("http://") + String(mCfg->groups[group].pm_url) +
|
||||
String("http://") + String(mCfg->groups[group].pm_src) +
|
||||
String("/") + String(mCfg->groups[group].pm_jsonPath + String("?user=") + String(mCfg->groups[group].pm_user) + String("&password=") + String(mCfg->groups[group].pm_pass));
|
||||
|
||||
http.begin(url);
|
||||
|
|
|
@ -676,14 +676,14 @@ class ZeroExport {
|
|||
// 0.8.103008.2
|
||||
// // "topic":"ctrl/zero/groups/+/pm_ip"
|
||||
// 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_src, ZEROEXPORT_GROUP_MAX_LEN_PM_SRC, "%s", obj[F("val")].as<const char *>());
|
||||
/// TODO:
|
||||
// snprintf(mCfg->groups[topicGroup].pm_url, ZEROEXPORT_GROUP_MAX_LEN_PM_URL, "%s", obj[F("val")].as<const char *>());
|
||||
// strncpy(mCfg->groups[topicGroup].pm_url, obj[F("val")], ZEROEXPORT_GROUP_MAX_LEN_PM_URL);
|
||||
// strncpy(mCfg->groups[topicGroup].pm_url, String(obj[F("val")]).c_str(), ZEROEXPORT_GROUP_MAX_LEN_PM_URL);
|
||||
// snprintf(mCfg->groups[topicGroup].pm_url, ZEROEXPORT_GROUP_MAX_LEN_PM_URL, "%s", String(obj[F("val")]).c_str());
|
||||
// snprintf(mCfg->groups[topicGroup].pm_src, ZEROEXPORT_GROUP_MAX_LEN_PM_SRC, "%s", obj[F("val")].as<const char *>());
|
||||
// strncpy(mCfg->groups[topicGroup].pm_src, obj[F("val")], ZEROEXPORT_GROUP_MAX_LEN_PM_SRC);
|
||||
// strncpy(mCfg->groups[topicGroup].pm_src, String(obj[F("val")]).c_str(), ZEROEXPORT_GROUP_MAX_LEN_PM_SRC);
|
||||
// snprintf(mCfg->groups[topicGroup].pm_src, ZEROEXPORT_GROUP_MAX_LEN_PM_SRC, "%s", String(obj[F("val")]).c_str());
|
||||
// mLog["k"] = "ctrl/zero/groups/" + String(topicGroup) + "/pm_ip";
|
||||
// mLog["v"] = mCfg->groups[topicGroup].pm_url;
|
||||
// mLog["v"] = mCfg->groups[topicGroup].pm_src;
|
||||
// }
|
||||
//
|
||||
// // "topic":"ctrl/zero/groups/+/pm_jsonPath"
|
||||
|
|
|
@ -839,7 +839,7 @@ class RestApi {
|
|||
// Powermeter
|
||||
objGroup[F("pm_refresh")] = (uint8_t)mConfig->plugin.zeroExport.groups[group].pm_refresh;
|
||||
objGroup[F("pm_type")] = (uint8_t)mConfig->plugin.zeroExport.groups[group].pm_type;
|
||||
objGroup[F("pm_url")] = String(mConfig->plugin.zeroExport.groups[group].pm_url);
|
||||
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);
|
||||
|
@ -1159,7 +1159,7 @@ class RestApi {
|
|||
// Powermeter
|
||||
mConfig->plugin.zeroExport.groups[group].pm_refresh = jsonIn[F("pm_refresh")];
|
||||
mConfig->plugin.zeroExport.groups[group].pm_type = jsonIn[F("pm_type")];
|
||||
snprintf(mConfig->plugin.zeroExport.groups[group].pm_url, ZEROEXPORT_GROUP_MAX_LEN_PM_URL, "%s", jsonIn[F("pm_url")].as<const char*>());
|
||||
snprintf(mConfig->plugin.zeroExport.groups[group].pm_src, ZEROEXPORT_GROUP_MAX_LEN_PM_SRC, "%s", jsonIn[F("pm_src")].as<const char*>());
|
||||
snprintf(mConfig->plugin.zeroExport.groups[group].pm_jsonPath, ZEROEXPORT_GROUP_MAX_LEN_PM_JSONPATH, "%s", jsonIn[F("pm_jsonPath")].as<const char*>());
|
||||
snprintf(mConfig->plugin.zeroExport.groups[group].pm_user, ZEROEXPORT_GROUP_MAX_LEN_PM_USER, "%s", jsonIn[F("pm_user")].as<const char*>());
|
||||
snprintf(mConfig->plugin.zeroExport.groups[group].pm_pass, ZEROEXPORT_GROUP_MAX_LEN_PM_PASS, "%s", jsonIn[F("pm_pass")].as<const char*>());
|
||||
|
|
|
@ -1389,12 +1389,11 @@
|
|||
divRow("{#ZE_GROUP_TAB_POWERMETER_REFRESH}",
|
||||
ml("input", {name: "pm_refresh", class: "text", type: "number", min: "1", max: "30", step: "1", value: obj.pm_refresh}, null),
|
||||
),
|
||||
// TODO: URL -> IP
|
||||
divRow("{#ZE_GROUP_TAB_POWERMETER_TARGET}",
|
||||
ml("select", {name: "pm_target", class: "text", id: "pm_target"}, null),
|
||||
),
|
||||
divRow("{#ZE_GROUP_TAB_POWERMETER_IP}", [
|
||||
ml("input", {name: "pm_url", class: "text", type: "text", value: obj.pm_url, maxlength: "100"}, null),
|
||||
divRow("{#ZE_GROUP_TAB_POWERMETER_SRC}", [
|
||||
ml("input", {name: "pm_src", class: "text", type: "text", value: obj.pm_src, maxlength: "100"}, null),
|
||||
]),
|
||||
divRow("{#ZE_GROUP_TAB_POWERMETER_JSONPATH}", [
|
||||
ml("input", {name: "pm_jsonPath", class: "text", type: "text", value: obj.pm_jsonPath}, null),
|
||||
|
@ -1405,9 +1404,6 @@
|
|||
divRow("{#ZE_GROUP_TAB_POWERMETER_PASS}",
|
||||
ml("input", {name: "pm_pass", class: "text", type: "password", value: "****"}, null),
|
||||
),
|
||||
divRow("{#ZE_GROUP_TAB_POWERMETER_TOPIC}",
|
||||
ml("input", {id: 3, name: "pm_topic", class: "text", type: "text", value: ""}, 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üllhinweise in der Dokumentation."),
|
||||
|
@ -1514,7 +1510,6 @@
|
|||
|
||||
// add addEventListener
|
||||
const selectElement = document.querySelector("#pm_type");
|
||||
//selectElement.addEventListener("change", (event) => { pm_type_dropdown() });
|
||||
selectElement.addEventListener("change", (event) => { pm_type_dropdown() });
|
||||
|
||||
// run event one time
|
||||
|
@ -1580,21 +1575,27 @@
|
|||
|
||||
// Formular for Powermeter-DropDown
|
||||
// show all DIVs and remove only what is not necessary
|
||||
// 1 = pm_refresh, 2 = pm_target, 3 = pm_src, 4 = pm_jsonPath, 5 = pm_user, 6 = pm_pass
|
||||
for(var i = 0; i < divsToHide.childElementCount; i++) divsToHide.childNodes[i].style.display = '';
|
||||
|
||||
if(value == "---") for(var i = 1; i < divsToHide.childElementCount; i++) divsToHide.childNodes[i].style.display = 'none';
|
||||
else if(value == "Shelly") {
|
||||
divsToHide.childNodes[7].style.display = 'none';
|
||||
divsToHide.childNodes[5].style.display = 'none';
|
||||
divsToHide.childNodes[6].style.display = 'none';
|
||||
}
|
||||
else if(value == "Mqtt") {
|
||||
divsToHide.childNodes[3].style.display = 'none';
|
||||
divsToHide.childNodes[1].style.display = 'none';
|
||||
divsToHide.childNodes[2].style.display = 'none';
|
||||
divsToHide.childNodes[4].style.display = 'none';
|
||||
divsToHide.childNodes[5].style.display = 'none';
|
||||
divsToHide.childNodes[6].style.display = 'none';
|
||||
}
|
||||
else if(value == "Tibber") {
|
||||
divsToHide.childNodes[4].style.display = 'none';
|
||||
divsToHide.childNodes[7].style.display = 'none';
|
||||
}
|
||||
else if(value == "Shrdzm") {
|
||||
divsToHide.childNodes[1].style.display = 'none';
|
||||
divsToHide.childNodes[2].style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1611,7 +1612,7 @@
|
|||
o.pm_refresh = document.getElementsByName("pm_refresh")[0].value;
|
||||
var e = document.getElementsByName("pm_type")[0];
|
||||
o.pm_type = e.options[e.selectedIndex].value;
|
||||
o.pm_url = document.getElementsByName("pm_url")[0].value;
|
||||
o.pm_src = document.getElementsByName("pm_src")[0].value;
|
||||
o.pm_jsonPath = document.getElementsByName("pm_jsonPath")[0].value;
|
||||
o.pm_user = document.getElementsByName("pm_user")[0].value;
|
||||
o.pm_pass = document.getElementsByName("pm_pass")[0].value;
|
||||
|
@ -1678,7 +1679,7 @@
|
|||
// Powermeter
|
||||
o.pm_refresh = 5;
|
||||
o.pm_type = 0;
|
||||
o.pm_url = "";
|
||||
o.pm_src = "";
|
||||
o.pm_jsonPath = "";
|
||||
o.pm_user = "";
|
||||
o.pm_pass = "";
|
||||
|
|
|
@ -894,9 +894,9 @@
|
|||
"de": "Typ:"
|
||||
},
|
||||
{
|
||||
"token": "ZE_GROUP_TAB_POWERMETER_IP",
|
||||
"en": "IP:",
|
||||
"de": "IP:"
|
||||
"token": "ZE_GROUP_TAB_POWERMETER_SRC",
|
||||
"en": "IP / Topic:",
|
||||
"de": "IP / Topic:"
|
||||
},
|
||||
{
|
||||
"token": "ZE_GROUP_TAB_POWERMETER_JSONPATH",
|
||||
|
@ -913,11 +913,6 @@
|
|||
"en": "Password:",
|
||||
"de": "Passwort:"
|
||||
},
|
||||
{
|
||||
"token": "ZE_GROUP_TAB_POWERMETER_TOPIC",
|
||||
"en": "Topic:",
|
||||
"de": "Topic:"
|
||||
},
|
||||
{
|
||||
"token": "ZE_GROUP_TAB_POWERMETER_TARGET",
|
||||
"en": "Target:",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue