Switch node - MQTT like wildcards for switching

Nobody reads the docs - you have seen the forum replies "see the built in help" "see the readme" "see the cookbook" right? :wink:


MQTT topic (of course :slight_smile: )...


sentiment node? :innocent:


Ok, lets see if we can round this off...

Summary

So I read from the posts in this thread there is slightly more positive consensus towards the switch node supporting this but there are variations on that support (mqtt filter vs more general wildcard)

Use xxxx (arguments against it)

There are several posters saying "use regex" or "use JSONata".

The counter argument to that is, why bother having == or contains or is true etc - you can do these in one of regex or JSONata

Personally, I dont think "use regex" or "use JSONata" is the answer. I love the power of regex & JSONata BUT I almost always have to use a helper for even quite simple things.

The fact is, they are not simple, not for newbees and are inconsistent with MQTT topics.

e.g. to achieve a really simple topic filter of +/1/+/temperature in regex is ^[^\/\n]+\/1\/[^\/\n]+\/temperature$ :face_vomiting:

example

General wildcard

I do agree MQTT topic filtering is somewhat restrictive BUT as others have pointed out "which wildcards?". There is no real standard (MS versions, VB like version, SQL like, glob etc etc). I too would really like a nice easy to use *?# form of wildcard matching but in the context of MQTT topic filtering, I dont think it it makes a lot of sense since * and ? are valid characters in a topic (not that I would ever use them) - meaning we would have to escape them.
Perhaps this is a good and sensible proposal for simple wildcard matching & something that should be considered for the switch node but I believe it should be separate from MQTT topic filter. Perhaps we can discuss and agree in a different thread?

MQTT topic filtering

IMHO Anyone doing MQTT knows (or will eventually learn about) topic filtering via +/# so i would propose if we DO add support for this, then it is just that - KISS approach.

2 Likes