diff --git a/contrib/etc/ebusd/mqtt-hassio.cfg b/contrib/etc/ebusd/mqtt-hassio.cfg index 18751a6f..4dc6e623 100644 --- a/contrib/etc/ebusd/mqtt-hassio.cfg +++ b/contrib/etc/ebusd/mqtt-hassio.cfg @@ -101,9 +101,13 @@ filter-seen = 5 #filter-priority = # include only messages having the specified circuit (partial match, alternatives and wildcard supported). #filter-circuit = -# include only messages having the specified name (partial match, alternatives and wildcard supported). +# exclude messages having the specified circuit (partial match, alternatives and wildcard supported). +#filter-non-circuit = +# include only messages having the specified name (partial match, alternatives and wildcard supported). # HA integration: filter to some useful names for monitoring the heating circuit filter-name = status|temp|yield|count|energy|power|runtime|hours|starts|mode|curve|^load$|^party$ +# exclude messages having the specified name (partial match, alternatives and wildcard supported). +#filter-non-name = # include only messages having the specified level (partial match, alternatives and wildcard supported). # Note: This is a filter on top of the messages already filtered implicitly for the ebusd "mqtt" user (if any). # Note: Since the empty string matches all levels, an explicit check for empty string (with "^$") needs to be used for @@ -114,6 +118,9 @@ filter-level = ^$ filter-direction = r|u # include only fields having the specified name (partial match, alternatives and wildcard supported). #filter-field = +# exclude fields having the specified name (partial match, alternatives and wildcard supported). +# HA integration: exclude the useless sensor ok/cutoff info from temperature sensor. +filter-non-field = ^sensor$ # HA integration: home assistant configuration topics prefix diff --git a/contrib/etc/ebusd/mqtt-integration.cfg b/contrib/etc/ebusd/mqtt-integration.cfg index 96c8fb0f..82f8ce49 100644 --- a/contrib/etc/ebusd/mqtt-integration.cfg +++ b/contrib/etc/ebusd/mqtt-integration.cfg @@ -94,8 +94,12 @@ filter-seen = 1 #filter-priority = # include only messages having the specified circuit (partial match, alternatives and wildcard supported). #filter-circuit = +# exclude messages having the specified circuit (partial match, alternatives and wildcard supported). +#filter-non-circuit = # include only messages having the specified name (partial match, alternatives and wildcard supported). #filter-name = +# exclude messages having the specified name (partial match, alternatives and wildcard supported). +#filter-non-name = # include only messages having the specified level (partial match, alternatives and wildcard supported). # Note: This is a filter on top of the messages already filtered implicitly for the ebusd "mqtt" user (if any). # Note: Since the empty string matches all levels, an explicit check for empty string (with "^$") needs to be used for @@ -105,6 +109,8 @@ filter-level = ^$ filter-direction = r|u # include only fields having the specified name (partial match, alternatives and wildcard supported). #filter-field = +# exclude fields having the specified name (partial match, alternatives and wildcard supported). +filter-non-field = ^sensor$ # the field type mapped from variables named "type_map-%direction-%type" or "type_map-%type" as fallback with the diff --git a/src/ebusd/mqtthandler.cpp b/src/ebusd/mqtthandler.cpp index f24c130d..d5f8bd38 100755 --- a/src/ebusd/mqtthandler.cpp +++ b/src/ebusd/mqtthandler.cpp @@ -1347,7 +1347,8 @@ void MqttHandler::run() { ostringstream updates; unsigned int filterPriority = 0; unsigned int filterSeen = 0; - string filterCircuit, filterName, filterLevel, filterField, filterDirection; + string filterCircuit, filterNonCircuit, filterName, filterNonName, filterField, filterNonField, + filterLevel, filterDirection; vector typeSwitchNames; if (m_hasDefinitionTopic) { result_t result = RESULT_OK; @@ -1361,12 +1362,18 @@ void MqttHandler::run() { } filterCircuit = m_replacers["filter-circuit"]; FileReader::tolower(&filterCircuit); + filterNonCircuit = m_replacers["filter-non-circuit"]; + FileReader::tolower(&filterNonCircuit); filterName = m_replacers["filter-name"]; FileReader::tolower(&filterName); - filterLevel = m_replacers["filter-level"]; - FileReader::tolower(&filterLevel); + filterNonName = m_replacers["filter-non-name"]; + FileReader::tolower(&filterNonName); filterField = m_replacers["filter-field"]; FileReader::tolower(&filterField); + filterNonField = m_replacers["filter-non-field"]; + FileReader::tolower(&filterNonField); + filterLevel = m_replacers["filter-level"]; + FileReader::tolower(&filterLevel); filterDirection = m_replacers["filter-direction"]; FileReader::tolower(&filterDirection); if (!m_typeSwitches.empty()) { @@ -1451,7 +1458,9 @@ void MqttHandler::run() { continue; } if (!FileReader::matches(message->getCircuit(), filterCircuit, true, true) + || (!filterNonCircuit.empty() && FileReader::matches(message->getCircuit(), filterNonCircuit, true, true)) || !FileReader::matches(message->getName(), filterName, true, true) + || (!filterNonName.empty() && FileReader::matches(message->getName(), filterNonName, true, true)) || !FileReader::matches(message->getLevel(), filterLevel, true, true)) { continue; } @@ -1491,7 +1500,8 @@ void MqttHandler::run() { if (fieldName.empty() && fieldCount == 1) { fieldName = "0"; // might occur for unnamed single field sets } - if (!FileReader::matches(fieldName, filterField, true, true)) { + if (!FileReader::matches(fieldName, filterField, true, true) + || (!filterNonField.empty() && FileReader::matches(fieldName, filterNonField, true, true))) { continue; } const DataType* dataType = field->getDataType();