Custom Payload

Custom Payload

You can customize the payload to communicate (publish or subscribe) with third-party devices that use different payload format.
A typical payload contains header and records. For example:
{ "Timestamp": "2024-08-27T12:36:50" "Records": [ {"Name"="MyVariableA" "Val"=23}, {"Name"="MyVariableB" "Val"=true}, {"Name"="MyVariableC" "Val"=”abc”} ] }
General payload structure
By selecting alias refering to specific item along with its attributes, you can define payload records format. You can perform advanced modification by using the FactoryTalk Optix String Formatter. The Formatter is required to add new properties to MQTT Publisher node, with additional properties:
PF Enabled
,
PF Header
and
PFRecord
.
PF Header
:
  • Defines the JSON header.
  • FT Optix String Formatter is required to define JSON format and to link variables to be used in JSON header.
  • You must link a specific placeholder
    #PFRecord
    to payload records.
  • You can define one or more variables in the header, such as payload timespamp or production line numer.
  • For sending plain text (or variable as plain text), you can type a plain text message in the
    PF Header
    or place a link to the variable in the
    PF Header
    .
  • When multiple variables exist in Folder, you must create an array of records by placing
    #PFRecord
    in square brackets []. FactoryTalk Optix iterates through all variables and uses them during payload creation.
PFRecord
:
  • Defines the JSON records.
  • FT Optix String Formatter is required to define JSON records and to link variables to be used in JSON records.
TIP: In String Formatter the first bracket must be escaped to prevent a syntax error. You can double the bracket to escape it, e.g.:
{{{0}

Custom Payload Examples

  • PF Header
    :
    {"timestamp": "{0:o}", "sensors": [#PFRecord]}
    Adds the timestamp and the records name to the payload header.
  • PF Record
    :
    {"name": "{0}", "value": {1}},
    Adds the names and values of the array of sensors.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.