Hello,
i connected a wincc datapoint to a mqtt broker using the mqtt driver (subscribe). The plain text messages are exchanged without problems, but not the messages with json-profile. I need that to load the correct time stamp into WinCC OA database. But all i get is an error: wrong Json-format.
WCCOAmqtt (1), 2020.01.20 17:48:01.998, SYS, SEVERE, 6/mqtt, _testAIOLOS - Falsches Json-format! Main connection Topic: topic_text Nachricht: {'Value': 'hello', 'Time': '2020-01-20T17:23:25.000Z'}
What have i done wrong?
Best Regards
MQTT wrong JSON-format
- leoknipp
- Posts:2928
- Joined: Tue Aug 24, 2010 7:28 pm
Re: MQTT wrong JSON-format
Which WinCC OA version and patch level are you using?
Do you want to receive from or send values to the MQTT broker in that case?
Best Regards
Leopold Knipp
Senior Support Specialist
Do you want to receive from or send values to the MQTT broker in that case?
Best Regards
Leopold Knipp
Senior Support Specialist
- n.kuehl
- Posts:28
- Joined: Mon Mar 18, 2019 9:35 am
Re: MQTT wrong JSON-format
I am using the demo version of the new published WinCC OA 3.17 for test purposes. Patch Level 0 I think (see the link below). I want to receive data.
In the first step I set up a broker (Mosquitto). Then I connected two WinCC datapoints to the server, one for publish and one for subscribing. That worked well for the plain text format, I was able to send data through the broker and receive it. In the next step I have written a simple JavaScript doing the same thing: works well. Also with sending data in JSON-format. Then I wanted to test my actual case: Sending values with a timestamp from a JavaScript via MQTT to WinCC OA. That worked with plain text, but not with the JSON-profiles.
Did I something wrong?
Best Regards
https://www.winccoa.com/downloads/detai ... on%5D=show
In the first step I set up a broker (Mosquitto). Then I connected two WinCC datapoints to the server, one for publish and one for subscribing. That worked well for the plain text format, I was able to send data through the broker and receive it. In the next step I have written a simple JavaScript doing the same thing: works well. Also with sending data in JSON-format. Then I wanted to test my actual case: Sending values with a timestamp from a JavaScript via MQTT to WinCC OA. That worked with plain text, but not with the JSON-profiles.
Did I something wrong?
Best Regards
https://www.winccoa.com/downloads/detai ... on%5D=show
- leoknipp
- Posts:2928
- Joined: Tue Aug 24, 2010 7:28 pm
Re: MQTT wrong JSON-format
You can possibly use the following approach:
-- Send data (JSON format including timestamp information) from WinCC OA to your JavaScript application
-- Check how the timestamp is formatted
-- Use the same format when sending data to WinCC OA
Best Regards
Leopold Knipp
Senior Support Specialist
-- Send data (JSON format including timestamp information) from WinCC OA to your JavaScript application
-- Check how the timestamp is formatted
-- Use the same format when sending data to WinCC OA
Best Regards
Leopold Knipp
Senior Support Specialist
- n.kuehl
- Posts:28
- Joined: Mon Mar 18, 2019 9:35 am
Re: MQTT wrong JSON-format
The format was correct. It looks like the order is critical to the json. First timestamp, then value. @etm: That's not how json works...