Hey all, I’m by no means an expert at home assistant but so far have seemed to struggle my way through most things but this one is stumping me.
I’m trying to learn more about how to parse a JSON API response using the RESTful api integration. I currently have something working with the below configuration but I’d like to be able to parse not based on the array position but filter by specific attributes so that if the endpoint response changes it doesn’t break my sensor.
Here is my example using Template Editor in Developer Tools. Once you get it right you just need to change (value_json | from_json).value_json to value_json before using in RESTful. This assumes that there will only ever be one dataset entry of 154 in json and one parameter_id of 2570 in parameters of that dataset as the template is using | first for both.
When developing a template like this, if I am not sure what a jinja interator (like selectattr) is outputting I just use | list to have a look, then adjust my next filter.
@chrisolson91 — you might find you have problems with a 438kB response. Might need to use a Command Line sensor with curl and jq to cut it down a bit first.