Skip to content

Commit

Permalink
changes tibber things
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielR92 committed May 12, 2024
1 parent 05978a0 commit d1535ea
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
12 changes: 1 addition & 11 deletions src/plugins/zeroExport/powermeter.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "config/settings.h"

#if defined(ZEROEXPORT_POWERMETER_TIBBER)
#include <base64.h>
#include <string.h>

#include <list>
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 10 additions & 2 deletions src/web/RestApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "ESPAsyncWebServer.h"

#include "plugins/history.h"
#include <base64.h>

#if defined(F) && defined(ESP32)
#undef F
Expand Down Expand Up @@ -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<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*>());


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++) {
Expand Down
2 changes: 1 addition & 1 deletion src/web/html/setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit d1535ea

Please sign in to comment.