cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Extract data from json by using a subscription

Lenn
8-Gravel

Extract data from json by using a subscription

Hi,

I'm currently using MQTT to send sensor data to the thingworx platform. The data is in json format and looks like this: 

{"tire_pressure":4.7,"speed":55,"timestamp":"2020-05-07 11:25:19.971","status":"success","vehicle":"car"}

 

In the MQTT master template I created a property called Speedometer which receives this json data. Now, I'm trying to extract the data by using another property (called Speed, base type: int) which subscribes to the Speedometer. The subscription looks like this: 

me.Speed = me.Speedometer.speed;

 

But the property Speed doesn't change it's value. Do you know how to solve this?

 

 

 

 

ACCEPTED SOLUTION

Accepted Solutions
rjanardan
16-Pearl
(To:Lenn)

me.Speed= me.Speedometer["speed"];

View solution in original post

4 REPLIES 4
rjanardan
16-Pearl
(To:Lenn)

me.Speed= me.Speedometer["speed"];

Lenn
8-Gravel
(To:rjanardan)

Thanks a lot!

Unfortunately it worked only once. Now I have always the same value for Speed but the Speedometer json changes every 5 seconds

rjanardan
16-Pearl
(To:Lenn)

Is the JSON property getting updated in ThingWorx as well?

Are you using MQTT extension?Which version? Also, have you enabled SSL for communication with the broker?

Please check the logs for any error message. 

Lenn
8-Gravel
(To:rjanardan)

I found the problem. I had to change the visibility in the permissions. 

Now it's working!

 

Thank you!

Announcements


Top Tags