send empty topic instead of logging an error on messages without a single field (fixes #817)

This commit is contained in:
John
2023-09-23 12:34:21 +02:00
parent 70db4fa509
commit 1c1b39ea29
+4
View File
@@ -1381,6 +1381,10 @@ void MqttHandler::publishMessage(const Message* message, ostringstream* updates,
*updates << message->getCircuit() << UI_FIELD_SEPARATOR << message->getName() << UI_FIELD_SEPARATOR; *updates << message->getCircuit() << UI_FIELD_SEPARATOR << message->getName() << UI_FIELD_SEPARATOR;
} }
result_t result = message->decodeLastData(false, nullptr, -1, outputFormat, updates); 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) { if (result != RESULT_OK) {
logOtherError("mqtt", "decode %s %s: %s", message->getCircuit().c_str(), message->getName().c_str(), logOtherError("mqtt", "decode %s %s: %s", message->getCircuit().c_str(), message->getName().c_str(),
getResultCode(result)); getResultCode(result));