MQTT user definition

Hi everyone,

I want to send data from Modbus devices to the IoT platform ThingsBoard via MQTT using the MQTT out node. The MQTT API from the platform defines the MQTT user as the device token. So the data gathered for each device should be sent to the platform with a different user each. Is it possible to define the MQTT connection user through a message property?

Thank you all

It would seem so if you look at the sidebar help

mqtt out

Connects to a MQTT broker and publishes messages.

Inputs

payload string | buffer

the payload to publish. If this property is not set, no message will be sent. To send a blank message, set this property to an empty String.

topic string

the MQTT topic to publish to.

qos number

0, fire and forget - 1, at least once - 2, once and once only. Default 0.

retain boolean

set to true to retain the message on the broker. Default false.

responseTopic string

MQTTv5 : the MQTT response topic for the message

correlationData Buffer

MQTTv5 : the correlation data for the message

contentType string

MQTTv5 : the content-type of the payload

userProperties object

MQTTv5 : any user properties of the message

messageExpiryInterval number

MQTTv5 : the expiry time, in seconds, of the message

topicAlias number

MQTTv5 : the MQTT topic alias to use

Details

msg.payload is used as the payload of the published message. If it contains an Object it will be converted to a JSON string before being sent. If it contains a binary Buffer the message will be published as-is.

The topic used can be configured in the node or, if left blank, can be set by msg.topic .

Likewise the QoS and retain values can be configured in the node or, if left blank, set by msg.qos and msg.retain respectively. To clear a previously retained topic from the broker, send a blank message to that topic with the retain flag set.

This node requires a connection to a MQTT broker to be configured. This is configured by clicking the pencil icon.

Several MQTT nodes (in or out) can share the same broker connection if required.

Dynamic Control

The connection shared by the node can be controlled dynamically. If the node receives one of the following control messages, it will not publish the message payload as well.

Inputs

action string

the name of the action the node should perform. Available actions are: "connect" , and "disconnect" .

broker broker

For the "connect" action, this property can override any of the individual broker configuration settings, including:

  • broker
  • port
  • url - overrides broker/port to provide a complete connection url
  • username
  • password

If this property is set and the broker is already connected an error will be logged unless it has the force property set - in which case it will disconnect from the broker, apply the new settings and reconnect.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.