...
Note |
---|
This can also be true with certain Sparkplug based payloads where metric names may have unusual characters in them. While MQTT and Sparkplug both support characters such as . & % =, Ignition does not support these as valid characters in a tag path or tag name. As a result, sometimes it may be necessary to tell MQTT Engine to replace certain characters or strings of characters with something else so the tag path and tag names can be properly created in Ignition. |
String Replacement Usage
Consider the following Custom Namespace.
Image Removed
String Replacement UsageThe String Conversion feature can be used in any Custom Namespace or in the Sparkplug B Namespace. The String Replacement feature supports the following.
- Replacements are executed using the 'Order Index' order from lowest to highest.
- Single character to single character replacement
- String to string replacement
- Character or string to nothing (i.e. removes a string or character)
- Regular Expression (regex) to string, character, or nothing replacement (i.e. uses a regex for pattern matching rather than a literal string)
- Character replacements will only occur for characters that will be part of the tag path. Character replacements are not applied to Ignition tag values
- Null or empty replacement string
Examples:
- Remove all '@' symbols
Image Added - Replace all '@' symbols with '_'
Image Added - Replace all 'abc' character sequences with 'def'
Image Added - Replace all characters between the literal strings 'start' and 'end' with a '_' character using a regex
Image Added
How do I determine what string replacement I need?When an Ignition tag is created, there are some rules that need to be followed:
- The first character of the Tag name must be one of the following:
- Letter - specifically, a letter as recognized by Unicode's Letter (L) category.
- Number
- Underscore
- The second character, and every character after that can then be one of the following:
- Letter
- Number
- Underscore
- Space
- Any of the following special characters:
'
, -
, :
, (
, )
Warning |
---|
All other special characters are not allowed in a Tag name. |
To determine the string replacement needed for the namespace:
- Look at the published MQTT topic and a sample payload, if parsing as JSON, and identify any characters that may be problematic.
- Review these characters against the rules above or open Ignition designer and test if a tag can be created with the specific characters.
- If a tag cannot be created, created a string replacement rule.
Consider Now consider an incoming MQTT message with the characteristics:
- Topic = a/b
- Payload = { "tag 1": 123, "tag@2": "some.value" }
This A custom namespace with a subscription a/# will be able to receive the message however this will fail to be handled by the Custom Namespace and an error will be logged that looks like:
...
This tells MQTT Engine that for this custom namespace, convert any '@' characters that would normally be part of the tag path to '_' characters. So now when we publish the same MQTT message, we don't get an error message and the tag gets properly created as shown below with the '@' character replaced by a '_' character.

The String Conversion feature can be used in any Custom Namespace or in the Sparkplug B Namespace. The String Replacement feature supports the following.
- Replacements are executed using the 'Order Index' order from lowest to highest.
- Single character to single character replacement
- String to string replacement
- Character or string to nothing (i.e. removes a string or character)
- Regular Expression (regex) to string, character, or nothing replacement (i.e. uses a regex for pattern matching rather than a literal string)
- Character replacements will only occur for characters that will be part of the tag path. Character replacements are not applied to Ignition tag values
- Null or empty replacement string
Examples:
...
Additional Resources
- Inductive Automation's Ignition download with free trial
- Cirrus Link Solutions Modules for Ignition
- Questions about this tutorial?
- Sales questions
- About Cirrus Link