diff --git a/doc/Denmark/Kamstrup_encrypted_OBIS.txt b/doc/Denmark/Kamstrup_encrypted_OBIS.txt index 50bd7aff..bbfe1038 100644 --- a/doc/Denmark/Kamstrup_encrypted_OBIS.txt +++ b/doc/Denmark/Kamstrup_encrypted_OBIS.txt @@ -2,7 +2,7 @@ 1.1.2.8.0.255 - Active- Energy 1.1.3.8.0.255 - Reactive+ Energy 1.1.4.8.0.255 - Reactive- Energy -1.1.0.0.1.255 - Electricity ID? +1.1.0.0.1.255 - Meter number 1 1.1.1.7.0.255 - Active+ Instantaneous value 1.1.2.7.0.255 - Active- Instantaneous value 1.1.3.7.0.255 - Reactive+ Instantaneous value diff --git a/doc/omnipower.technical.description.pdf b/doc/omnipower.technical.description.pdf new file mode 100644 index 00000000..d15790c2 Binary files /dev/null and b/doc/omnipower.technical.description.pdf differ diff --git a/src/AmsData.h b/src/AmsData.h index 0f8c87df..05d506f3 100644 --- a/src/AmsData.h +++ b/src/AmsData.h @@ -69,7 +69,7 @@ protected: String listId, meterId, meterModel; time_t meterTimestamp = 0; uint16_t activeImportPower = 0, reactiveImportPower = 0, activeExportPower = 0, reactiveExportPower = 0; - float l1voltage = 0, l2voltage = 0, l3voltage = 0, l1current = 0, l2current = 0, l3current = 0; + double l1voltage = 0, l2voltage = 0, l3voltage = 0, l1current = 0, l2current = 0, l3current = 0; float powerFactor = 0, l1PowerFactor = 0, l2PowerFactor = 0, l3PowerFactor = 0; float activeImportCounter = 0, reactiveImportCounter = 0, activeExportCounter = 0, reactiveExportCounter = 0; bool threePhase = false, twoPhase = false, counterEstimated = false; diff --git a/src/AmsDataStorage.cpp b/src/AmsDataStorage.cpp index e274ffb0..4269cfd3 100644 --- a/src/AmsDataStorage.cpp +++ b/src/AmsDataStorage.cpp @@ -226,7 +226,7 @@ void AmsDataStorage::setHour(uint8_t hour, int32_t val) { day.points[hour] = val / 10; } -int16_t AmsDataStorage::getHour(uint8_t hour) { +int32_t AmsDataStorage::getHour(uint8_t hour) { if(hour < 0 || hour > 24) return 0; return day.points[hour] * 10; } diff --git a/src/AmsDataStorage.h b/src/AmsDataStorage.h index 6e6bcc4a..e49be34b 100644 --- a/src/AmsDataStorage.h +++ b/src/AmsDataStorage.h @@ -28,7 +28,7 @@ public: AmsDataStorage(RemoteDebug*); void setTimezone(Timezone*); bool update(AmsData*); - int16_t getHour(uint8_t); + int32_t getHour(uint8_t); int32_t getDay(uint8_t); bool load(); bool save(); diff --git a/src/AmsToMqttBridge.ino b/src/AmsToMqttBridge.ino index c77be649..c3f40306 100644 --- a/src/AmsToMqttBridge.ino +++ b/src/AmsToMqttBridge.ino @@ -18,7 +18,7 @@ ADC_MODE(ADC_VCC); #if defined(ESP32) #include #endif -#define WDT_TIMEOUT 30 +#define WDT_TIMEOUT 60 #include "AmsToMqttBridge.h" #include "AmsStorage.h" diff --git a/src/IEC6205675.cpp b/src/IEC6205675.cpp index 6eb8e177..d1501d12 100644 --- a/src/IEC6205675.cpp +++ b/src/IEC6205675.cpp @@ -312,6 +312,17 @@ IEC6205675::IEC6205675(const char* d, uint8_t useMeterType, uint8_t distribution l2PowerFactor /= 100; if(l3PowerFactor != 0) l3PowerFactor /= 100; + + int adiv = 1; + int watt = abs((l1voltage * l1current) + (l2voltage * l2current) + (l3voltage * l3current)); + while(watt / (activeImportPower + activeExportPower + reactiveImportPower + reactiveExportPower) > 2) { + adiv *= 10; + watt /= 10; + } + + l1current = l1current != 0 ? l1current / adiv : 0; + l2current = l2current != 0 ? l2current / adiv : 0; + l3current = l3current != 0 ? l3current / adiv : 0; } else if(meterType == AmsTypeSagemcom) { CosemData* meterTs = getCosemDataAt(1, ((char *) (d))); if(meterTs != NULL) { @@ -348,7 +359,7 @@ IEC6205675::IEC6205675(const char* d, uint8_t useMeterType, uint8_t distribution if(l2current == 0.0 && l1current > 0.0 && l3current > 0.0) { l2current = (((activeImportPower - activeExportPower) * sqrt(3)) - (l1voltage * l1current) - (l3voltage * l3current)) / l2voltage; if(activeExportPower == 0.0) { - l2current = max((float) 0.0, l2current); + l2current = max((double) 0.0, l2current); } } } else if(twoPhase && l1current > 0.0 && l2current > 0.0 && l3current > 0.0) { diff --git a/src/ams/hdlc.cpp b/src/ams/hdlc.cpp index d9db24ca..a609683d 100644 --- a/src/ams/hdlc.cpp +++ b/src/ams/hdlc.cpp @@ -268,7 +268,7 @@ int HDLC_validate(const uint8_t* d, int length, HDLCConfig* config, CosemDateTim } else if(dateTime->base.type == CosemTypeDateTime) { memcpy(timestamp, ptr, dateTime->base.length); } else if(dateTime->base.type == 0x0C) { // Kamstrup bug... - memcpy(timestamp, ptr, 0x0C); + memcpy(timestamp, ptr, 13); ptr += 13; } else { return HDLC_TIMESTAMP_UNKNOWN; diff --git a/src/entsoe/EntsoeApi.cpp b/src/entsoe/EntsoeApi.cpp index 8aeddfff..21321287 100644 --- a/src/entsoe/EntsoeApi.cpp +++ b/src/entsoe/EntsoeApi.cpp @@ -13,7 +13,7 @@ EntsoeApi::EntsoeApi(RemoteDebug* Debug) { client.setInsecure(); https.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS); - https.setTimeout(20000); + https.setTimeout(50000); // Entso-E uses CET/CEST TimeChangeRule CEST = {"CEST", Last, Sun, Mar, 2, 120}; diff --git a/web/application.js b/web/application.js index 2b45092e..0954de22 100644 --- a/web/application.js +++ b/web/application.js @@ -728,19 +728,19 @@ var fetch = function() { var a = 0; var r = 1; var arr = [['Phase', 'Amperage', { role: 'style' }, { role: 'annotation' }]]; - if(json.i1) { + if(json.i1 || json.u1) { var i1 = parseFloat(json.i1); a = Math.max(a, i1); var pct = (parseFloat(json.i1)/parseInt(json.mf))*100; arr[r++] = ['L1', pct, "color: " + ampcol(pct) + ";opacity: 0.9;", i1 + "A"]; } - if(json.i2) { + if(json.i2 || json.u2) { var i2 = parseFloat(json.i2); a = Math.max(a, i2); var pct = (parseFloat(json.i2)/parseInt(json.mf))*100; arr[r++] = ['L2', pct, "color: " + ampcol(pct) + ";opacity: 0.9;", i2 + "A"]; } - if(json.i3) { + if(json.i3 || json.u3) { var i3 = parseFloat(json.i3); a = Math.max(a, i3); var pct = (parseFloat(json.i3)/parseInt(json.mf))*100; diff --git a/web/index.html b/web/index.html index 12d78349..f9022c90 100644 --- a/web/index.html +++ b/web/index.html @@ -44,8 +44,8 @@
- {PO} - W + {PO} + W
Export