Fixed timelib

This commit is contained in:
Gunnar Skjold 2021-12-18 15:20:15 +01:00
parent aa893f7ede
commit 8adf591c4e
6 changed files with 34 additions and 8 deletions

View File

@ -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]

View File

@ -1,7 +1,7 @@
#include "EntsoeApi.h"
#include <EEPROM.h>
#include "Uptime.h"
#include "Time.h"
#include "TimeLib.h"
#include "DnbCurrParser.h"
#if defined(ESP8266)

View File

@ -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");

View File

@ -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);

View File

@ -30,5 +30,6 @@
"wm" : %d,
"mm" : %d,
"me" : %d,
"p" : %s
"p" : %s,
"c" : %lu
}

View File

@ -3,10 +3,10 @@
<div class="col-md-2 col-6">
<div class="text-center">Up <span class="ju">{cs}</span></div>
</div>
<div class="col-md-3 col-6">
<div class="col-md-3 col-6 rt ">
<div class="text-center">Temperature: <span class="jt">{temp}</span>&deg;C</div>
</div>
<div class="col-md-2 col-6">
<div class="col-md-2 col-6 rv">
<div class="text-center">ESP volt: <span class="jv">{vcc}</span>V</div>
</div>
<div class="col-md-3 col-6">
@ -15,6 +15,9 @@
<div class="col-md-2 col-6">
<div class="text-center">Free mem: <span class="jm">{mem}</span>kb</div>
</div>
<div class="col-md-3 col-6 rc">
<div class="text-center"><span class="jc"></span></div>
</div>
</div>
</div>