From cc72d0e0b3adabeeffc3cdcb746eb555400af036 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Sat, 18 Apr 2020 19:18:39 +0200 Subject: [PATCH 1/3] Uncommited changes --- lib/HanReader/src/HanReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/HanReader/src/HanReader.cpp b/lib/HanReader/src/HanReader.cpp index 78c5aca4..acec9893 100644 --- a/lib/HanReader/src/HanReader.cpp +++ b/lib/HanReader/src/HanReader.cpp @@ -203,7 +203,7 @@ int HanReader::getInt(int dataPosition, byte *buffer, int start, int length) { return getUint8(dataPosition, buffer, start, length); case 0x0F: return getInt8(dataPosition, buffer, start, length); - case 0x12: + case 0x12: return getUint16(dataPosition, buffer, start, length); case 0x10: return getInt16(dataPosition, buffer, start, length); From f67f12a1888d290c287ee19acdd658a407ecf1c9 Mon Sep 17 00:00:00 2001 From: Sten Otto Johnsen Date: Fri, 24 Apr 2020 00:05:12 +0200 Subject: [PATCH 2/3] Adding full report on raw data --- src/AmsConfiguration.h | 2 +- src/AmsToMqttBridge.ino | 26 +++++++++++++------------- src/web/AmsWebServer.cpp | 2 +- web/configmqtt.html | 3 ++- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/AmsConfiguration.h b/src/AmsConfiguration.h index c2991cb6..afe60992 100644 --- a/src/AmsConfiguration.h +++ b/src/AmsConfiguration.h @@ -114,7 +114,7 @@ private: int debugLevel = 3; const int EEPROM_SIZE = 512; - const int EEPROM_CHECK_SUM = 81; // Used to check if config is stored. Change if structure changes + const int EEPROM_CHECK_SUM = 82; // Used to check if config is stored. Change if structure changes const int EEPROM_CONFIG_ADDRESS = 0; bool loadConfig72(int address); diff --git a/src/AmsToMqttBridge.ino b/src/AmsToMqttBridge.ino index aee17ecc..85932da7 100644 --- a/src/AmsToMqttBridge.ino +++ b/src/AmsToMqttBridge.ino @@ -462,7 +462,7 @@ void readHanPort() { String msg; serializeJson(json, msg); mqtt.publish(config.getMqttPublishTopic(), msg.c_str()); - } else if(config.getMqttPayloadFormat() == 1) { + } else if(config.getMqttPayloadFormat() == 1 || config.getMqttPayloadFormat() == 2) { mqtt.publish(config.getMqttPublishTopic() + "/meter/dlms/timestamp", String(data.getPackageTimestamp())); switch(data.getListType()) { case 3: @@ -476,41 +476,41 @@ void readHanPort() { mqtt.publish(config.getMqttPublishTopic() + "/meter/export/active/accumulated", String(data.getActiveExportCounter(), 2)); case 2: // Only send data if changed. ID and Type is sent on the 10s interval only if changed - if(lastMqttData.getMeterId() != data.getMeterId()) { + if(lastMqttData.getMeterId() != data.getMeterId() || config.getMqttPayloadFormat() == 2) { mqtt.publish(config.getMqttPublishTopic() + "/meter/id", data.getMeterId()); } - if(lastMqttData.getMeterType() != data.getMeterType()) { + if(lastMqttData.getMeterType() != data.getMeterType() || config.getMqttPayloadFormat() == 2) { mqtt.publish(config.getMqttPublishTopic() + "/meter/type", data.getMeterType()); } - if(lastMqttData.getL1Current() != data.getL1Current()) { + if(lastMqttData.getL1Current() != data.getL1Current() || config.getMqttPayloadFormat() == 2) { mqtt.publish(config.getMqttPublishTopic() + "/meter/l1/current", String(data.getL1Current(), 2)); } - if(lastMqttData.getL1Voltage() != data.getL1Voltage()) { + if(lastMqttData.getL1Voltage() != data.getL1Voltage() || config.getMqttPayloadFormat() == 2) { mqtt.publish(config.getMqttPublishTopic() + "/meter/l1/voltage", String(data.getL1Voltage(), 2)); } - if(lastMqttData.getL2Current() != data.getL2Current()) { + if(lastMqttData.getL2Current() != data.getL2Current() || config.getMqttPayloadFormat() == 2) { mqtt.publish(config.getMqttPublishTopic() + "/meter/l2/current", String(data.getL2Current(), 2)); } - if(lastMqttData.getL2Voltage() != data.getL2Voltage()) { + if(lastMqttData.getL2Voltage() != data.getL2Voltage() || config.getMqttPayloadFormat() == 2) { mqtt.publish(config.getMqttPublishTopic() + "/meter/l2/voltage", String(data.getL2Voltage(), 2)); } - if(lastMqttData.getL3Current() != data.getL3Current()) { + if(lastMqttData.getL3Current() != data.getL3Current() || config.getMqttPayloadFormat() == 2) { mqtt.publish(config.getMqttPublishTopic() + "/meter/l3/current", String(data.getL3Current(), 2)); } - if(lastMqttData.getL3Voltage() != data.getL3Voltage()) { + if(lastMqttData.getL3Voltage() != data.getL3Voltage() || config.getMqttPayloadFormat() == 2) { mqtt.publish(config.getMqttPublishTopic() + "/meter/l3/voltage", String(data.getL3Voltage(), 2)); } - if(lastMqttData.getReactiveExportPower() != data.getReactiveExportPower()) { + if(lastMqttData.getReactiveExportPower() != data.getReactiveExportPower() || config.getMqttPayloadFormat() == 2) { mqtt.publish(config.getMqttPublishTopic() + "/meter/export/reactive", String(data.getReactiveExportPower())); } - if(lastMqttData.getActiveExportPower() != data.getActiveExportPower()) { + if(lastMqttData.getActiveExportPower() != data.getActiveExportPower() || config.getMqttPayloadFormat() == 2) { mqtt.publish(config.getMqttPublishTopic() + "/meter/export/active", String(data.getActiveExportPower())); } - if(lastMqttData.getReactiveImportPower() != data.getReactiveImportPower()) { + if(lastMqttData.getReactiveImportPower() != data.getReactiveImportPower() || config.getMqttPayloadFormat() == 2) { mqtt.publish(config.getMqttPublishTopic() + "/meter/import/reactive", String(data.getReactiveImportPower())); } case 1: - if(lastMqttData.getActiveImportPower() != data.getActiveImportPower()) { + if(lastMqttData.getActiveImportPower() != data.getActiveImportPower() || config.getMqttPayloadFormat() == 2) { mqtt.publish(config.getMqttPublishTopic() + "/meter/import/active", String(data.getActiveImportPower())); } } diff --git a/src/web/AmsWebServer.cpp b/src/web/AmsWebServer.cpp index b5c6d8c9..9d1cbf45 100644 --- a/src/web/AmsWebServer.cpp +++ b/src/web/AmsWebServer.cpp @@ -248,7 +248,7 @@ void AmsWebServer::configMqttHtml() { html.replace("${config.mqttUser}", config->getMqttUser()); html.replace("${config.mqttPassword}", config->getMqttPassword()); html.replace("${config.mqttPayloadFormat}", String(config->getMqttPayloadFormat())); - for(int i = 0; i<2; i++) { + for(int i = 0; i<3; i++) { html.replace("${config.mqttPayloadFormat" + String(i) + "}", config->getMqttPayloadFormat() == i ? "selected" : ""); } diff --git a/web/configmqtt.html b/web/configmqtt.html index 29fdcc12..e507fb5f 100644 --- a/web/configmqtt.html +++ b/web/configmqtt.html @@ -54,7 +54,8 @@
From f696e0b59bbe72be3c7ca1fd64dc46ddae1f4cc7 Mon Sep 17 00:00:00 2001 From: Sten Otto Johnsen Date: Fri, 24 Apr 2020 12:15:25 +0200 Subject: [PATCH 3/3] Removed checksum change --- src/AmsConfiguration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AmsConfiguration.h b/src/AmsConfiguration.h index afe60992..c2991cb6 100644 --- a/src/AmsConfiguration.h +++ b/src/AmsConfiguration.h @@ -114,7 +114,7 @@ private: int debugLevel = 3; const int EEPROM_SIZE = 512; - const int EEPROM_CHECK_SUM = 82; // Used to check if config is stored. Change if structure changes + const int EEPROM_CHECK_SUM = 81; // Used to check if config is stored. Change if structure changes const int EEPROM_CONFIG_ADDRESS = 0; bool loadConfig72(int address);