MQTT

How to enter the payload configuration:

Once you have selected the desired plant, press the wheel in the upper right corner between the pencil and the bell:

Then double click on the desired device:

Once inside the device settings we will see between the entries in the top left the entry “Payload” and by clicking on it we could enter its configuration:

Array returned by the JSONPath query:

In this case you can have N arrays, but only one (the one that will be extracted by JSONPath query) will contain N objects which in turn will contain the data we need.

{
"data": [
{
"signal" : "test1",
"value" : 250,
"ts" : 1740749063,
"um" : "rpm"
},
{
"signal" : "test2",
"value" : 50,
"ts" : 1740749063,
"um" : "°C"
}
]
}

Possible reading configurations:

Configuration with reading of property values:

Configuration with JSONPath query applied to (1):

NB: In the case below, when the configuration is saved, all variables will be set to “the value of the property indicated” (as in the first case) because they have the same logical value.

Single array present in the payload root:

In this case the code may contain the data of N objects, but all will be within the single array.

[
{
"signal" : "test3",
"value" : 34,
"um" : "ms",
"ts" : 1740754186
}
]

Possible reading configurations:

Configuration with reading of property values:

Configuration with JSONPath query applied to (1):

NB: The configuration below is correct to use it in case you have only one object within the array.

Single object present in the payload root:

This is the simplest case, you have only one object from which to take directly all the data.

{
"signal" : "test4",
"value" : 78,
"um" : "kg",
"ts" : 1740754186
}

Possible reading configurations:

Configuration with reading of property values:

Configuration with JSONPath query:

NB: In this case if I use “The result of the following JSONPath query applied to what was specified in (1)” I will get the same result as the above example.

Special case:

When the signal is represented with “signal_name”: value then you need to use a particular configuration for reading the ID and its value (you can also use single object in the payload and JSONPath query in the entry “Variables are found (1)”), but for everything else the payload can be configured exactly as the cases already seen above.

[
{
"test5": 2,
"ts": 1740754632,
"um": "rpm"
},
{
"test6": 45,
"ts": 1740754632,
"um": "°C"
}
]

Possible reading configurations:

Configuration with reading of property values:

Configuration with JSONPath query applied to (1):

NB: In this case, when the ID of a variable is read, the value on the right will be automatically recorded as its value.

Other examples of special cases:

In this case the correct configurations to be applied are the same in the case of N arrays, it only changes how ID and value are read.

 {
"data": [
{
"test7": 2,
"ts": 1740754632,
"um": "rpm"
},
{
"test8": 45,
"ts": 1740754632,
"um": "°C"
}
]
}

Possible reading configurations:

Configuration with reading of property values:

Configuration with JSONPath query applied to (1):

In this case the correct configurations to apply are the same as the single object present in the payload, it changes only the way in which ID and value are read.

{
"test9": 45,
"ts": 1740754632,
"um": "°C"
}

Possible reading configurations:

Configuration with reading of property values:

Configuration with JSONPath query applied to (1):

General important notes:

  • The timestamp can be written in various formats;
  • Only certain predefined unit of measurement can be read;
  • If I select “The ID of a variable is in the topic and it is the text of the level at position number”, the configuration will automatically take the specified topic slot and use it as the signal name.
  • “The value of the properties with the suffix specified” means that the unit of measure is located in a field starting with the id of the variable and then has the suffix inserted in the field, also it can be used in all the cases seen above.
ES:
{
"signal" : "test10",
"value" : 78,
"test10um" : "kg",
"ts" : 1740754186
}

Correct reading configuration (you can also use the suffix with timestamp):

Was this helpful?

0 / 0