MQTT Topic Configuration
- Last UpdatedJul 10, 2024
- 3 minute read
To add an MQTT topic and link it to an existing control or specify a script
-
In the MQTT Topic Configuration page, specify the following details:
Property
Description
Topic
Enter the path of the topic.
MQTT Connection
Select the MQTT Connection.
Note: When MQTT Connection is changed, the latest published message of the topic is displayed in the Subscribed Value text box.
Subscribed Value
The latest published message is displayed in the Subscribed Value text box.
The Subscribed Value text box is empty when the published message is not available. Click Refresh button to retrieve the latest published message.Note: When the Topic and the MQTT Connection is changed, Refresh button is disabled for 5 seconds. It is enabled after the subscribed value is received.
Data Type
Select the data type of the topic value.
For more information on available data types, see Data Types in MQTT Topic Configuration.
JSON Path
Specify the JSON Path.
This is required only for topic message containing valid JSON string and when publisher sends message as JSON object. You must specify the path to access the node in the JSON string. For examples, see Specify JSON PathMQTT Connections.
Array
Select the Array option as Yes if the published message is an array.
Note: The format for the supported array values is <element1>, <element2>, ..., <elementN>
Separator
Specify the character comma (,) to separate the array.
Note: Only one character can be entered in the Separator box.
Element
Enter the position of the element in the array to be extracted.
The minimum value is 1 and the maximum value is 999999999999999.
Note:
When the Array option is Yes and an array element position is not specified, the value displayed in Extracted Value box is based on the value selected in Action Type box.
- If you select Link to Existing Control, then the first element value of the array is displayed.
- If you select Specify Script, the whole array value is displayed.Action Type
Two options are available for Action Type:
-
Link to Existing Control
In the Existing Control list, select a control (available on the form).
-
Specify Script
Click the Script Editor button to specify the script in the Script Editor page.
Existing Control
Select the existing controls available in the form. The controls which have the value is listed like TextInput, Number, etc.
Action Script
Click the Script Editor button. Specify the script that is to be executed. For example, control.findByXmlNode("Textinput1").value=currentValue;
Click Save & Close.The script is executed when message is arrived.
Extracted Value
Displays the value extracted from the Subscribed Value. The Extracted value is based on Topic, MQTT Connection, Data Type, JSON path, and Array.
-
If Array is Yes, then the Separator and Element is considered.
-
If the Action Type is Link to Existing Control, then the Extracted value is shown based on the Existing Control type.
-
If the Action Type is Specify Script, then the currentValue type is based on the selected Data Type .
-
2. Click Save & Continue.
The Forms properties page appears.
Note: After you save the settings, the setting details are displayed in the Topic box. For example, the displayed information is:
- <Control name ~ topic>, when the Action type is Link To Existing Control, and <Control not linked> when control is not linked.
- <Script ~ topic>, when the Action type is Script.
- MQTT topics are not supported in AVEVA Work Tasks Pro.
For information about MQTT Connections, see MQTT Connections in the Developer Guide.