How to configure value_template to extract data from JSON array without name

You can use top level arrays.

Use this tool to get the path to the data you want. Just replace x with value_json

https://jsonpathfinder.com/

You can get all the temperature sensors with the one rest call using the new rest integration rather than the rest sensor platform. No template sensors required:

rest:
  - resource: http://192.168.2.3/get/json/v1/1/temps
    scan_interval: 60
    sensor:
      - name: "DG Bad" #change this to what you want
        value_template: "{{ value_json[0].raeume[0].temperatur }}"
        device_class: temperature
        unit_of_measurement: "°C"
      - name: "DG Lena" #change this to what you want
        value_template: "{{ value_json[0].raeume[1].temperatur }}"
        device_class: temperature
        unit_of_measurement: "°C"
      - name: "OG Bad" #change this to what you want
        value_template: "{{ value_json[1].raeume[0].temperatur }}"
        device_class: temperature
        unit_of_measurement: "°C"
      - name: "OG Schlafzimmer" #change this to what you want
        value_template: "{{ value_json[1].raeume[1].temperatur }}"
        device_class: temperature
        unit_of_measurement: "°C"
3 Likes