diff --git a/scripts/makeweb.py b/scripts/makeweb.py index 69ca56e1..658f4ca4 100644 --- a/scripts/makeweb.py +++ b/scripts/makeweb.py @@ -59,8 +59,6 @@ for filename in os.listdir(webroot): try: if filename.endswith(".html"): content = html_minify(content) - if filename.endswith(".svg"): - content = html_minify(content) elif filename.endswith(".css"): content = css_minify(content) elif (filename.endswith(".js") and filename != 'gaugemeter.js') or filename.endswith(".json"): diff --git a/src/AmsToMqttBridge.ino b/src/AmsToMqttBridge.ino index 37a79433..a408506a 100644 --- a/src/AmsToMqttBridge.ino +++ b/src/AmsToMqttBridge.ino @@ -1662,7 +1662,7 @@ void configFileParse() { sDs = true; } else if(strncmp(buf, "energyaccounting ", 17) == 0) { uint8_t i = 0; - EnergyAccountingData ead = { 3, 0, + EnergyAccountingData ead = { 4, 0, 0, 0, 0, 0, 0, // Peak 1 0, 0, // Peak 2 @@ -1684,13 +1684,13 @@ void configFileParse() { } } else if(i == 3) { double val = String(pch).toDouble(); - ead.costYesterday = val * 100; + ead.costYesterday = val * 10; } else if(i == 4) { double val = String(pch).toDouble(); - ead.costThisMonth = val * 100; + ead.costThisMonth = val; } else if(i == 5) { double val = String(pch).toDouble(); - ead.costLastMonth = val * 100; + ead.costLastMonth = val; } else if(i >= 6 && i < 18) { uint8_t hour = i-6; if(hour%2 == 0) { diff --git a/src/EnergyAccounting.cpp b/src/EnergyAccounting.cpp index 1262a07d..75cdd07d 100644 --- a/src/EnergyAccounting.cpp +++ b/src/EnergyAccounting.cpp @@ -45,7 +45,7 @@ bool EnergyAccounting::update(AmsData* amsData) { if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EnergyAccounting) Initializing data at %lld\n", (int64_t) now); if(!load()) { if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EnergyAccounting) Unable to load existing data\n"); - data = { 3, local.Month, + data = { 4, local.Month, 0, 0, 0, 0, 0, // Peak 1 0, 0, // Peak 2 @@ -57,7 +57,7 @@ bool EnergyAccounting::update(AmsData* amsData) { for(uint8_t i = 0; i < 5; i++) { debugger->printf("(EnergyAccounting) Peak hour from day %d: %d\n", data.peaks[i].day, data.peaks[i].value*10); } - debugger->printf("(EnergyAccounting) Loaded cost yesterday: %d, this month: %d, last month: %d\n", data.costYesterday, data.costThisMonth, data.costLastMonth); + debugger->printf("(EnergyAccounting) Loaded cost yesterday: %d, this month: %d, last month: %d\n", data.costYesterday / 10.0, data.costThisMonth, data.costLastMonth); } init = true; } @@ -85,8 +85,8 @@ bool EnergyAccounting::update(AmsData* amsData) { if(local.Day != currentDay) { if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EnergyAccounting) New day %d\n", local.Day); - data.costYesterday = costDay * 100; - data.costThisMonth += costDay * 100; + data.costYesterday = costDay * 10; + data.costThisMonth += costDay; costDay = 0; currentDay = local.Day; ret = true; @@ -173,7 +173,7 @@ double EnergyAccounting::getCostToday() { } double EnergyAccounting::getCostYesterday() { - return data.costYesterday / 100.0; + return data.costYesterday / 10.0; } double EnergyAccounting::getUseThisMonth() { @@ -192,11 +192,11 @@ double EnergyAccounting::getUseThisMonth() { } double EnergyAccounting::getCostThisMonth() { - return (data.costThisMonth / 100.0) + getCostToday(); + return data.costThisMonth + getCostToday(); } -double EnergyAccounting::getCostLastMonth() { - return data.costLastMonth / 100.0; +uint16_t EnergyAccounting::getCostLastMonth() { + return data.costLastMonth; } uint8_t EnergyAccounting::getCurrentThreshold() { @@ -248,12 +248,22 @@ bool EnergyAccounting::load() { file.readBytes(buf, file.size()); if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EnergyAccounting) Data version %d\n", buf[0]); - if(buf[0] == 3) { + if(buf[0] == 4) { EnergyAccountingData* data = (EnergyAccountingData*) buf; memcpy(&this->data, data, sizeof(this->data)); + } else if(buf[0] == 3) { + EnergyAccountingData* data = (EnergyAccountingData*) buf; + this->data = { 4, data->month, + (uint16_t) (data->costYesterday / 10), (uint16_t) (data->costThisMonth / 100), (uint16_t) (data->costLastMonth / 100), + data->peaks[0].day, data->peaks[0].value, + data->peaks[1].day, data->peaks[1].value, + data->peaks[2].day, data->peaks[2].value, + data->peaks[3].day, data->peaks[3].value, + data->peaks[4].day, data->peaks[4].value + }; ret = true; } else { - data = { 3, 0, + data = { 4, 0, 0, 0, 0, 0, 0, // Peak 1 0, 0, // Peak 2 @@ -264,9 +274,9 @@ bool EnergyAccounting::load() { if(buf[0] == 2) { EnergyAccountingData1* data = (EnergyAccountingData1*) buf; this->data.month = data->month; - this->data.costYesterday = data->costYesterday; - this->data.costThisMonth = data->costThisMonth; - this->data.costLastMonth = data->costLastMonth; + this->data.costYesterday = (uint16_t) (data->costYesterday / 10); + this->data.costThisMonth = (uint16_t) (data->costThisMonth / 100); + this->data.costLastMonth = (uint16_t) (data->costLastMonth / 100); uint8_t b = 0; for(uint8_t i = sizeof(this->data); i < file.size(); i+=2) { this->data.peaks[b].day = b; @@ -278,9 +288,9 @@ bool EnergyAccounting::load() { } else if(buf[0] == 1) { EnergyAccountingData1* data = (EnergyAccountingData1*) buf; this->data.month = data->month; - this->data.costYesterday = data->costYesterday; - this->data.costThisMonth = data->costThisMonth; - this->data.costLastMonth = data->costLastMonth; + this->data.costYesterday = (uint16_t) (data->costYesterday / 10); + this->data.costThisMonth = (uint16_t) (data->costThisMonth / 100); + this->data.costLastMonth = (uint16_t) (data->costLastMonth / 100); this->data.peaks[0].day = 1; this->data.peaks[0].value = data->maxHour; ret = true; diff --git a/src/EnergyAccounting.h b/src/EnergyAccounting.h index a6a8266d..96c82a2d 100644 --- a/src/EnergyAccounting.h +++ b/src/EnergyAccounting.h @@ -48,7 +48,7 @@ public: double getCostYesterday(); double getUseThisMonth(); double getCostThisMonth(); - double getCostLastMonth(); + uint16_t getCostLastMonth(); float getMonthMax(); uint8_t getCurrentThreshold(); diff --git a/src/web/AmsWebServer.cpp b/src/web/AmsWebServer.cpp index 3a634b75..bf5f2652 100644 --- a/src/web/AmsWebServer.cpp +++ b/src/web/AmsWebServer.cpp @@ -1073,6 +1073,14 @@ void AmsWebServer::handleSetup() { gpioConfig->ledPin = 2; gpioConfig->ledInverted = false; break; + case 50: // S2 + gpioConfig->hanPin = 18; + break; + case 51: // S2-mini + gpioConfig->hanPin = 18; + gpioConfig->ledPin = 15; + gpioConfig->ledInverted = false; + break; } WiFiConfig wifi; @@ -2421,9 +2429,9 @@ void AmsWebServer::configFileDownload() { ead.version, ead.month, 0.0, // Old max - ead.costYesterday / 100.0, - ead.costThisMonth / 100.0, - ead.costLastMonth / 100.0, + ead.costYesterday / 10.0, + ead.costThisMonth / 1.0, + ead.costLastMonth / 1.0, ead.peaks[0].day, ead.peaks[0].value / 100.0, ead.peaks[1].day, diff --git a/web/head.html b/web/head.html index 5ea5f361..343c3c8f 100644 --- a/web/head.html +++ b/web/head.html @@ -63,7 +63,7 @@ MQTT Web NTP - ENTSO-E API + ENTSO-E API
Documentation diff --git a/web/setup.html b/web/setup.html index ec1ad2fe..d8028281 100644 --- a/web/setup.html +++ b/web/setup.html @@ -41,7 +41,11 @@ - + +