I have rest sensor which gets json array response. How I can get array value in template?
configuratuin.yaml:
sensor:
- platform: rest
scan_interval: 86400
name: nuki_lock_log
resource: https://api.nuki.io/smartlock/xxxx/log?limit=20
value_template: '{{ value_json[0]["smartlockId"] }}'
headers:
authorization: xxxx
- platform: template
sensors:
lock_log_last_name:
value_template: "{{ state_attr('sensor.nuki_lock_log', '')[1]['name'] }}"```
json response from api:
[
{
"id": "string",
"smartlockId": 0,
"deviceType": 0,
"accountUserId": 0,
"authId": "string",
"name": "string",
"action": 0,
"trigger": 0,
"state": 0,
"autoUnlock": true,
"date": "2022-02-03T17:49:17.993Z",
"openerLog": {
"activeCm": true,
"activeRto": true,
"source": 0,
"flagGeoFence": true,
"flagForce": true,
"flagDoorbellSuppression": true
},
"ajarTimeout": 0
},
{
"id": "string",
"smartlockId": 0,
"deviceType": 0,
"accountUserId": 0,
"authId": "string",
"name": "string",
"action": 0,
"trigger": 0,
"state": 0,
"autoUnlock": true,
"date": "2022-02-03T17:49:17.993Z",
"openerLog": {
"activeCm": true,
"activeRto": true,
"source": 0,
"flagGeoFence": true,
"flagForce": true,
"flagDoorbellSuppression": true
},
"ajarTimeout": 0
}
]
How can I get name from the first element in array?