Compare commits

...

3 Commits

Author SHA1 Message Date
Gunnar Skjold
9d902c63de Fixed NPE 2023-05-22 12:51:26 +02:00
Gunnar Skjold
a57405a7a5 Fixed NaN in clock 2023-05-22 10:26:12 +02:00
Gunnar Skjold
550d32ee33 Fixed issue with new device 2023-05-22 09:55:15 +02:00
6 changed files with 13 additions and 14 deletions

View File

@@ -577,6 +577,11 @@ bool AmsDataStorage::isHappy() {
}
bool AmsDataStorage::isDayHappy() {
if(tz == NULL) {
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(AmsDataStorage) Timezone is missing\n"));
return false;
}
time_t now = time(nullptr);
if(now < FirmwareVersion::BuildEpoch) return false;

View File

@@ -179,6 +179,7 @@ bool EnergyAccounting::update(AmsData* amsData) {
void EnergyAccounting::calcDayCost() {
time_t now = time(nullptr);
tmElements_t local, utc;
if(tz == NULL) return;
breakTime(tz->toLocal(now), local);
if(getPriceForHour(0) != ENTSOE_NO_VALUE) {
@@ -205,10 +206,10 @@ float EnergyAccounting::getUseThisHour() {
}
float EnergyAccounting::getUseToday() {
if(tz == NULL) return 0.0;
float ret = 0.0;
time_t now = time(nullptr);
if(now < FirmwareVersion::BuildEpoch) return 0.0;
if(tz == NULL) return 0.0;
tmElements_t utc, local;
breakTime(tz->toLocal(now), local);
for(uint8_t i = 0; i < currentHour; i++) {
@@ -237,6 +238,7 @@ float EnergyAccounting::getProducedThisHour() {
}
float EnergyAccounting::getProducedToday() {
if(tz == NULL) return 0.0;
float ret = 0.0;
time_t now = time(nullptr);
if(now < FirmwareVersion::BuildEpoch) return 0.0;

File diff suppressed because one or more lines are too long

View File

@@ -6,10 +6,10 @@
export let offset;
let showFull;
let adjusteTimestamp;
$:{
showFull = Math.abs(new Date().getTime()-timestamp.getTime()) < 300000;
addHours(timestamp, offset);
if(!isNaN(offset))
addHours(timestamp, offset);
}
</script>

View File

@@ -329,7 +329,7 @@ void AmsWebServer::sysinfoJson() {
ea->getCostLastMonth(),
ea->getProducedLastMonth(),
ea->getIncomeLastMonth(),
(tz->toLocal(now)-now)/3600
tz == NULL ? 0 : (tz->toLocal(now)-now)/3600
);
stripNonAscii((uint8_t*) buf, size+1);

View File

@@ -387,15 +387,7 @@ void setup() {
if(config.hasConfig()) {
if(Debug.isActive(RemoteDebug::INFO)) config.print(&Debug);
WiFi_connect();
NtpConfig ntp;
if(config.getNtpConfig(ntp)) {
tz = resolveTimezone(ntp.timezone);
ws.setTimezone(tz);
ds.setTimezone(tz);
ea.setTimezone(tz);
}
handleNtpChange();
ds.load();
} else {
if(Debug.isActive(RemoteDebug::INFO)) {