From dbb3eac7093e229d16a617e67117414070429c04 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Sun, 15 Jan 2023 10:56:46 +0100 Subject: [PATCH] Some changes for L&G --- lib/SvelteUi/app/src/lib/Helpers.js | 4 +++- src/LNG.cpp | 12 ++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/SvelteUi/app/src/lib/Helpers.js b/lib/SvelteUi/app/src/lib/Helpers.js index 36a9490c..e5a3e57f 100644 --- a/lib/SvelteUi/app/src/lib/Helpers.js +++ b/lib/SvelteUi/app/src/lib/Helpers.js @@ -31,9 +31,11 @@ export function metertype(mt) { case 8: return "Iskra"; case 9: - return "Landis"; + return "Landis+Gyr"; case 10: return "Sagemcom"; + case 11: + return "L&G"; default: return ""; } diff --git a/src/LNG.cpp b/src/LNG.cpp index e7d818d3..452dcdae 100644 --- a/src/LNG.cpp +++ b/src/LNG.cpp @@ -26,6 +26,7 @@ LNG::LNG(const char* payload, uint8_t useMeterType, MeterConfig* meterConfig, Da if(descriptor->obis[3] == 7) { if(descriptor->obis[4] == 0) { o170 = getNumber(item); + listType = listType >= 1 ? listType : 1; if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf(" and value %lu", o170); } } else if(descriptor->obis[3] == 8) { @@ -36,9 +37,11 @@ LNG::LNG(const char* payload, uint8_t useMeterType, MeterConfig* meterConfig, Da activeImportCounter = o180 / 1000.0; } else if(descriptor->obis[4] == 1) { o181 = getNumber(item); + listType = listType >= 3 ? listType : 3; if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf(" and value %lu", o181); } else if(descriptor->obis[4] == 2) { o182 = getNumber(item); + listType = listType >= 3 ? listType : 3; if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf(" and value %lu", o182); } } @@ -46,6 +49,7 @@ LNG::LNG(const char* payload, uint8_t useMeterType, MeterConfig* meterConfig, Da if(descriptor->obis[3] == 7) { if(descriptor->obis[4] == 0) { o270 = getNumber(item); + listType = listType >= 2 ? listType : 2; if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf(" and value %lu", o270); } } else if(descriptor->obis[3] == 8) { @@ -56,9 +60,11 @@ LNG::LNG(const char* payload, uint8_t useMeterType, MeterConfig* meterConfig, Da activeExportCounter = o280 / 1000.0; } else if(descriptor->obis[4] == 1) { o281 = getNumber(item); + listType = listType >= 3 ? listType : 3; if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf(" and value %lu", o281); } else if(descriptor->obis[4] == 2) { o282 = getNumber(item); + listType = listType >= 3 ? listType : 3; if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf(" and value %lu", o282); } } @@ -69,12 +75,14 @@ LNG::LNG(const char* payload, uint8_t useMeterType, MeterConfig* meterConfig, Da memcpy(str, item->oct.data, item->oct.length); str[item->oct.length] = '\0'; meterId = String(str); + listType = listType >= 2 ? listType : 2; if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf(" and value %s (oct)", str); } else if(descriptor->obis[4] == 1) { char str[item->oct.length+1]; memcpy(str, item->oct.data, item->oct.length); str[item->oct.length] = '\0'; meterModel = String(str); + listType = listType >= 2 ? listType : 2; if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf(" and value %s (oct)", str); } } @@ -85,21 +93,17 @@ LNG::LNG(const char* payload, uint8_t useMeterType, MeterConfig* meterConfig, Da if(o170 > 0 || o270 > 0) { int32_t sum = o170-o270; if(sum > 0) { - listType = listType >= 1 ? listType : 1; activeImportPower = sum; } else { - listType = listType >= 2 ? listType : 2; activeExportPower = sum * -1; } } if(o181 > 0 || o182 > 0) { activeImportCounter = (o181 + o182) / 1000.0; - listType = listType >= 3 ? listType : 3; } if(o281 > 0 || o282 > 0) { activeExportCounter = (o281 + o282) / 1000.0; - listType = listType >= 3 ? listType : 3; } if((*data) == 0x09) {