I finally setup and parse JSON in different way, but I need to do one external query for each sensor, and couldn’t find the right way to process the json_attributes.
- platform: rest
name: Estado Model X
resource: https://www.teslafi.com/feed.php?token=SOME-TOKEN
value_template: '{{ value_json.state }}'
scan_interval: 60
- platform: template
sensors:
longitude:
value_template: '{{ states.sensor.state.attributes.longitude }}'
friendly_name: 'Longitud'
latitude:
value_template: '{{ states.sensor.state.attributes.latitude }}'
friendly_name: 'Latitud'
- platform: rest
name: Nivel de batería Model X
resource: https://www.teslafi.com/feed.php?token=SOME-TOKEN
value_template: '{{ value_json.battery_level }}'
unit_of_measurement: "%"
scan_interval: 60
- platform: rest
name: Temperatura interior Model X
resource: https://www.teslafi.com/feed.php?token=SOME-TOKEN
value_template: '{{ value_json.inside_temp }}'
unit_of_measurement: "ºC"
scan_interval: 60
- platform: rest
name: Temperatura exterior Model X
resource: https://www.teslafi.com/feed.php?token=SOME-TOKEN
value_template: '{{ value_json.outside_temp }}'
unit_of_measurement: "ºC"
scan_interval: 60
I can see all the data in dev-tools except for the json-attributes: latitude and longitude. I see them as ‘unknow’ and in the log I see this:
2017-12-18 11:13:34 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template Latitud, the state is unknown.
2017-12-18 11:13:35 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template Longitud, the state is unknown.
I can’t help with the last 2 questions but I can where you are going wrong on the lat/long, they have to be decoded from the json the same way the rest of the values (for battery, temp, state etc) were retrieved value_template: ‘{{ value_json.longitude }}’, they are not attributes they are just part of the json message.
platform: file
name: Tesla inne temperatur
file_path: /home/thomas/.homeassistant/teslafi.json
value_template: ‘{{ value_json.inside_temp }}’
unit_of_measurement: ‘°C’