From 44cc05604ee28ea4ba1de922dcb1a9e648fdccff Mon Sep 17 00:00:00 2001 From: Techbeard Date: Wed, 3 Jul 2024 02:05:19 +0200 Subject: [PATCH] change MQTT message structure --- software/src/janitza.cpp | 4 ++-- software/src/main.cpp | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/software/src/janitza.cpp b/software/src/janitza.cpp index af3a7a2..5855b1b 100644 --- a/software/src/janitza.cpp +++ b/software/src/janitza.cpp @@ -161,10 +161,10 @@ JsonDocument Janitza::generateJson() { if (regDef->phaseTag != P_NONE) { const char *phaseStr = phaseTagStr[regDef->phaseTag]; - doc["values"][regDef->nameStr][phaseStr] = val; + doc["Values"][regDef->nameStr][phaseStr] = val; } else { - doc["values"][regDef->nameStr] = val; + doc["Values"][regDef->nameStr] = val; } } diff --git a/software/src/main.cpp b/software/src/main.cpp index f98b00b..37f9eb9 100644 --- a/software/src/main.cpp +++ b/software/src/main.cpp @@ -67,6 +67,11 @@ void setup() { DBG.begin(115200); DBG.println("\nJanitza UMG96RM Power Analyzer to Influx\n"); MODUBS_SERIAL.begin(MODBUS_BAUD); + + initEthernet(); + connectEthernet(); + mqttInit(); + janitza.setDebugSerial(DBG); janitza.useRS485(MODBUS_DE_PIN, MODBUS_RE_PIN, preTransmission, postTransmission); #if USE_INFLUXDB @@ -77,9 +82,6 @@ void setup() { // janitza.read(); - initEthernet(); - connectEthernet(); - mqttInit(); } uint32_t lastUpdate = 0; @@ -99,6 +101,7 @@ void loop () { size_t len = serializeJson(doc, buf); String topic = MQTT_BASE_TOPIC; topic += String(janitza.getSerialNumber()); + topic += "/json"; mqttPublish(topic.c_str(), buf, len); } #endif