Skip to content

Commit

Permalink
Fixed threshold update via config file
Browse files Browse the repository at this point in the history
  • Loading branch information
gskjold committed Oct 21, 2022
1 parent bfee2a1 commit c38c305
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/AmsToMqttBridge.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/web/AmsWebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit c38c305

Please sign in to comment.