Hi all,
Prolly a dumb question but im really confused about it. I have a Vera Edge and im doing a custom interface using HTML/JS as a personal proyect.
When i pull an object using JSON tru lets say IP_ADDRESS:3480/data_request?id=status, the object i get is similiar to this structure
OBJECT
DEVICES: Array[16]
0:Object
1:Object
3:Object
ID: 12
states: Array [7]
0:Object
Variable:status
value:1
…
So the code i have to pull the light status for each of the lights of certain room is like this
var kitchen_lights = [12,13,14] // These are the IDS
function pull_light_status (kitchen_lights) {
$.getJSON( “resources/php/getjson.php”, function( json ) {
var vera_obj = json;
$.each(kitchen_lights,function(myindex, myvalue){
var light_status = vera_obj.devices[myvalue].states[0].value;
})
})
}
So with this i just pulled the light status of the Objects 12,13,14 and NOT IDs 12,13,14 …
So my question is, if there is any way i can do this in an easier way? Maybe get an object from the JSON sorted by IDs or something like that?
anyways, any help will be greatly appreciated
thanks,