From 8adf591c4ec4ab0ffe7894693c134a7d8ae54327 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Sat, 18 Dec 2021 15:20:15 +0100 Subject: [PATCH] Fixed timelib --- platformio.ini | 2 +- src/entsoe/EntsoeApi.cpp | 2 +- src/web/AmsWebServer.cpp | 7 ++++--- web/application.js | 21 +++++++++++++++++++++ web/data.json | 3 ++- web/index.html | 7 +++++-- 6 files changed, 34 insertions(+), 8 deletions(-) diff --git a/platformio.ini b/platformio.ini index 8d72eace..28a2d49a 100755 --- a/platformio.ini +++ b/platformio.ini @@ -2,7 +2,7 @@ extra_configs = platformio-user.ini [common] -lib_deps = file://lib/Timezone, 256dpi/MQTT@2.5.0, OneWireNg@0.10.0, DallasTemperature@3.9.1, EspSoftwareSerial@6.14.1, https://github.com/gskjold/RemoteDebug.git, Time@1.6.0 +lib_deps = file://lib/Timezone, 256dpi/MQTT@2.5.0, OneWireNg@0.10.0, DallasTemperature@3.9.1, EspSoftwareSerial@6.14.1, https://github.com/gskjold/RemoteDebug.git, Time@1.6.1 lib_ignore = OneWire [env:esp8266] diff --git a/src/entsoe/EntsoeApi.cpp b/src/entsoe/EntsoeApi.cpp index ff0c0618..12b4e2a1 100644 --- a/src/entsoe/EntsoeApi.cpp +++ b/src/entsoe/EntsoeApi.cpp @@ -1,7 +1,7 @@ #include "EntsoeApi.h" #include #include "Uptime.h" -#include "Time.h" +#include "TimeLib.h" #include "DnbCurrParser.h" #if defined(ESP8266) diff --git a/src/web/AmsWebServer.cpp b/src/web/AmsWebServer.cpp index e14cd4b3..5e147c53 100644 --- a/src/web/AmsWebServer.cpp +++ b/src/web/AmsWebServer.cpp @@ -691,7 +691,7 @@ void AmsWebServer::dataJson() { uint8_t espStatus; #if defined(ESP8266) if(vcc == 0) { - espStatus = 0; + espStatus = 1; } else if(vcc > 3.1 && vcc < 3.5) { espStatus = 1; } else if(vcc > 3.0 && vcc < 3.6) { @@ -701,7 +701,7 @@ void AmsWebServer::dataJson() { } #elif defined(ESP32) if(vcc == 0) { - espStatus = 0; + espStatus = 1; } else if(vcc > 2.8 && vcc < 3.5) { espStatus = 1; } else if(vcc > 2.2 && vcc < 3.6) { @@ -780,7 +780,8 @@ void AmsWebServer::dataJson() { wifiStatus, mqttStatus, mqtt == NULL ? 0 : (int) mqtt->lastError(), - price == ENTSOE_NO_VALUE ? "null" : String(price, 2).c_str() + price == ENTSOE_NO_VALUE ? "null" : String(price, 2).c_str(), + time(nullptr) ); server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate"); diff --git a/web/application.js b/web/application.js index 03968efc..b01fe559 100644 --- a/web/application.js +++ b/web/application.js @@ -670,7 +670,28 @@ var fetch = function() { var temp = parseInt(json.t); if(temp == -127) { $('.jt').html("N/A"); + $('.rt').hide(); + } else { + $('.rt').show(); } + + var vcc = parseFloat(json.v); + if(vcc > 0.0) { + $('.rv').show(); + } else { + $('.rv').hide(); + } + + var unixtime = moment().unix(); + var ts = parseInt(json.c); + if(Math.abs(unixtime-ts) < 300) { + $('.jc').html(moment(ts * 1000).format('DD. MMM HH:mm')); + $('.jc').removeClass('text-danger'); + } else { + $('.jc').html(moment(ts * 1000).format('DD.MM.YYYY HH:mm')); + $('.jc').addClass('text-danger'); + } + setTimeout(fetch, interval); var price = parseFloat(json.p); diff --git a/web/data.json b/web/data.json index e23702b9..6de2c486 100644 --- a/web/data.json +++ b/web/data.json @@ -30,5 +30,6 @@ "wm" : %d, "mm" : %d, "me" : %d, - "p" : %s + "p" : %s, + "c" : %lu } \ No newline at end of file diff --git a/web/index.html b/web/index.html index 4a06243c..0789d9b2 100644 --- a/web/index.html +++ b/web/index.html @@ -3,10 +3,10 @@
Up {cs}
-
+
Temperature: {temp}°C
-
+
ESP volt: {vcc}V
@@ -15,6 +15,9 @@
Free mem: {mem}kb
+
+
+