Need help with REST-Sensor with ressource-template

This is driving me nuts!

I have this definition:

  - name: bright_sky_rest
    platform: rest
    resource_template: https://api.brightsky.dev/weather?date={{ now().strftime('%Y-%m-%dT%H:00+02:00') }}&last_date={{ now().strftime('%Y-%m-%dT%H:00+02:00') }}&dwd_station_id=00403
    json_attributes_path: "$.weather"
    value_template: "OK"
    scan_interval: 900
    json_attributes:
      - timestamp
      - temperature

If check the resource_template in the template-debugger it renders the URL correctly and opening the resulting URL in the browser gets a valid JSON-response.

However the sensor just generates the following error in the logger:

JSON result was not a dictionary or list with 0th element a dictionary

I tried quoting, urlencode, etc. but nothing works.

Any Idea whats going on?

Of course, how else should this be. I’ve been racking my brain for hours on this, and right after posting this I saw, that the “Weather”-Node in the JSON response was a list, so the attribute path should have been something like this

json_attributes_path: "$.weather[0]"

to get the first item.

Work now, thanks for your help :grinning:

And another correction:
I actually have to urlencode the templates like this:

https://api.brightsky.dev/weather?date={{ now().strftime('%Y-%m-%dT%H:00+02:00')|urlencode }}&last_date={{ now().strftime('%Y-%m-%dT%H:00+02:00')|urlencode }}&dwd_station_id=00403

otherwise the api will return the wrong results.