Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
Since I change to ThingWorx 8 I have a big trouble with setting property values via mqtt.
I send messages like this via mqtt to an thing (base type mqtt)
{ "temp":3.1,
"brightness":11.2,
"name":"climateSensor_3",
"humidity":5.3,
"pressure":6.4,
"CO2concentration":8.5 }
This message will set in a property of the thing named MQTTValue (type json). If MQTTValue change I call a subscriber which will set all properties of the think to the properties of the message:
var newVal = eventData.newValue.value;
me.temp = newVal.temp;
me.humidity = newVal.humidity;
...
I surrounded it by a try catch.
Everytime I get a mqtt message where a value is changed I get an null pointer exception at the set-line.
Example:
All properties of the climateSensor_3 thing are set to 10. Now a new mqtt message arrived where every property is also 10:
{ "temp":10.0,
"brightness":10.0,
"name":"climateSensor_3",
"humidity":10.0,
"pressure":10.0,
"CO2concentration":10.0 }
==> no exception
Now a other mqtt message arrived where one property is not the same like the old value:
{ "temp":20.0,
"brightness":10.0,
"name":"climateSensor_3",
"humidity":10.0,
"pressure":10.0,
"CO2concentration":10.0 }
==> null pointer exception in line "me.temp = newVal.temp;"
If the message would be like this:
{ "temp":10.0,
"brightness":20.0,
"name":"climateSensor_3",
"humidity":10.0,
"pressure":10.0,
"CO2concentration":10.0 }
I get the error on line "me.brightness = newVal.brightness;"
Another strange thing is I get the null pointer exception but the value is still changed.
Solved! Go to Solution.
Now I get it =)
In this post from Pai Chung: Visibility Permissions when logging properties helps me out. I have to add Visbility to the Persistence Provider of the ValueStream. Which is not so easy.
You have to go to your ValueStream and click on ThingworxPersistenceProvider and click on View. Than you must start the AddVisibilityPermission-Service of the PersistenceProvider:
principal: Everyone
principalType: Organization
After that the ValueStream will work
Maybe I have the issues but not the solution.
If I remove the ValueStream I don't get the null pointer exception. I tested it with other things and the same result. The ValueStream causes the trouble.
Now I try to
But this helps me not =(
Now I get it =)
In this post from Pai Chung: Visibility Permissions when logging properties helps me out. I have to add Visbility to the Persistence Provider of the ValueStream. Which is not so easy.
You have to go to your ValueStream and click on ThingworxPersistenceProvider and click on View. Than you must start the AddVisibilityPermission-Service of the PersistenceProvider:
principal: Everyone
principalType: Organization
After that the ValueStream will work