Skip to content

Instantly share code, notes, and snippets.

@xeophin
Last active Apr 26, 2021
Embed
What would you like to do?
Swiss Covid-19 Data Sensors
rest:
# This downloads the URLs of the current data files
- resource: https://www.covid19.admin.ch/api/data/context
# Checks every 6 hours. The data changes every 24 hours, so maybe this is too much
# Your mileage may vary, etc.pp.
scan_interval: 21600
sensor:
- name: "Covid Data Sources"
json_attributes_path: "$.sources.individual.json.daily"
value_template: "OK"
json_attributes:
- "cases"
- "re"
# The following two integrations download the actual data
- resource_template: >-
{{ state_attr('sensor.covid_data_sources', 'cases') }}
scan_interval: 21600
sensor:
- name: "14-Tage-Inzidenz"
# Change 'ZH' to another value, if you'd like to have the Data from all Switzerland ('CH')
# or from another canton
value_template: >-
{% set items = value_json | selectattr('geoRegion', 'eq', 'ZH') | selectattr('inzsum14d', 'defined') | sort(attribute='datum') | list | last %}
{{ items['inzsum14d']|float }}
unit_of_measurement: '14d-Inz'
- resource_template: >-
{{ state_attr('sensor.covid_data_sources', 're') }}
scan_interval: 21600
sensor:
- name: "R-Wert"
value_template: >-
{% set items = value_json | selectattr('geoRegion', 'eq', 'ZH') | selectattr('median_R_mean', 'defined') | sort(attribute='date') | list | last %}
{{ items['median_R_mean']|float }}
unit_of_measurement: 'Re'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment