Using wildcards in MQTT trigger

Hi,

I am trying to create a very simple rule that is triggered by an MQTT message. I have been able to make it work for a specific message but I need to match a variable message.

The form of the message I want to trigger on is “deviceX” where the “X” could be any number.

I can’t find any documentation on how to use wildcards to match in the Event field. Is it possible to use wildcards in the Event field to match variable messages like this?

Thanks for your help.

Evan

You don’t need to set up any specific message.
Just use Channel xyz triggered as trigger and the implicit variable receivedEvent to get the message.

It’s unclear. Is “deviceX” in the message or the topic? If it’s in the message, the typical approach would be to set up a Thing to represent deviceX. Then you’d have one Channel for each of the pieces of information you’d want from the message for deviceX. The trick is to use the REGEX transformation to first identify those messages containing “deviceX”: REGEX:.*deviceX.* then chain that to a transformation that extracts the value (e.g. a JSONPATH): REGEX:.*deviceX.*∩JSONPATH:$.temperature. Only those messages that contain “deviceX” will be passed to the next transformation and the rest will be ignored.

If for some reason you still need to use a rule, you cannot use wild cards in a rule’s trigger. You will have to filter the messages in the rule or if you are using UI rules in the condition. But given the fact that all of these messages should be similar you probably want to use one rule to process all the messages.