Skip to main content
Version: Streamsheets 3.0

MQTT.SUBSCRIBE

Subcribes to the specified topics and places the incoming messages into the target.

Syntax

=MQTT.SUBSCRIBE(Connection, Topics, Target, [QoS], [MQTT V5 No Local], [MQTT V5 Retain as Published], [MQTT V5 Retain Handling], [MQTT V5 Properties], [Datatype])

Arguments

NameTypeDescription
ConnectionConnectionConnection to use for subscribing.
TopicsRange or StringTopics to subscribe to.
TargetTargetINBOX(), OUTBOX("MsgID") or a cell range where the incoming MQTT messages will be placed.
QoS (optional)QoSQuality of Service. This option defines the reliability of the subscribe operation. It depends on the used protocol.

Options:
0: At most once
1: At least once.
2: Exactly once.
MQTT V5 No Local (optional)BooleanNo Local MQTT V5 Flag. If set to true, this subscription will not receive message published on the same connection.
MQTT V5 Retain as Published (optional)BooleanRetain as Published MQTT V5 Flag.
MQTT V5 Retain Handling (optional)RHRetain Handling MQTT V5 Flag. Specifies, if the subscription will receive retained messages.

Options:
0: Receive retained messages.
1: Receive new retained messages.
2: Don't receive retained messages
MQTT V5 Properties (optional)JSONA JSON with one or more of the following properties:
PropertyType
userPropertiesobject
subscriptionIdentifierpositive non-zero integer
Datatype (optional)DatatypeDatatype of the incoming messages

Options:
"auto": Detect automatically
"binary": Binary
"json": JSON
"string": String

Return

TypeDescription
Boolean or ErrorTRUE, if no error.

Examples

A
1machines/1/#
2machines/2/#
3MQTT.SUBSCRIBE
FormulaResultComment
=MQTT.SUBSCRIBE(MQTT_Connection!,"machines/+/status",INBOX("Sheet2"))
TRUESubscribe to the "machines/+/status" topic and write incoming messsages to the inbox of "Sheet2"
=MQTT.SUBSCRIBE(MQTT_Connection!,A1:A2,INBOX("Sheet2"),2)
TRUESubscribe to the topics "machines/1/#" and "machines/2/#" with QoS 2 and and write incoming messsages to the inbox of "Sheet2"