Skip to main content
Version: Streamsheets 3.0

MQTT.PUBLISH

Publishes either a message or an arbitrary value using a specified Producer and topic. To reference a message from the outbox use the outbox function and to reference a message from the inbox use INBOX.

Syntax

=MQTT.PUBLISH(Connection, MessageOrValue, Topic, [QoS], [Retain], [MQTT V5 Properties])

Arguments

NameTypeDescription
ConnectionConnectionConnection to use for publishing.
MessageOrValueStringEither an existing message from the outbox or a value to publish.
TopicStringTopic that is appended to the base topic defined in the Connector.
QoS (optional)QoSQuality of Service. This option defines the reliability of the publish operation. It depends on the used protocol.

Options:
0: At most once
1: At least once.
2: Exactly once.
Retain (optional)BooleanThis option defines if the message should be retained on the broker.
MQTT V5 Properties (optional)JSONA JSON with one or more of the following properties:
PropertyType
payloadFormatIndicatorboolean
messageExpiryIntervalpositive non-zero integer
topicAliaspositive non-zero integer
responseTopicstring
correlationDatastring
userPropertiesobject
subscriptionIdentifierpositive non-zero integer
contentTypestring

Return

TypeDescription
Boolean or ErrorTRUE, if no error.

Examples

All examples assume a base topic with the value "/cedalo" in the connector.

AB
1parameter112.4
2parameter264.2
FormulaResultComment
=MQTT.PUBLISH(MQTT_Connection!,JSON(A1:B2), "test")
TRUEThis publishes a JSON object created by the json function using the "MQTT_Connection" and topic "cedalo/test"
=MQTT.PUBLISH(MQTT_Connection!,"Message", "test")
TRUEThis publishes the string value "Message" using the "MQTT_Connection" under the topic "cedalo/test"
=MQTT.PUBLISH(MQTT_Connection!, OUTBOX("Message"), "test")
TRUEThis publishes the outbox message with id "Message" using the "MQTT_Connection" and topic "cedalo/test"