fix topic matching, extend documentation

This commit is contained in:
John
2022-01-30 14:17:12 +01:00
parent 62698a8021
commit 6155e58e50
3 changed files with 16 additions and 4 deletions
+7 -1
View File
@@ -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"
+7 -1
View File
@@ -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
+2 -2
View File
@@ -593,7 +593,7 @@ ssize_t MqttReplacer::matchTopic(const string& topic, string* circuit, string* n
// non-name in remainder found
return -static_cast<ssize_t>(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) {