Compare commits

..

4 Commits

Author SHA1 Message Date
Gunnar Skjold
a5f872a86c More timezone adjustments after testing 2023-04-25 08:09:47 +02:00
Gunnar Skjold
6e8233e4af Fixed timestamp from meter 2023-04-24 15:46:56 +02:00
Gunnar Skjold
d85d68b4a6 Hide firmware upgrade when no upgrade 2023-04-24 15:46:34 +02:00
Gunnar Skjold
ed9cf4b87d Fixed NTP 2023-04-24 15:26:31 +02:00
8 changed files with 46 additions and 38 deletions

File diff suppressed because one or more lines are too long

View File

@@ -164,7 +164,7 @@
<div class="my-2 flex"> <div class="my-2 flex">
Latest version: Latest version:
<a href={nextVersion.html_url} class="ml-2 text-blue-600 hover:text-blue-800" target='_blank' rel="noreferrer">{nextVersion.tag_name}</a> <a href={nextVersion.html_url} class="ml-2 text-blue-600 hover:text-blue-800" target='_blank' rel="noreferrer">{nextVersion.tag_name}</a>
{#if (sysinfo.security == 0 || data.a) && sysinfo.fwconsent === 1 && nextVersion && nextVersion.tag_name} {#if (sysinfo.security == 0 || data.a) && sysinfo.fwconsent === 1 && nextVersion && nextVersion.tag_name != sysinfo.version}
<div class="flex-none ml-2 text-green-500" title="Install this version"> <div class="flex-none ml-2 text-green-500" title="Install this version">
<button on:click={askUpgrade}><DownloadIcon/></button> <button on:click={askUpgrade}><DownloadIcon/></button>
</div> </div>

View File

@@ -17,18 +17,18 @@ export default defineConfig({
plugins: [svelte()], plugins: [svelte()],
server: { server: {
proxy: { proxy: {
"/data.json": "http://192.168.233.244", "/data.json": "http://192.168.233.235",
"/energyprice.json": "http://192.168.233.244", "/energyprice.json": "http://192.168.233.235",
"/dayplot.json": "http://192.168.233.244", "/dayplot.json": "http://192.168.233.235",
"/monthplot.json": "http://192.168.233.244", "/monthplot.json": "http://192.168.233.235",
"/temperature.json": "http://192.168.233.244", "/temperature.json": "http://192.168.233.235",
"/sysinfo.json": "http://192.168.233.244", "/sysinfo.json": "http://192.168.233.235",
"/configuration.json": "http://192.168.233.244", "/configuration.json": "http://192.168.233.235",
"/tariff.json": "http://192.168.233.244", "/tariff.json": "http://192.168.233.235",
"/save": "http://192.168.233.244", "/save": "http://192.168.233.235",
"/reboot": "http://192.168.233.244", "/reboot": "http://192.168.233.235",
"/configfile": "http://192.168.233.244", "/configfile": "http://192.168.233.235",
"/upgrade": "http://192.168.233.244" "/upgrade": "http://192.168.233.235"
} }
} }
}) })

View File

@@ -32,7 +32,7 @@ lib_ignore = ${common.lib_ignore}
extra_scripts = ${common.extra_scripts} extra_scripts = ${common.extra_scripts}
[env:esp32] [env:esp32]
platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.02.00/platform-espressif32.zip platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.04.02/platform-espressif32.zip
framework = arduino framework = arduino
board = esp32dev board = esp32dev
board_build.f_cpu = 160000000L board_build.f_cpu = 160000000L
@@ -47,7 +47,7 @@ extra_scripts = ${common.extra_scripts}
# https://github.com/Jason2866/esp32-arduino-lib-builder # https://github.com/Jason2866/esp32-arduino-lib-builder
[env:esp32s2] [env:esp32s2]
platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.02.00/platform-espressif32.zip platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.04.02/platform-espressif32.zip
framework = arduino framework = arduino
board = esp32-s2-saola-1 board = esp32-s2-saola-1
board_build.mcu = esp32s2 board_build.mcu = esp32s2
@@ -63,7 +63,7 @@ lib_ignore = ${common.lib_ignore}
extra_scripts = ${common.extra_scripts} extra_scripts = ${common.extra_scripts}
[env:esp32solo] [env:esp32solo]
platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.02.00/platform-espressif32.zip platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.04.02/platform-espressif32.zip
framework = arduino framework = arduino
board = esp32-solo1 board = esp32-solo1
board_build.f_cpu = 160000000L board_build.f_cpu = 160000000L
@@ -75,7 +75,7 @@ lib_ignore = ${common.lib_ignore}
extra_scripts = ${common.extra_scripts} extra_scripts = ${common.extra_scripts}
[env:esp32c3] [env:esp32c3]
platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.02.00/platform-espressif32.zip platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.04.02/platform-espressif32.zip
framework = arduino framework = arduino
board = esp32-c3-devkitm-1 board = esp32-c3-devkitm-1
board_build.mcu = esp32c3 board_build.mcu = esp32c3

View File

@@ -96,7 +96,7 @@ RemoteDebug Debug;
EntsoeApi* eapi = NULL; EntsoeApi* eapi = NULL;
Timezone* tz; Timezone* tz = NULL;
AmsWebServer ws(commonBuffer, &Debug, &hw); AmsWebServer ws(commonBuffer, &Debug, &hw);
@@ -341,9 +341,6 @@ void setup() {
NtpConfig ntp; NtpConfig ntp;
if(config.getNtpConfig(ntp)) { if(config.getNtpConfig(ntp)) {
tz = resolveTimezone(ntp.timezone); tz = resolveTimezone(ntp.timezone);
configTime(tz->toLocal(0), tz->toLocal(JULY1970)-JULY1970, ntp.enable ? strlen(ntp.server) > 0 ? ntp.server : (char*) F("pool.ntp.org") : (char*) F("")); // Add NTP server by default if none is configured
sntp_servermode_dhcp(ntp.enable && ntp.dhcp ? 1 : 0);
ntpEnabled = ntp.enable;
ws.setTimezone(tz); ws.setTimezone(tz);
ds.setTimezone(tz); ds.setTimezone(tz);
ea.setTimezone(tz); ea.setTimezone(tz);
@@ -560,12 +557,21 @@ void handleEnergyAccountingChanged() {
config.ackEnergyAccountingChange(); config.ackEnergyAccountingChange();
} }
char ntpServerName[64] = "";
void handleNtpChange() { void handleNtpChange() {
NtpConfig ntp; NtpConfig ntp;
if(config.getNtpConfig(ntp)) { if(config.getNtpConfig(ntp)) {
tz = resolveTimezone(ntp.timezone); tz = resolveTimezone(ntp.timezone);
configTime(tz->toLocal(0), tz->toLocal(JULY1970)-JULY1970, ntp.enable ? strlen(ntp.server) > 0 ? ntp.server : (char*) F("pool.ntp.org") : (char*) F("")); // Add NTP server by default if none is configured if(ntp.enable && strlen(ntp.server) > 0) {
sntp_servermode_dhcp(ntp.enable && ntp.dhcp ? 1 : 0); strcpy(ntpServerName, ntp.server);
} else if(ntp.enable) {
strcpy(ntpServerName, "pool.ntp.org");
} else {
memset(ntpServerName, 0, 64);
}
configTime(tz->toLocal(0), tz->toLocal(JULY1970)-JULY1970, ntpServerName, "", "");
sntp_servermode_dhcp(ntp.enable && ntp.dhcp ? 1 : 0); // Not implemented on ESP32?
ntpEnabled = ntp.enable; ntpEnabled = ntp.enable;
ws.setTimezone(tz); ws.setTimezone(tz);
@@ -704,8 +710,8 @@ void rxerr(int err) {
if(err == 0) return; if(err == 0) return;
switch(err) { switch(err) {
case 1: case 1:
debugE_P(PSTR("Serial break error")); debugD_P(PSTR("Serial break"));
break; return;
case 2: case 2:
debugE_P(PSTR("Serial buffer overflow")); debugE_P(PSTR("Serial buffer overflow"));
rxBufferErrors++; rxBufferErrors++;
@@ -720,10 +726,10 @@ void rxerr(int err) {
debugE_P(PSTR("Serial FIFO overflow")); debugE_P(PSTR("Serial FIFO overflow"));
break; break;
case 4: case 4:
debugE_P(PSTR("Serial frame error")); debugW_P(PSTR("Serial frame error"));
break; break;
case 5: case 5:
debugE_P(PSTR("Serial parity error")); debugW_P(PSTR("Serial parity error"));
break; break;
} }
meterState.setLastError(90+err); meterState.setLastError(90+err);
@@ -1087,7 +1093,7 @@ bool readHanPort() {
data = new IEC6205675(payload, meterState.getMeterType(), &meterConfig, ctx); data = new IEC6205675(payload, meterState.getMeterType(), &meterConfig, ctx);
} }
} else if(ctx.type == DATA_TAG_DSMR) { } else if(ctx.type == DATA_TAG_DSMR) {
data = new IEC6205621(payload); data = new IEC6205621(payload, tz);
} }
len = 0; len = 0;

View File

@@ -1,6 +1,6 @@
#include "IEC6205621.h" #include "IEC6205621.h"
IEC6205621::IEC6205621(const char* p) { IEC6205621::IEC6205621(const char* p, Timezone* tz) {
if(strlen(p) < 16) if(strlen(p) < 16)
return; return;
@@ -58,7 +58,8 @@ IEC6205621::IEC6205621(const char* p) {
tm.Hour = timestamp.substring(6,8).toInt(); tm.Hour = timestamp.substring(6,8).toInt();
tm.Minute = timestamp.substring(8,10).toInt(); tm.Minute = timestamp.substring(8,10).toInt();
tm.Second = timestamp.substring(10,12).toInt(); tm.Second = timestamp.substring(10,12).toInt();
meterTimestamp = makeTime(tm); // TODO: Adjust for time zone meterTimestamp = makeTime(tm);
if(tz != NULL) meterTimestamp = tz->toUTC(meterTimestamp);
} }
activeImportPower = (uint16_t) (extractDouble(payload, F("1.7.0"))); activeImportPower = (uint16_t) (extractDouble(payload, F("1.7.0")));

View File

@@ -3,10 +3,11 @@
#include "Arduino.h" #include "Arduino.h"
#include "AmsData.h" #include "AmsData.h"
#include "Timezone.h"
class IEC6205621 : public AmsData { class IEC6205621 : public AmsData {
public: public:
IEC6205621(const char* payload); IEC6205621(const char* payload, Timezone* tz);
private: private:
String extract(String payload, String obis); String extract(String payload, String obis);

View File

@@ -168,8 +168,10 @@ IEC6205675::IEC6205675(const char* d, uint8_t useMeterType, MeterConfig* meterCo
} }
} }
if(meterType == AmsTypeKamstrup || meterType == AmsTypeAidon) { if(this->packageTimestamp > 0) {
this->packageTimestamp = this->packageTimestamp > 0 ? tz.toUTC(this->packageTimestamp) : 0; if(meterType == AmsTypeAidon || meterType == AmsTypeKamstrup) {
this->packageTimestamp = this->packageTimestamp - 3600;
}
} }
uint8_t str_len = 0; uint8_t str_len = 0;
@@ -270,10 +272,8 @@ IEC6205675::IEC6205675(const char* d, uint8_t useMeterType, MeterConfig* meterCo
if(meterTs != NULL) { if(meterTs != NULL) {
AmsOctetTimestamp* amst = (AmsOctetTimestamp*) meterTs; AmsOctetTimestamp* amst = (AmsOctetTimestamp*) meterTs;
time_t ts = decodeCosemDateTime(amst->dt); time_t ts = decodeCosemDateTime(amst->dt);
if(meterType == AmsTypeAidon) { if(meterType == AmsTypeAidon || meterType == AmsTypeKamstrup) {
meterTimestamp = ts - 3600; meterTimestamp = ts - 3600;
} else if(meterType == AmsTypeKamstrup) {
meterTimestamp = tz.toUTC(ts);
} else { } else {
meterTimestamp = ts; meterTimestamp = ts;
} }