diff --git a/src/plugins/zeroExport/powermeter.h b/src/plugins/zeroExport/powermeter.h index 780005bc..3457aef0 100644 --- a/src/plugins/zeroExport/powermeter.h +++ b/src/plugins/zeroExport/powermeter.h @@ -14,7 +14,6 @@ #include "config/settings.h" #if defined(ZEROEXPORT_POWERMETER_TIBBER) -#include #include #include @@ -493,16 +492,7 @@ class powermeter { logObj["mod"] = "getPowermeterWattsTibber"; - String auth; - if (strlen(mCfg->groups[group].pm_user) > 0 && strlen(mCfg->groups[group].pm_pass) > 0) { - auth = base64::encode(String(mCfg->groups[group].pm_user) + String(":") + String(mCfg->groups[group].pm_pass)); - snprintf(mCfg->groups[group].pm_user, ZEROEXPORT_GROUP_MAX_LEN_PM_USER, "%s", DEF_ZEXPORT); - snprintf(mCfg->groups[group].pm_pass, ZEROEXPORT_GROUP_MAX_LEN_PM_PASS, "%s", auth.c_str()); - //@TODO:mApp->saveSettings(false); - } else { - auth = mCfg->groups[group].pm_pass; - } - + String auth = mCfg->groups[group].pm_pass; String url = String("http://") + mCfg->groups[group].pm_url + String("/") + String(mCfg->groups[group].pm_jsonPath); setHeader(&http); diff --git a/src/web/RestApi.h b/src/web/RestApi.h index 21123be6..602c8843 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -20,6 +20,7 @@ #include "ESPAsyncWebServer.h" #include "plugins/history.h" +#include #if defined(F) && defined(ESP32) #undef F @@ -1161,8 +1162,15 @@ class RestApi { 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()); snprintf(mConfig->plugin.zeroExport.groups[group].pm_jsonPath, ZEROEXPORT_GROUP_MAX_LEN_PM_JSONPATH, "%s", jsonIn[F("pm_jsonPath")].as()); - snprintf(mConfig->plugin.zeroExport.groups[group].pm_user, ZEROEXPORT_GROUP_MAX_LEN_PM_USER, "%s", jsonIn[F("pm_user")].as()); - snprintf(mConfig->plugin.zeroExport.groups[group].pm_pass, ZEROEXPORT_GROUP_MAX_LEN_PM_PASS, "%s", jsonIn[F("pm_pass")].as()); + + + if (jsonIn[F("pm_pass")] != F("****")) + { + String auth = base64::encode(String(jsonIn[F("pm_user")]) + String(":") + String(jsonIn[F("pm_pass")])); + snprintf(mConfig->plugin.zeroExport.groups[group].pm_user, ZEROEXPORT_GROUP_MAX_LEN_PM_USER, "%s", String(jsonIn[F("pm_user")]).c_str()); + snprintf(mConfig->plugin.zeroExport.groups[group].pm_pass, ZEROEXPORT_GROUP_MAX_LEN_PM_PASS, "%s", auth.c_str()); + } + mConfig->plugin.zeroExport.groups[group].pm_target = jsonIn[F("pm_target")]; // Inverters for(uint8_t inv = 0; inv < ZEROEXPORT_GROUP_MAX_INVERTERS; inv++) { diff --git a/src/web/html/setup.html b/src/web/html/setup.html index 761e9f42..7cc49b5d 100644 --- a/src/web/html/setup.html +++ b/src/web/html/setup.html @@ -1400,7 +1400,7 @@ ml("input", {name: "pm_jsonPath", class: "text", type: "text", value: obj.pm_jsonPath}, null), ]), divRow("{#ZE_GROUP_TAB_POWERMETER_USER}", - ml("input", {name: "pm_user", class: "text", type: "text", value: "" }, null), + ml("input", {name: "pm_user", class: "text", type: "text", value: obj.pm_user }, null), ), divRow("{#ZE_GROUP_TAB_POWERMETER_PASS}", ml("input", {name: "pm_pass", class: "text", type: "password", value: "****"}, null),