Use MQTT's multi-level wildcard to Subscribe to multiple Topics

MQTT's multi-level wildcards allow you to Subscribe to multiple Topics simultaneously while using a specific Topic structure (they will follow the same Topic Structure before their level).

Multi-level wildcards are represented with a hash symbol (#). Multi-level wildcards must always be placed as the last level of the Topic. For example, if using the following Subscription Topic with a multi-level wildcard:

Topic

/v1.6/devices/<device_label>/#

Then the response will be updated with the Last Dot of any variable that has received a value within the specified Device.

FieldValueRequired
Hostindustrial.api.ubidots.comYes
Port1883/8883 (Non-TLS/TLS)Yes
UsernameYour Ubidots TokenYes
PasswordAny character or leave blankNo
Quality of Service0 or 1No

🚧

Non-specific results

The results for Subscriptions using wildcards give no clue of what variable has received the resulting value/dot, as it only gives the value/dot itself and no other information

Examples

📘

Note

The bash example from this section makes use of the Eclipse Mosquitto library, if you wish to test it please install it using the official instructions.

If there are 3 Devices which contain the following Variables:

DeviceVariables
device-atemperature, pressure, humidity
device-btemperature
device-cpressure, humidity

Using multi-level wildcard Subscription to obtain a dot sent to a any Variable within a determined Device
When using the following multi-level wildcard Subscription Topic:

/v1.6/devices/device-a/#

Then the results would be as if multiple Subscriptions were made as following:

/v1.6/devices/device-a/temperature
/v1.6/devices/device-a/pressure
/v1.6/devices/device-a/humidity

Hence, the response would be updated if device-a receives a new value for either its temperature, pressure, or humidity variable.

$ mosquitto_sub \
-h "industrial.api.ubidots.com" \
-t "/v1.6/devices/device-a/#" \
-u "BBFF-Rfcgaxns6HlVb155WA0RhSY85xNDmB" \
-p 1883 \
-q 1
-v

Using multi-level wildcard to obtain the dot of any variable from any device when it is updated
Use the following Subscription Topic:

/v1.6/devices/#

Then the results would be as if multiple Subscriptions were made as following:

/v1.6/devices/device-a/temperature
/v1.6/devices/device-a/pressure
/v1.6/devices/device-a/humidity
/v1.6/devices/device-b/temperature
/v1.6/devices/device-c/pressure
/v1.6/devices/device-c/humidity

Hence, the response would be updated if any of the variables from any device would be updated

$ mosquitto_sub \
-h "industrial.api.ubidots.com" \
-t "/v1.6/devices/#" \
-u "BBFF-Rfcgaxns6HlVb155WA0RhSY85xNDmB" \
-p 1883 \
-q 1
-v