From b3f474e3b83a21aa050508328c3bccf888774a8e Mon Sep 17 00:00:00 2001 From: John Date: Sun, 30 Jan 2022 14:51:44 +0100 Subject: [PATCH] skip seen for active write messages and publish read pendant for those --- contrib/etc/ebusd/mqtt-hassio.cfg | 2 +- contrib/etc/ebusd/mqtt-integration.cfg | 2 +- src/ebusd/mqtthandler.cpp | 11 ++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/contrib/etc/ebusd/mqtt-hassio.cfg b/contrib/etc/ebusd/mqtt-hassio.cfg index 33657659..fb97c071 100644 --- a/contrib/etc/ebusd/mqtt-hassio.cfg +++ b/contrib/etc/ebusd/mqtt-hassio.cfg @@ -90,7 +90,7 @@ # - "$" matches the end of the input, e.g. "al$" matches "hal" but not "all". # - "*" matches a single arbitrary length wildcard part in the middle, e.g. "^a*l$" matches "all" but not "always". -# include only messages having data sent at least once. +# include only messages having data sent at least once (only checked for passive or read messages, not for active write). # HA integration: filtering only seen messages to avoid unnecessary "pollution" filter-seen = 1 # include only messages having a priority less than or equal to the specified value. diff --git a/contrib/etc/ebusd/mqtt-integration.cfg b/contrib/etc/ebusd/mqtt-integration.cfg index 43a5cce5..5e0d651a 100644 --- a/contrib/etc/ebusd/mqtt-integration.cfg +++ b/contrib/etc/ebusd/mqtt-integration.cfg @@ -84,7 +84,7 @@ # - "$" matches the end of the input, e.g. "al$" matches "hal" but not "all". # - "*" matches a single arbitrary length wildcard part in the middle, e.g. "^a*l$" matches "all" but not "always". -# include only messages having data sent at least once. +# include only messages having data sent at least once (only checked for passive or read messages, not for active write). filter-seen = 1 # include only messages having a priority less than or equal to the specified value. #filter-priority = diff --git a/src/ebusd/mqtthandler.cpp b/src/ebusd/mqtthandler.cpp index 8c72fef8..ab5dcb79 100755 --- a/src/ebusd/mqtthandler.cpp +++ b/src/ebusd/mqtthandler.cpp @@ -1274,7 +1274,10 @@ void MqttHandler::run() { for (const auto& message : messages) { if (filterSeen) { if (message->getLastUpdateTime()==0) { - continue; // no data ever + if (message->isPassive() || !message->isWrite()) { + // only wait for data on passive or read messages + continue; // no data ever + } } if (message->getDataHandlerState()==1) { // already seen in the past, check for poll prio update @@ -1425,6 +1428,12 @@ void MqttHandler::run() { if (filterSeen && message->getLastUpdateTime()>message->getCreateTime()) { // ensure data is published as well m_updatedMessages[message->getKey()]++; + } else if (filterSeen && direction=="w") { + // publish data for read pendant of write message + Message* read = m_messages->find(message->getCircuit(), message->getName(), "", true); + if (read && read->getLastUpdateTime()>0) { + m_updatedMessages[read->getKey()]++; + } } } time(&m_definitionsSince);