Im trying to parse JSON response from my home automation system in javscript. The response is available here
That is only a small part of the response, also, the order of keys changes on every reboot for reasons i do not know, su using the the number index wont really work i need to be able to store the state value of sensor.out, sensor.in, sensor.door into variables for tasker on andorid i tried to select using the entity.id, but for some reason the code never finished ( i believe i just didnt know what i was doing)
With ES6 you can use the
Array#find
method:See snippet:
Alternatively, you could convert the response to an object with the entity id values as keys, so you can access it like
response['session.out'].state
:See snippet: