Json_attributes - How to extract

Here the example data.
Because the resultset is very long and I’m only interested in two numbers, I don’t want to call the uri two times and I would like to avoid to store the whole states object.
The data I’m interested in:

  • data / vaccinated
  • data / states / NW / vaccinated

Here is my starting point:

- platform: rest
  name: RKI-Covid-Vaccinated
  resource: https://api.corona-zahlen.org/vaccinations
  json_attributes_path: "$.data"
  json_attributes:
    - vaccinated
    - states
  value_template: "OK"  # To allow more than 255 characters return value

- platform: template
  sensors:
    rki_covid_nrw_vaccinated:
      value_template: '{{ states.sensor.rki_covid_vaccinated.attributes.states.NW.vaccinated}}'

How would I avoid to store the huge sensor.rki_covid_vaccinated object?
Is there a way to have a json_attributes selector to get sub objects like states/NW?

Don’t use the RESTful Sensor. Rather, use the RESTful Integration.

rest:
  - resource: https://api.corona-zahlen.org/vaccinations
    sensor:
      - name: vaccinated_all
        value_template: "{{ value_json.data.vaccinated }}"
      - name: vaccinated_nw
        value_template: "{{ value_json.data.states.NW.vaccinated }}"
1 Like

Edit:
Found that this is a known issue and is solved in 2021.4.0.

How would I get values from two different resources?
With this test sensors I get two test_r sensors but no test_v.
What’s wrong?

rest:
  - resource: https://api.corona-zahlen.org/vaccinations
    sensor:
      - name: test_v
        value_template: "{{ value_json.data.vaccinated | int }}"  

  - resource: https://api.corona-zahlen.org/germany
    sensor:
      - name: test_r
        # json_attributes_path: "$"
        value_template: "{{ value_json.recovered | int }}"