09-12-2023, 09:41 PM
(This post was last modified: 09-12-2023, 10:43 PM by iliaslamprou.)
Hi Joe,
It took me quite some time to figure out how to resolve this issue.
From the next update the function Virtuino.readValue will be able to read the Json message
This is an example:
It took me quite some time to figure out how to resolve this issue.
From the next update the function Virtuino.readValue will be able to read the Json message
This is an example:
Code:
/*
This script reads values from a Json
e.g. {"temperature":34.5, "room":"bedroom","state":true}
*/
//--- Copy values from Virtuino Variables to JavaScript variables
let inputValue = Virtuino.readValue("inputTag"); // read the json text
//--- enter the code here
const obj = JSON.parse(inputValue);
var value = obj.temperature;
var room = obj.room;
var state = obj.state;
result1 = '{"tag":"outputTag1", "value":'+value+'}';
result2 = '{"tag":"outputTag2", "value":"'+room+'"}';
result3 = '{"tag":"outputTag3", "value":"'+state+'"}';
result=[result1,result2,result3];