Taking parsed JSON and putting it into a Project Variable

Iain Brew 4 months ago • updated by Aleksandr Romanov (CTO) 3 months ago 2

With thanks to this forum, I have been able to solve many issues with my current project. I have everything working perfectly now (using Philips Hue Dimmer switches to trigger various events/drivers etc in my system) however the only thing left which is stumping me is the ability to take a requested and parsed JSON value and have it written to a Server Channel/Tag:

//Get "temperature" number from motion sensor
            // SENSOR 2 TEMPERATURE
            var getTemperature = sensor2.state["temperature"];
            var tempreadout2 = getTemperature.toString();
            tempreadout2 = tempreadout2.slice(0,2) + "." + tempreadout2.charAt(2) + " ºC";
            IR.SetVariable("Server.Tags.Lab1_Temperature", "tempreadout2");

Here I request the temperature from a Philips Motion Sensor. When testing this on a panel project, I was able to send 'tempreadout2' to a text field and it worked. Instead, I want to send this to a Server Tag (named Lab1_Temperature) so that it can appear on any control panel subscribed to that feedback channel. 

What is the best way to 'insert' that text?

Under review

To solve your problem with JSON, you may find these projects useful as an example.