What are Wildcards ?


Wildcards are used with channels in the same way that wildcards are used with Topics in the MQTT messaging infrastructure.

Wildcards are powerful special characters which allow you to subscribe to multiple channels at once and to perform read operations across multiple channels with single commands.

The channel level separator is used to introduce structure into the channel, and can therefore be specified within the channel for that purpose. The multi-level wildcard and single-level wildcard can be used for subscriptions, but they cannot be used within a channel by the publisher of a message.

Channel level separator

The forward slash (/) is used to separate each level within a channel tree and provide a hierarchical structure to the channel space. The use of the channel level separator is significant when the two wildcard characters are encountered in channels specified by subscribers.  Multiple channel separators are not allowed; therefore, a channel description such as //sensor///temperature is not valid.

Multi-level wildcard

The number sign (#) is a wildcard character that matches any number of levels within a channel. For example, if you subscribe to sensor/temperature/fridge/#, you receive messages on these channels:




The multi-level wildcard can represent zero or more levels. Therefore, fridge/#  can also match the singular fridge , where #  represents zero levels. The channel level separator is meaningless in this context, because there are no levels to separate.

The multi-level wildcard can be specified only on its own or next to the channel level separator character. Therefore, #  and temperature/#  are both valid, but temperature#  is not valid. The multi-level wildcard must be the last character used within the channel tree. For example, temperature/#  is valid but temperature/#/reading  is not valid.

Single-level wildcard

The plus sign (+) is a wildcard character that matches only one channel level. For example, sensor/temperature/+  matches sensor/temperature/fridge  and sensor/temperature/cooler , but not sensor/temperature/fridge/freezer. Also, because the single-level wildcard matches only a single level, sensor/+  does not match sensor.

The single-level wildcard can be used at any level in the channel tree, and in conjunction with the multilevel wildcard. It must be used next to the channel level separator, except when it is specified on its own. Therefore, +  and sensor/+  are both valid, but sensor+  is not valid. The single-level wildcard can be used at the end of the channel tree or within the channel tree. For example, sensor/+  and sensor/+/fridge  are both valid.

The following is the list of supported wildcard combinations:

Channel string CloudPlugs subscribe CloudPlugs publish
# Yes No
+ Yes No
/# Yes No
/+ Yes No
## No No
++ No No
#/# No No
+/+ Yes No
channel# No No
channel+ No No
channel/# Yes No
channel/+ Yes No
channel## No No
channel++ No No
channel/## No No
channel/++ No No
channel#/# No No
channel+/+ No No
channel/#/# No No
channel/+/+ Yes No
#channel No No
+channel No No
#/channel No No
+/channel Yes No
/#channel No No
/+channel No No
/ No No
channel/#/channel No No
chan+nel No No
Still need help? Get in touch!
Last updated on 6th May 2021