Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
Hi,
I want to send a json data from Node MCU, and decode the data by thingworx service. Unfortunately, the service did not execute complitely.
Here are my service and the test data:
Service:
No input and output.
var obj = me.data;
var temperatureString = obj.T;
if(temperatureString != null){
me.Temperature = Number(temperatureString);
}
var humidityString = obj.H;
if(humidityString != null){
me.Humidity = Number(humidityString);
}
var airString = obj.A;
if(airString != null){
me.Air = Number(airString);
}
var pressureString = obj.P;
if(pressureString != null){
me.Pressure = Number(pressureString);
}
var windDirectionString = obj.D;
if(windDirectionString != null){
me.WindDirection = Number(windDirectionString);
}
var windSpeedString = obj.S;
if(windSpeedString != null){
me.WindSpeed = Number(windSpeedString);
}
var rainFallString = obj.R;
if(rainFallString != null){
me.RainFall = Number(rainFallString);
}
Test data:
{"T":"233","H":"233","P":"233","A":"233","S":"233","D":"233","R":"233"}
I save the json data in "data" propertity and I wrote a subscription to listen the "DataChange" event ------ execute the service.
Unfortunately, only temperature change to "233", others still looked like zero.
Here are the propertities and the permissions.
Solved! Go to Solution.
I would start by logging out each of the items you are assigning just to make sure they have a value.
It may be that the JSON is not being read the way you think it is.
I would start by logging out each of the items you are assigning just to make sure they have a value.
It may be that the JSON is not being read the way you think it is.
Hi Pai,
In fact, when I tested the service by clicked the button, all data changed to "233", but when I executed the service by listen the "DataChange" event, it did not execute complitely. Why?