Extract Value from jason (?) for gas prices

Dear Community,

I´m trying to extract the prices value from following file.

https://api.e-control.at/sprit/1.0/search/gas-stations/by-address?latitude=48.2031166&longitude=16.3378803&fuelType=DIE&includeClosed=false

what seems a bit strange is the beginning [ ]

I tried following combinations:

- platform: rest
    method: GET
    name: Diesel
    resource: https://api.e-control.at/sprit/1.0/search/gas-stations/by-address?latitude=48.2031166&longitude=16.3378803&fuelType=DIE&includeClosed=false
    value_template: '{{ value_json[0].prices.amount }}'
    #value_template: '{{ value_json.prices.amount }}'
    #value_template: '{{ value_json.prices[0].amount }}'
    #value_template: '{{ value_json.prices.amount[0] }}'
    json_attributes:
      - prices

Any help would be very appreciated!

Thanks and have a nice day
Philipp

Try this:

    resource: https://api.e-control.at/sprit/1.0/search/gas-stations/by-address?latitude=48.2031166&longitude=16.3378803&fuelType=DIE&includeClosed=false
    value_template: '{{ value_json[0].prices[0].amount }}'

Thanks. That did the trick!

1 Like