How to dynamically output MQTT values from a JSON advanced custom payload

How to dynamically output MQTT values from a JSON advanced custom payload
none 0.0 0
  • HMI Model: cMT2166X
  • EasyBuilder Pro Version: V6.10.01.510

The Topic Publisher accepts a JSON template that gets parsed into the payload structure - Name, Type, Value.

Is it possible to also provide the Address information in the template or does this have to mapped manually?

Something on the lines of:
{
”someVariable”: {“Address”: ”LW-0”, “Address Format”:”32-Bit Float”, “Address Element Count”: 2}
}

Where the above line gets parsed into the categories:

Name=someVariable,
type=Number,
Value=Null,
Address=LW-0,
Address Format= 32-Bit Float,
Address Element Count=2

Rather than:
payload:
→ someVariable
→→ Address
→→ Address Format.. etc

Many thanks.

As far as I know, this is not supported natively in the cMT MQTT JSON model. The tag address and format must be defined in the project beforehand.
In my projects, I create the LB/LW variables, configure them in EasyBuilder Pro, and then bind them to the MQTT topic. The JSON payload only transfers the tag name and value.
If there is a way to do dynamic mapping, it would likely require predefined tags and macro scripting.

Hi Eddy, thanks for the reply. This was my approach too.

I have just noticed how to do it, and it’s the way I define variables also.

In the MQTT window, you can export to Excel and get the necessary format for importing excels. Variables can then be maintained in Excel and and imported to the project. EasyBuilder handles the mapping of objects to variables as long as the names stay the same. For me, the benefit is having a nicely formatted set of data (that is now nicely ordered in EB!) that is easily manipulated, then I use a vba macro to reformat the data in new worksheet for pointing the import function to.

Thanks again.

1 Like