cancel
Showing results for 
Search instead for 
Did you mean: 

MQTT - PCo - MII setup (without cloud)

0 Kudos
1,520

Hi,

We are currently experimenting with machines that log messages to our MQTT system and we are trying to propagate those messages to our MII-system. However, there is little information on SAP on how to do this - or only information about a full cloud setup.

We managed to communicate to MII, but the messages that are being sent from MQTT are scrambled.

A simple example of the JSON that PCO receives:

{ "prop1" : "value",
  "prop2" : {
      "subprop1" : 00,
      "subprop2" : "value"
   },
   "prop3" : {
      "subprop4" : "value"
   },
   "prop4" : "value"
}

I tried setting up the PCo to send it as an object, but this gives internal LINQ errors. The closest I was able to get was sending it without objects. I did this by using "prop2.subprop1" in the "Tag Definition" tab and adding it to the message configuration. I receive an XML with the properties in MII. However, it will then have to be mapped again to the actual structure.

My questions:

- is there any resource on how to set up MQTT with PCo that have multiple levels?

- Do we need to add a Source System for EACH tag we want to listen to?

- Is it possible to correctly map a structure like this in PCo so it can be sent to MII? If not, is it possible to send the data as a JSON format to MII?

- Right now we are listening to changes under " test/my/topic/# ". This has three topics under the #, I would expect that it would send me an XML of the topics when a change happens in one of each 3. It doesn't do that, but instead sends the same topic over and over. Sometimes not even with the correct data? What am I doing wrong?

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

Kevin_Hunter
Product and Topic Expert
Product and Topic Expert

Hi,

Let me see if I can answer some of your questions

- is there any resource on how to set up MQTT with PCo that have multiple levels?

Not that I can find, the help guide isn't particularly helpful on this topic. I will bring this up with the PCo development team to see if they can improve it. However your structure can be mapped in the message configuration screen by using the dot notation that you already used. Here is a screenshot of the configuration for your message.

I created a test agent instance that used this source and sent it to a simulator destination. When I send your example payload to the MQTT broker the simulator wrote this file:

Which shows it correctly read the data.

- Do we need to add a Source System for EACH tag we want to listen to?

This depends on how you are defining a tag in this use case. Do you mean each property or sub property in the MQTT payload (if you do then no you dont need multiple source systems as you can add multiple subscriptions in the one source)

- Is it possible to correctly map a structure like this in PCo so it can be sent to MII? If not, is it possible to send the data as a JSON format to MII?

Yes, I show it in the example above. If you want to send it in JSON then you can also do that (the MII message will still be XML with the embedded JSON message) . To do this you need to set the payload type in the tag definition to "formatted string" and enter "{}" in the template. This will embed the JSON as string into the MII XML message as shown below.

Hopefully this helps you, if not let me know and we can discuss further.

Thanks

Kevin

0 Kudos

Hi Kevin,

Thanks for your response! It seems like my preferences are off when it comes to e-mail notifications, so apologies for the late response. I made sure to switch them on now.

We managed to figure out the "formatted string" option to send the JSON after some trial and error. This way we can keep the deeper structure, since the other way makes a flat XML structure from the MQTT JSON. I am happy that you can confirm this is indeed the way to go.

> Not that I can find, the help guide isn't particularly helpful on this topic. I will bring this up with the PCo development team to see if they can improve it.

Thank-you for bringing it up. Right now we are progressing really slowly, a lot by trial and error. We managed to set up a full communication path between MII, PCo and MQTT, but there are still parts where I doubt this is the correct way of doing it or where we are stuck.

I will accept your answer, since this is the way we are doing it right now. If you would have a contact we can connect to surrounding our PCo issues and PCoQueries, that would be greatly appreciated.

(A bit of information about my main issue right now)

I am using a PcoQuery Tag Store, but there is no documentation on how to really use it:

When I hardcode the values inside the PCoQuery, it works like a charm. However, when I want to use parameters, it sends the "Param.1" values as a string and doesn't bind the parameters. After searching I found out that there is something called "SelectedTagsValue" and you can populate it with a comma-seperated string. I can't find any documentation on this, so I don't know if this is correct.

Anyhow, every attempt on binding the retrieved MII data to PCo results in mangled data. Below is a picture where I try to send the string "OEE" in the "measurement" field. It turns into unreadable characters or "8A".

Best Regards

0 Kudos

To follow up on this, we have found that the Tag Store Query contains a parameter on encoding. When changing this to true, the messages are propagated correctly.

former_member204155
Active Participant
0 Kudos

Hi Kevin Hunter

You explanations looks really helpful. Currently I am dealing with this kind of scenario in my engagement. Can you please share the snap shot of MQTT source then Agent of the same source and then how notification are to be configured. It will be a real help I want to understand the configs as not much documentation . I am thinking of automating the versioned notification for MQTT topics from tag / tag group for this i just need to see how your notifications that you have configured in your answer Looks like with connection from source to agent to notification and destination.

your knowledge is greatly appreciated

Regards,

Kuntal Sarkar

Answers (0)