From 1c1b39ea2907a8619223a9fca61877634e3489b1 Mon Sep 17 00:00:00 2001 From: John Date: Sat, 23 Sep 2023 12:34:21 +0200 Subject: [PATCH] send empty topic instead of logging an error on messages without a single field (fixes #817) --- src/ebusd/mqtthandler.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ebusd/mqtthandler.cpp b/src/ebusd/mqtthandler.cpp index d8969d92..f508f322 100755 --- a/src/ebusd/mqtthandler.cpp +++ b/src/ebusd/mqtthandler.cpp @@ -1381,6 +1381,10 @@ void MqttHandler::publishMessage(const Message* message, ostringstream* updates, *updates << message->getCircuit() << UI_FIELD_SEPARATOR << message->getName() << UI_FIELD_SEPARATOR; } result_t result = message->decodeLastData(false, nullptr, -1, outputFormat, updates); + if (result == RESULT_EMPTY) { + publishEmptyTopic(getTopic(message)); // alternatively: , json ? "null" : ""); + return; + } if (result != RESULT_OK) { logOtherError("mqtt", "decode %s %s: %s", message->getCircuit().c_str(), message->getName().c_str(), getResultCode(result));