mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-01-15 00:12:07 +00:00
Merge pull request #68 from stenjo/feature/fullreport
Implementation of MQTT RAW full format
This commit is contained in:
commit
1ea9da22c7
@ -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);
|
||||
|
||||
@ -468,7 +468,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:
|
||||
@ -482,41 +482,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()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -274,7 +274,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" : "");
|
||||
}
|
||||
|
||||
|
||||
@ -54,7 +54,8 @@
|
||||
<div class="col-8">
|
||||
<select class="form-control mqtt-config" name="mqttPayloadFormat">
|
||||
<option value="0" ${config.mqttPayloadFormat0}>JSON</option>
|
||||
<option value="1" ${config.mqttPayloadFormat1}>Raw</option>
|
||||
<option value="1" ${config.mqttPayloadFormat1}>Raw (minimal)</option>
|
||||
<option value="2" ${config.mqttPayloadFormat2}>Raw (full)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user