Extract the values from MQTT topic to show on Ignition

I have an MQTT device which is publising data on MQTT broker in this format {"FM_10":"FLOWRATE_M3_H : 0.000000\nTime_Stamp: 28/09/2024 07:31:39"}, I am not able to show on Ignition Screen as a value. Can any help me out to extract the value and show on the SCADA

It will be hard to assist you without knowing where your data is going...

Are you using CirrusLink Modules for MQTT?

Are you using third-party brokers and publishing to things outside of Ignition such as HiveMQ?

Without knowing more info there is no way to help as "extracting the value" can mean different things in different context.

I would recommend giving context in your original question and appropriately tagging the question with things like your version ignition81 and if you're using CirrusLink maybe 3rd Party Modules.

Once this info is provided, I would love to try and assist you.

When using the MQTT Engine by CirrusLink, you'll need to use the custom namespace as documented here to extract those values and read them in Ignition:
https://docs.chariot.io/display/CLD80/MQTT+Engine+Custom+Namespace

1 Like

Data is coming from flowmeter through an gateway which publish data on MQTT broker
MQTT broker is local host mosquitto broker


I am using Cirruslink
Data coming in values as "FLOWRATE_M3_H : 0.000000 Time_Stamp: 27/09/2024 23:50:10"

It is coming in a single topic only

{"FM_10":"pin4 : 1\nTime_Stamp: 28/09/2024 00:04:00"}
{"FM_10":"VOLUME_NET : 967.847961\nTime_Stamp: 28/09/2024 00:05:20"}

At best what you'll need to do is parse the message using Regular Expressions commonly called RegEx. This should allow you to extract the flow meter number (FM_10), value name (pin4, VOLUME_NET, etc), the value itself, and the timestamp. Then you can do tag writes to get this into the proper tags. The timestamp though will only be good for logging to a database as the timestamp of the value will be set to the system time when your script writes it to the tag.

How to do Parse in Ignition

When you say a gateway you mean an Ignition Gateway to the mosquito broker back down to another Ignition Gateway?

If this is correct, you should really consider changing, if you can, how the data is being pushed up to the broker. If you have Cirrus Link Modules on both (and if the first Gateway you have is Ignition you would almost have to) you may consider taking out the middleman of Mosquito and just use the CirrusLink modules end-to-end. You can take a UDT and send it to another gateway through MQTT and it be structured exactly the same on both sides.

Again, this is if you can control how and where to data is sent. You may be able to make changes to how it is sent to Mosquito and get a better result as well. If you don't or can't make changes to that, then @michael.flagler is correct using Regular Expressions is going to be the route you need to take. Just keep in mind about how manageable it is, and how many tags you will need regular expressions for etc.

This documentation should be some help in using the re library included with python in Ignition. It is normal Python not Jython, but I believe the syntax and available functions should be mostly the same. A few googles and stack overflows should give you some pretty good examples. I am not the best at remembering how to use RegEx I almost always need to look it up when I need it.
7.2. re — Regular expression operations — Python 2.7.18 documentation

I often use this to test out any regular expressions I am trying to use. It will help you understand better what exactly you are doing. Never blindly trust regular expressions from places like stack or chatGPT as you will want to make sure they give you the actual result you need.
regex101: build, test, and debug regex

1 Like

When I say an gateway its physical device that read values from Flowmeter through Modbus RTU and then this physical device publish the data on MQTT (physical device connected to laptop via ethernet cable), I have my local mqtt broker mosquitto, which again configured on Ignition and ignition connected to this mosquitto broker.

I need data values in tags as discussed earlier.

Also for testing, Using node red i can extract the data very easily but I want to get the tag directly to ignition without using nodered