Hi,
Trying to decode a message from mqtt that contains several values like this one:
{"CurrentLevel":1000,"DeviceId":18,"DeviceName":"_Light Sensor","DeviceType":"urn:schemas-micasaverde-com:device:LightSensor:1","OldCurrentLevel":0,"RoomId":1,"RoomName":"Garage","ServiceId":"urn:micasaverde-com:serviceId:LightSensor1","Time":1487402816,"Variable":"CurrentLevel"}
I created a script that can read one value that I use like this:
In Items I have this:
Number Lightlevel “Light [%d] Lux” (all) {mqtt=“<[skynet:survey/Events/_Light Sensor:state:JS(getVeraMqtt.js)]”}
And in the script file getVeraMqtt.js:
(function(csv) {
var arr = csv.split(“,”);
var ret = arr[0].split(“:”);
return ret[1];
})(input);
That return 1000 and thats good.
I would like to return a array with all the values: Can I do that and if so how do I do that?