![]() The next step would be to figure out what you need to send to MQTT to get the device to change state. You only want/need one broker connection String HVACStatus "Hvac mode" 1 Possible duplicate of Safely turning a JSON string into an object T.Todua at 14:33 Add a comment 10 Answers Sorted by: 170 Javascript has a built in JSON parse for strings, which I think is what you have: var myObject JSON. The items would look like depending on you broker name. ![]() Note I put in Mapping as per json string supplied. Javascript has a built in JSON parse for strings, which I think is what you have: var myObject JSON. How to convert JSON string to array of JSON objects using JavaScript 3. Properties.Status", commandTopic = "SOMETHING", On="ON", Off="OFF" ] What is difference between JSON.parse() and JSON.stringify() Methods in JavaScript 2. Properties.Status", commandTopic = "SOMETHING", On="ON", Off="OFF" ] Properties.Temperature", commandTopic ="SOMETHING" ] Type number : temperature "Set Temperature". Properties.Status", commandTopic = "SOMETHING" ] If the provided parameter is not valid JSON, the JSON.parse method throws a Syntaćrror exception. The method parses a JSON string and returns its JavaScript value or object equivalent. Its an example of what you want maybe not the solution as you asked how to do it in a suggestion is how I would do it in the first place if the OP question was different. Use the JSON.parse() method to parse a JSON array, e.g. Try it Syntax JSON.stringify(value) JSON.stringify(value, replacer) JSON. Then you can just do another rule with the data coming in you just go to know the difference between update and command rule "Device 3 status changes" The JSON.stringify () static method converts a JavaScript value to a JSON string, optionally replacing values if a replacer function is specified or optionally including only the specified properties if a replacer array is specified. Val Device_3_Type = transform("JSONPATH", = 'Device_3')].Properties.Type", Incoming_) Val Device_3_Status = transform("JSONPATH", = 'Device_3')].Properties.Status", Incoming_) Browser Support The numbers in the table specify the first browser version that fully supports the method. The JSON.parse () method can optionally transform the result with a function. The string has to be written in JSON format. Val Device_2_Type = transform("JSONPATH", = 'Device_2')].Properties.Type", Incoming_) Description The JSON.parse () method parses a string and returns a JavaScript object. Val Device_2_Status = transform("JSONPATH", = 'Device_2')].Properties.Status", Incoming_) Val Device_1_Type = transform("JSONPATH", = 'Device_1')].Properties.Type", Incoming_) Val Device_1_Temperature = transform("JSONPATH", = 'Device_1')].Properties.Temperature", Incoming_) Val Device_1_Status = transform("JSONPATH", = 'Device_1')].Properties.Status", Incoming_) Something like rule "Transform json message to devices" ![]() You probably already figured it out but you just ask for specific peace of data you want. ![]()
0 Comments
Leave a Reply. |