Last active
April 26, 2021 19:12
-
-
Save xeophin/56275de5063e206fc50601a5634d8d79 to your computer and use it in GitHub Desktop.
Swiss Covid-19 Data Sensors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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