Value Template for json curl response

Hey

I am trying to extract the state of a relay on my Suprema BioEntry W2 using the ‘new’ Biostar 2 API

when running the command

curl -kX POST "https://172.16.0.19/api/doors/status" -H "accept: application/json" -H "bs-session-id: apikeyhere" -H "Content-Type: application/json" -d "{ \"monitoring_permission\": true}"

I get the response:

{"DoorStatusCollection":{"rows":[{"door_id":{"id":"1"},"opened":"false","unlocked":"true","last_open_time":"0","alarm":"0","status":"2048","alarm":"2048"}],"total":"1"},"DeviceResponse":{"rows":[{"id":"544110530","code":"0"}],"result":"true"},"Response":{"code":"0","link":"https:\/\/support.supremainc.com\/en\/support\/home","message":"Success"}}

I have tried with my value template set as a number of things, ending up at:

      value_template: '{{ DoorStatusCollection.rows.door_id.1.unlocked == "false" }}'

But it is still not working :frowning:

Can anybody help me to understand this please?

value_template: '{{ value_json["DoorStatusCollection"]["rows"][0]["unlocked"] == "false" }}'

Paste your json response on the right in this tool and drill down on the left to check the path:

https://jsonpathfinder.com/

1 Like

Thank you so much ! its working now :slight_smile:

1 Like