From c38c305bab6d4b6d26bbfd49df300c5461332d78 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Fri, 21 Oct 2022 19:21:55 +0200 Subject: [PATCH] Fixed threshold update via config file --- src/AmsToMqttBridge.ino | 4 +++- src/web/AmsWebServer.cpp | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/AmsToMqttBridge.ino b/src/AmsToMqttBridge.ino index 3dda8f0b..bfc9a6d8 100644 --- a/src/AmsToMqttBridge.ino +++ b/src/AmsToMqttBridge.ino @@ -1635,10 +1635,11 @@ void configFileParse() { if(!lEac) { config.getEnergyAccountingConfig(eac); lEac = true; }; int i = 0; char * pch = strtok (buf+11," "); - while (pch != NULL) { + while (pch != NULL && i < 10) { eac.thresholds[i++] = String(pch).toInt(); pch = strtok (NULL, " "); } + eac.hours = String(pch).toInt(); } else if(strncmp_P(buf, PSTR("dayplot "), 8) == 0) { int i = 0; DayDataPoints day = { 4 }; // Use a version we know the multiplier of the data points @@ -1750,6 +1751,7 @@ void configFileParse() { if(lDomo) config.setDomoticzConfig(domo); if(lNtp) config.setNtpConfig(ntp); if(lEntsoe) config.setEntsoeConfig(entsoe); + if(lEac) config.setEnergyAccountingConfig(eac); if(sDs) ds.save(); if(sEa) ea.save(); config.save(); diff --git a/src/web/AmsWebServer.cpp b/src/web/AmsWebServer.cpp index b219fbc3..850a2090 100644 --- a/src/web/AmsWebServer.cpp +++ b/src/web/AmsWebServer.cpp @@ -2136,7 +2136,7 @@ void AmsWebServer::configFileDownload() { bool includeDomo = server.hasArg(F("id")) && server.arg(F("id")) == F("true"); bool includeNtp = server.hasArg(F("in")) && server.arg(F("in")) == F("true"); bool includeEntsoe = server.hasArg(F("is")) && server.arg(F("is")) == F("true"); - bool includeThresholds = server.hasArg(F("nh")) && server.arg(F("nh")) == F("true"); + bool includeThresholds = server.hasArg(F("ih")) && server.arg(F("ih")) == F("true"); SystemConfig sys; config->getSystemConfig(sys); @@ -2439,7 +2439,7 @@ void AmsWebServer::configFileDownload() { server.sendContent(buf, snprintf_P(buf, BufferSize, PSTR("energyaccounting %d %d %.2f %.2f %.2f %.2f %d %.2f %d %.2f %d %.2f %d %.2f %d %.2f"), ead.version, ead.month, - 0.0, // Old max + 0.0, ead.costYesterday / 10.0, ead.costThisMonth / 1.0, ead.costLastMonth / 1.0,