MQTT
MQTT Tag Configuration (Read & Write)
This section explains how to configure Tags that leverage MQTT Data Connectors to either read (subscribe) from topics on an MQTT broker or write (publish) data to topics on the broker.
Configuring MQTT Tags allows you to integrate live data from devices, sensors, or external systems into your Tricloud Nexus asset model, or push processed data from your Tags back out to other systems or Unified Namespace.
Prerequisites
Before configuring a Tag to subscribe or publish to an MQTT broker, ensure that:
An Asset Hierarchy has been created with at least one Area and one Asset as a child of that Area.
An MQTT Data Connector with at least one Topic has been configured on the Area.
You have access to the MQTT broker and know the topic structure.
Creating a Tag to Read from an MQTT Broker
When creating a Tag that subscribes to MQTT data, decide what part of the payload should be stored as the Tag's measurement value. Some common scenarios include:
Store the entire payload as a String measurement.
Extract a specific numeric reading (e.g., temperature) to store as an Analog measurement.
Extract a status or state flag to store as a Digital measurement (e.g.,
truefor ON,falsefor OFF).
Steps to Create a Read Tag
Choose the desired Tag type (Analog, Digital, or String).
Provide a descriptive name.
Set Access to Read.
Select the Data Connector
In the Data Connection dropdown, select the MQTT broker configured on the parent Area.
In the Read Topic dropdown, select the topic you want to subscribe to. (If no topics are available, configure them in the MQTT Data Connector settings.)

Select the Data Connection and Topic to Read from Define the Value Expression
Click the editor button next to the Value Expression field.
In the Query Window, use a JSONata expression to extract the desired value from the MQTT payload. Your expression must match the selected Tag type (see MQTT Query Editor for details). In this example below, we just take use the entire payload as is, by using the
$chharacter in the JsonAta Query editor textbox:
JsonAta Query Editor
Configure the Timestamp Source Choose how measurement timestamps are generated:
Measurement generation timestamp – use the UTC timestamp when the MQTT message was received.
Retrieve timestamp from MQTT payload – extract an ISO8601 timestamp from the payload using the Query Editor. In the example below, we are reading the orderCompletion timestamp property of the Json Payload as a Local timestamp in the Europe/Copenhagen timezone, and converting that into UTC timestamp in ISO8601 format.

Reading local timestamp from message, and converting it into UTC for all measurements generated from the Tag
Creating a Tag to Write to an MQTT Broker
Write Tags allow you to publish measurement values from one Tag to an MQTT broker.
Steps to Create a Write Tag
Create the Tag
Choose the desired Tag type (Analog, Digital, or String).
Provide a descriptive name.
Set Access to Write.
Select the Source and Destination
In Source Tag, select the Tag whose measurements should be published.
In Destination Connection, select the MQTT broker.
In Write Topic, select the topic to publish to. (If no topics are available, configure them in the MQTT Data Connector settings.)
Define the Value Expression
By default, the published payload will contain the standard measurement JSON:

Default Measurement Json format You can edit this Json structure by clicking the editor button next to the Value Expression field and adjusting it in the Query Editor. In the example below the following JsonAta query is used
This query removes the timeGenerated, startTimestamp, endTimestamp, quality and type as properties to the publish Json mpayload for the published message. Additionally, it creates a new property called data, where the value of the measurement is set.

Example of editing the Json sructure to publish on MQTT Topic
Last updated
Was this helpful?