I have an API sensor as below
- platform: rest
name: pervasive_test
json_attributes:
- samples
resource: https://....
headers:
X-Api-Key: ....
value_template: "OK"
- platform: template
sensors:
ambient_temp:
value_template: "{{ state_attr('sensor.pervasive_test', 'samples')['1'] }}"
device_class: temperature
unit_of_measurement: "°C"
Putting this into the templating tool
{{ state_attr('sensor.pervasive_test', 'samples') }}
Results in the following output.
Result type: list
[
{
"0": 0,
"1": 15.928,
"2": 0,
"3": 0,
"4": 602.7,
"5": 1,
"6": 1,
"7": 1,
"8": 0,
"9": 2.9,
"10": 14,
"11": 0,
"12": 82,
"13": -17,
"14": 180769,
"15": 0,
"16": 0,
"17": 0,
"18": 0,
"19": -124388891,
"20": 512328398,
"21": -646.59,
"22": 0,
"23": 277.8,
"24": 3.95312,
"25": 14.9492,
"time": "2021-07-01T16:20:00+10:00"
}
]
the value after “1” (15.928) is a temperature which i would like as the value in “ambient_temp” sensor but my current template is giving a null response.