Email Us at [email protected]

Download N3uron

Back to videos

MQTT Client / MQTT Client Custom Parser

MQTT Client Custom Parser

Description

In this video of our N3uron Academy, we’ll create a custom parser to process the structured payload and update tags in N3uron with this data. Let’s get started!

  • [06:30] MQTT Client Custom Parser

Transcription

[00:00]  Hello everyone! In our previous video, we configured an MQTT Publisher using password and certificate authentication to connect to a Mosquitto broker. Now, we’ll shift our focus to the subscriber side, where we’ll create a custom parser to process the structured payload and update tags in N3uron with this data. Since the broker connection remains unchanged from the previous video, we recommend watching the MQTT Client Configuration tutorial if you need to review the setup. Let’s begin by examining the topic structure and payload format. Each measurement is published following a hierarchical topic structure based on the ISA-95 standard. The topics are structured by enterprise, area, line A, cell 1 or cell 2, and then the specific measurement data.

[01:00] Let’s go through the code and explain how it works. The script starts by logging the entire input object to verify that the data is received correctly. It then extracts the timestamp by splitting it into time, date, and the UTC indicator. The date is further broken down into day, month, and year before being reformatted into an ISO 8601 string for compatibility. This string is then converted into an epoch timestamp, and logged for verification. Next, the script processes the rest of the payload. It iterates through each key-value pair, skipping the time field, and converts the remaining data into structured event objects. Each event uses the field name as the tag identifier. Instead of specifying full tag paths, this approach dynamically assigns tags based on field names, leveraging tag address aliases. This allows new data fields to be processed automatically without requiring additional configuration. We will explore this feature in more detail when configuring the tags in the tag model.

[02:00] In this example, we are going to proceed with a Custom broker configuration, and specific brokers such as AWS IoT Core and Azure IoT Hub will be covered in future videos. Next, enter the Client ID that uniquely identifies your MQTT connection. You can generate this ID randomly if needed. Now, let’s move on to authentication. Select an authentication mode based on your broker’s requirements. Available options include None, Password, Certificate, Password with Certificate, or JSON Web Tokens (JWT). If JWT is selected, additional fields will appear to define token duration, signing algorithm, and other properties. In this case, we will select Password and Certificate authentication. Enter the username and password, then provide the certificate. Certificates can either be embedded directly or selected via a file path.

[03:02] The script then converts the value to a floating-point number, assigns a fixed quality code of 192 (indicating “Good” data quality), and attaches the parsed timestamp. Finally, it logs the output. Next, we will instantiate the Subscriber Template in the model, assign it a meaningful name, and update the topic accordingly. Now, let’s move to the Tag Configuration.

[04:01] Here, we have a measurements Template with two Custom Properties. The first one, Module Name, should be set to the name of the MQTT Client module instance. The second, Subscriber, is created by combining the connection name to the broker with the previously assigned Subscriber name. The tags in this template are configured with MqttClient as the source module type. The Module Name is dynamically assigned from the corresponding Custom Property. Instead of using full tag paths, Tag Addresses are assigned to an alias, which matches the field names from the payload. As mentioned earlier, this allows for dynamic tag assignment, making it unnecessary to specify full tag paths in the subscription’s custom parser. However, if this setting is left empty, full tag paths must be used in the custom parser. Next, we will instantiate this Template into the Tag Model and provide the correct Subscriber value in the Custom Property.

[05:24] Once everything is set up, save the configuration and verify that it is working correctly. Navigate to the Diagnostics window, open the Real-Time Logs, and enable Trace Mode to monitor the data flow of the MQTT Client. If everything is working as expected, go to the Data → Real-Time window to visualize the data arriving from the broker.

[06:10] That’s it! The MQTT Client’s Custom Parser setup is now complete. For more details on configuring the MQTT Custom Parser and N3uron Templates, please visit N3uron’s Knowledge Base. Thanks for watching, and see you in the next video!

Privacy Settings
We use cookies to enhance your experience while using our website. If you are using our Services via a browser you can restrict, block or remove cookies through your web browser settings. We also use content and scripts from third parties that may use tracking technologies. You can selectively provide your consent below to allow such third party embeds. For complete information about the cookies we use, data we collect and how we process them, please check our Privacy Policy
Youtube
Consent to display content from - Youtube
Vimeo
Consent to display content from - Vimeo
Google Maps
Consent to display content from - Google
Spotify
Consent to display content from - Spotify
Sound Cloud
Consent to display content from - Sound