Subscribe single-level wildcard

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

MQTT's single-level wildcards allow you to subscribe to multiple topics simultaneously while using a specific topic structure. They match any subscription that follows the same topic structure.

Single-level wildcards are represented with a plus sign (+). For example, use the following subscription topic with a single-level wildcard:

Topic

/v1.6/devices/+/<variable_label>

Then the response will be updated with the last dot of a device that contains a variable with the same {VARIABLE_LABEL} specified in the topic and has received a value.

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

Examples

📘

Note

The bash examples in this section use the Eclipse Mosquitto library. To test them, install it using the official instructions.

If there are three devices that contain the following variables:

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

Using a single-level wildcard subscription to obtain a value/dot sent to a specified variable for any device
Use the following single-level wildcard subscription topic:

/v1.6/devices/+/pressure/lv
/v1.6/devices/+/pressure

Then the results would be as if multiple subscriptions were made as follows:

/v1.6/devices/device-a/pressure/lv
/v1.6/devices/device-c/pressure/lv
/v1.6/devices/device-a/pressure
/v1.6/devices/device-c/pressure

Therefore, the response would be updated if either device-a or device-c receives a new value/dot for its pressure variable.

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

Using a single-level wildcard to obtain the last value/dot of any variable from a device when it is updated
Use the following subscription topic:

/v1.6/devices/device-a/+/lv
/v1.6/devices/device-a/+

Then the results would be as if multiple subscriptions were made as follows:

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

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

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