Tags

Add Tags

Within the MQTT Connector, tags that are contained within the Connector Topic refer to individual MQTT topics that share the settings defined for the connector topic.

Note that “Generic” (publishing) topics are not expected to contain any tags because MQTT topic names are automatically generated within Tasks based on the connected tags.

To add tags, and therefore MQTT topics, to a connector topic, select a connector topic in the navigation tree and press the “Add” toolbar button.

../_images/mqtt-add-client-tags.png

In the dialog, enter one or more MQTT topics in separate lines.

../_images/mqtt-add-client-tags-dlg.png

Click the “Add” button in the dialog to add the defined MQTT topics as tags to the connector topic.

Alternatively, you can use the tag browser to connect to the MQTT broker and query available topics. The tag browser will subscribe to the given root topic, wait for MQTT messages to arrive and present the messsage topics in hierarchical form. Enter a root topic ending with ‘#” to capture all MQTT topics that match the string before ‘#’. Some brokers may not allow subscribing to the top level ‘#’ root topic; you may need to define a more specific root topic.

If MQTT topics contain JSON payloads then you may optionally want to check the “Decode JSON” option. This will inspect JSON payloads and make values within JSON objects available as individual tags.

Select one or more tags to drag onto the topic panel to add these tags (MQTT topics) to the connector topic.

../_images/mqtt-drag-tags.png

Note

The tag browser can only display topics that are active (messages are being sent) or retained (messages that are kept in storage by the broker). If messages are sent infrequently then it may take a little while for the tag browser to populate the tree view. Note also that the load of the MQTT broker may increases if many MQTT topics are captured by a high level root topic.

Tag Settings

Select a tag in the content panel to modify its settings.

../_images/mqtt-tag-settings.png
  • Name
    Choose a name for the tag. By default, this will be the same as the MQTT topic name.
  • MQTT Topic
    The MQTT topic is the “address” of the tag within the MQTT broker.

Tip

You can use wildcards here, but be carefull not to “capture” too many topics. If a wildcard topic is used, then the tag will receive all updates matching the wildcard topic. This is most useful when receiving JSON messages from multiple devices that are then decoded in Tasks for further processing. For tags containing wildcard topics, the MQTT connector places the orignal payload into a new JSON object containing the originating MQTT topic and the payload itself. For example, a JSON payload like this…

{ "temperature": 19.1, "pressure": 998, "humidity": 71.6 }

…that arrives for an MQTT topic sensors/sensor1 will be placed into a new JSON object like this:

{
    "topic": "sensors/sensor1",
    "value": { "temperature": 19.1, "pressure": 998, "humidity": 71.6 }
}

A wildcard MQTT Topic that would capture data from all sensor devices could in this case be, for example, sensors/#. Please see the example section for further guidance.

  • JSON path

    If the MQTT topic value contains a JSON object then you may optionally enter a path to a value within the JSON object to retrieve individual values. The JSON path maybe, for example, the name of a property within the JSON object.

    For wildcard MQTT topics, the individual value is retrieved before placing the value into the new JSON object as described above.

Remove Tags

To remove tags from a topic, select tags within the topic’s content panel, then press the toolbar’s “Remove” button to remove selected tags.

../_images/mqtt-remove-client-tags.png

Warning

Note that the tags are also removed from any task using the tags.