Parsing JSON from Wunderground Station

Hi all,

need a little help parsing the data from the Wunderground weather stations on:

Json URL

returns:

{"observations":[{"stationID":"ISCHWA83","obsTimeUtc":"2021-01-17T12:54:28Z","obsTimeLocal":"2021-01-17 13:54:28","neighborhood":"Massenbach","softwareType":"EasyWeatherV1.4.0","country":"DE","solarRadiation":38.5,"lon":9.069,"realtimeFrequency":null,"epoch":1610888068,"lat":49.164,"uv":0.0,"winddir":141,"humidity":93,"qcStatus":1,"metric":{"temp":0,"heatIndex":0,"dewpt":-1,"windChill":0,"windSpeed":0,"windGust":0,"pressure":1017.81,"precipRate":0.00,"precipTotal":0.00,"elev":207}}]}

now i like to get the solar radiation every 30 sec:

  - platform: rest
    resource: https://api.weather.com/v2/pws/observations/current?apiKey=6532d6454b8aa370768e63d6ba5a832e&stationId=ISCHWA83&format=json&units=m
    method: GET
    name: "Solar Radiation"
    value_template: '{{ value_json.observations.solarRadiation }}'
    unit_of_measurement: W/m²
    scan_interval: 30
    force_update: true

but no luck.
what am i doing wrong?

Thanks a lot!

As you can see, “observations”: is followed by a square bracket [ indicating a list/array.
Since there’s only one object in the list, we can just query it by looking for the 0th element:

  - platform: rest
    resource: https://api.weather.com/v2/pws/observations/current?apiKey=6532d6454b8aa370768e63d6ba5a832e&stationId=ISCHWA83&format=json&units=m
    method: GET
    name: "Solar Radiation"
    value_template: '{{ value_json.observations[0].solarRadiation }}'
    unit_of_measurement: W/m²
    scan_interval: 30
    force_update: true

stupid mistake! :man_facepalming:t3:

Thank you @fedot