Hi, my RESTFul integration calls an API that returns a JSON array. I want to save this data as a sensor so I can later use it in templating.
When I try the below code, the sensor state becomes ‘unknown’, but if I change it to 'value_json[0]'
it will return the first element of the array just fine. What’s the problem and how do I return the entire array?
This does not work:
rest:
- resource: https://jsonplaceholder.typicode.com/todos
scan_interval: 60
sensor:
- name: "entirearray"
value_template: "{{ value_json }}"
But this does:
rest:
- resource: https://jsonplaceholder.typicode.com/todos
scan_interval: 60
sensor:
- name: "entirearray"
value_template: "{{ value_json[0] }}"