I want to configure a RESTful sensor to retrieve values from RESTful API.
How do I get the “state” value and “time_last_updated”? I don’t get it!
- platform: rest
resource: http://127.0.0.1:8123/api/history/period/2018-01-08T00:00:00+01:00?filter_entity_id=sensor.temperature&end_time=2018-01-08T01%3A00%3A00%2B01%3A00
name: Temp
value_template: '{{ value_json.[0].[0].state() }}'
json_attributes:
- attributes.time_last_updated
unit_of_measurement: '*'
headers:
x-ha-access: xxxx
User-Agent: Home Assistant
Content-Type: application/json
scan_interval: 120
[[{"attributes": {"assumed_state": true, "friendly_name": "Temp", "icon": "mdi:power-plug", "time_last_updated": "2018-01-07 18:24:24", "unit_of_measurement": ""}, "entity_id": "sensor.temperature", "last_changed": "2018-01-07T23:00:00+00:00", "last_updated": "2018-01-07T23:00:00+00:00", "state": "0.1"}, {"attributes": {"assumed_state": true, "friendly_name": "Temp", "icon": "mdi:power-plug", "time_last_updated": "2018-01-07 18:24:24", "unit_of_measurement": ""}, "entity_id": "sensor.temperature", "last_changed": "2018-01-07T23:01:06.597223+00:00", "last_updated": "2018-01-07T23:01:06.597223+00:00", "state": "0.1"}]]
How should i format ‘{{ value_json.[0].[0].state() }}’ and attributes.time_last_updated?