diff --git a/ChangeLog.md b/ChangeLog.md index b6da05eb..4cc12782 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -4,6 +4,7 @@ * fix potentially unnecessary arbitration start for non-enhanced proto * fix smaller issues in KNX integration * fix numeric replacement+infinite and float min/max values in MQTT JSON payload format +* fix duplicate definition sent for same message when writable messages are included in MQTT integration ## Features * add support for setting visual ping, IP gateway, MAC from ID, and variant to ebuspicloader diff --git a/src/ebusd/mqtthandler.cpp b/src/ebusd/mqtthandler.cpp index 4f1ae37b..6a49b939 100755 --- a/src/ebusd/mqtthandler.cpp +++ b/src/ebusd/mqtthandler.cpp @@ -961,6 +961,7 @@ void MqttHandler::run() { ostringstream ostr; deque messages; m_messages->findAll("", "", m_levels, false, true, true, true, true, true, 0, 0, false, &messages); + bool includeActiveWrite = FileReader::matches("w", filterDirection, true, true); for (const auto& message : messages) { bool checkPollAdjust = false; if (filterSeen > 0) { @@ -1011,7 +1012,13 @@ void MqttHandler::run() { if (filterPriority > 0 && (message->getPollPriority() == 0 || message->getPollPriority() > filterPriority)) { continue; } - + if (includeActiveWrite && !message->isWrite()) { + // check for existance of write message with same name + Message* write = m_messages->find(message->getCircuit(), message->getName(), "", true); + if (write) { + continue; // avoid sending definition of read AND write message with the same key + } + } StringReplacers msgValues = m_replacers; // need a copy here as the contents are manipulated msgValues.set("circuit", message->getCircuit()); msgValues.set("name", message->getName());