Rest doesn't work for a specific API

Trying to get COVID-19 stats from an API that works fine for this one:

- platform: rest
  name: NRW
  resource: "https://api.corona-zahlen.org/states/NW"
  value_template: "{{ value_json.data.NW.weekIncidence | int }}"

But doesn’t for this one

- platform: rest
  name: Saar
  resource: "https://api.corona-zahlen.org/districts/10041"
  value_template: "{{ value_json.data.10041.weekIncidence | int }}"

The only difference I could see is that the value_Template contains a part with only numbers? Might this be a problem? And if so, is there a workaround? Debug only gives me the information that HA gets the same information as I’m getting in the browser, nothing related to some kind of parsing error.

Just tested and this works for me:

  - platform: rest
    name: Saar
    resource: "https://api.corona-zahlen.org/districts/10041"
    value_template: "{{ value_json.data['10041']['weekIncidence'] | int }}"
1 Like

Works perfect! THX for your help!

I wonder whether there is way to get all the delivered values as attributes in a sensor.
Any idea?

yes, using json_attributes_path and specifying the attributes in json_attributes. All covered in the docs and in the examples in the docs for rest sensors & rest.

1 Like

Hmm. Thanks for the quick answer.
I will try but I am really a newby and I hope I manage this ^^