diff --git a/contrib/etc/ebusd/mqtt-hassio.cfg b/contrib/etc/ebusd/mqtt-hassio.cfg index 735753ba..465f180e 100644 --- a/contrib/etc/ebusd/mqtt-hassio.cfg +++ b/contrib/etc/ebusd/mqtt-hassio.cfg @@ -82,7 +82,13 @@ # Before constructing the variable replacements, the messages and fields can optionally be filtered in order to use -# certain message definitions only: +# certain message definitions only. All of these criteria are applied, so they are basically combined by "AND". +# Filters with a "partial match" mention in the documentation allow using a limited glob/regex inspired case insensitive +# matching with the following options: +# - "|" allows defining alternatives, e.g. "a|b" matches "but" as well as "all". +# - "^" matches the beginning of the input, e.g. "^al" matches "al" but not "hal". +# - "$" 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. # HA integration: filtering only seen messages to avoid unnecessary "pollution" diff --git a/contrib/etc/ebusd/mqtt-integration.cfg b/contrib/etc/ebusd/mqtt-integration.cfg index 8b1e48d0..43a5cce5 100644 --- a/contrib/etc/ebusd/mqtt-integration.cfg +++ b/contrib/etc/ebusd/mqtt-integration.cfg @@ -76,7 +76,13 @@ # Before constructing the variable replacements, the messages and fields can optionally be filtered in order to use -# certain message definitions only: +# certain message definitions only. All of these criteria are applied, so they are basically combined by "AND". +# Filters with a "partial match" mention in the documentation allow using a limited glob/regex inspired case insensitive +# matching with the following options: +# - "|" allows defining alternatives, e.g. "a|b" matches "but" as well as "all". +# - "^" matches the beginning of the input, e.g. "^al" matches "al" but not "hal". +# - "$" 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. filter-seen = 1 diff --git a/src/ebusd/mqtthandler.cpp b/src/ebusd/mqtthandler.cpp index 1a55c582..8c72fef8 100755 --- a/src/ebusd/mqtthandler.cpp +++ b/src/ebusd/mqtthandler.cpp @@ -593,7 +593,7 @@ ssize_t MqttReplacer::matchTopic(const string& topic, string* circuit, string* n // non-name in remainder found return -static_cast(idx)-1; } - value = topic; + value = topic.substr(last); } last += value.length(); switch (part.second) { @@ -1092,7 +1092,7 @@ void MqttHandler::notifyTopic(const string& topic, const string& data) { logOtherDebug("mqtt", "received topic %s with data %s", topic.c_str(), data.c_str()); string circuit, name, field; ssize_t match = m_replacers.get("topic").matchTopic(topic.substr(0, pos), &circuit, &name, &field); - if (match<0 && !isList) { // TODO + if (match<0 && !isList) { logOtherError("mqtt", "received unmatchable topic %s", topic.c_str()); } if (isList) {