Hello all,
I spent the afternoon finding new data sources for my coronavirus card. I liked to display more local numbers in the process (for the anticipation of the day when life starts again :D).
I’m not reinventing the wheel here, but use some sources that don’t show up here in the forum yet, so I’m posting this as a new thread.
(Inspiration can also be found here)
Example-Dataset:
Helpful Tools:
- JSONPath Online Evaluator: https://jsonpath.com/
- JSON-Selector: http://jsonselector.com/
Parse RESTful JSON-Data:
sensor:
##############################################################
##
## Fallzahlen Deutschland
##
##############################################################
- platform: rest
name: "Germany Coronavirus BRD Risklayer"
resource: https://services.arcgis.com/ObdAEOfl1Z5LP2D0/ArcGIS/rest/services/Corona_Risklayer_Kreisebene/FeatureServer/0/query?where=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&resultType=none&distance=0.0&units=esriSRUnit_Meter&returnGeodetic=false&outFields=&returnGeometry=true&returnCentroid=false&featureEncoding=esriDefault&multipatchOption=xyFootprint&maxAllowableOffset=&geometryPrecision=&outSR=&datumTransformation=&applyVCSProjection=false&returnIdsOnly=false&returnUniqueIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&returnQueryGeometry=false&returnDistinctValues=false&cacheHint=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=%5B%7B%22statisticType%22%3A%22sum%22%2C%22onStatisticField%22%3A%22cases%22%2C%22outStatisticFieldName%22%3A%22cases%22%7D%2C%0D%0A%7B%22statisticType%22%3A%22sum%22%2C%22onStatisticField%22%3A%22cases_current%22%2C%22outStatisticFieldName%22%3A%22cases_current%22%7D%2C%0D%0A%7B%22statisticType%22%3A%22sum%22%2C%22onStatisticField%22%3A%22recovered%22%2C%22outStatisticFieldName%22%3A%22recovered%22%7D%2C%0D%0A%7B%22statisticType%22%3A%22sum%22%2C%22onStatisticField%22%3A%22death%22%2C%22outStatisticFieldName%22%3A%22death%22%7D%2C%0D%0A%7B%22statisticType%22%3A%22sum%22%2C%22onStatisticField%22%3A%22cases_new_7d%22%2C%22outStatisticFieldName%22%3A%22cases_new_7d%22%7D%2C%0D%0A%7B%22statisticType%22%3A%22sum%22%2C%22onStatisticField%22%3A%22EWZ%22%2C%22outStatisticFieldName%22%3A%22EWZ%22%7D%5D&having=&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&returnExceededLimitFeatures=true&quantizationParameters=&sqlFormat=none&f=pjson&token=
json_attributes_path: $.features[0].attributes
json_attributes:
- cases
- recovered
- cases_current
- death
- cases_new_7d
- EWZ
value_template: 'OK'
- platform: rest
name: "Germany Coronavirus BRD Risklayer timestamp"
resource: https://services.arcgis.com/ObdAEOfl1Z5LP2D0/ArcGIS/rest/services/Corona_Risklayer_Kreisebene/FeatureServer/0/query?where=1%3D1&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&resultType=none&distance=0.0&units=esriSRUnit_Meter&returnGeodetic=false&outFields=last_update&returnGeometry=false&returnCentroid=false&featureEncoding=esriDefault&multipatchOption=xyFootprint&maxAllowableOffset=&geometryPrecision=&outSR=&datumTransformation=&applyVCSProjection=false&returnIdsOnly=false&returnUniqueIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&returnQueryGeometry=false&returnDistinctValues=false&cacheHint=false&orderByFields=last_update&groupByFieldsForStatistics=&outStatistics=&having=&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&returnExceededLimitFeatures=true&quantizationParameters=&sqlFormat=none&f=pjson&token=
value_template: '{{ (value_json.features[-1].attributes.last_update | int / 1000) | timestamp_local }}'
- platform: template
sensors:
germany_coronavirus_brd_risklayer_cases7_per_100k:
value_template: "{{ ((state_attr('sensor.germany_coronavirus_brd_risklayer', 'cases_new_7d') | int) / (state_attr('sensor.germany_coronavirus_brd_risklayer', 'EWZ') | int / 100000)) | round(0) }}"
##############################################################
##
## Fallzahlen Köln
##
##############################################################
- platform: rest
name: "Germany Coronavirus Cologne Risklayer"
resource: https://services.arcgis.com/ObdAEOfl1Z5LP2D0/arcgis/rest/services/Corona_Risklayer_Kreisebene/FeatureServer/0/query?where=ags=05315&returnGeometry=false&f=json&outFields=%22*%22
json_attributes_path: $.features[0].attributes
json_attributes:
- cases
- recovered
- cases_current
- death
- cases_new_7d_per_100k
value_template: '{{ (value_json.features[0].attributes.last_update | int / 1000) | timestamp_local }}'
device_class: timestamp
- platform: rest
name: "Germany Coronavirus Cologne DIVI"
resource: https://services7.arcgis.com/mOBPykOjAyBO2ZKk/ArcGIS/rest/services/DIVI_Intensivregister_Landkreise/FeatureServer/0/query?where=AGS=05315&f=json&returnGeometry=false&outFields=%22*%22
json_attributes_path: $.features[0].attributes
json_attributes:
- betten_frei
- betten_belegt
- betten_gesamt
- Anteil_betten_frei
- faelle_covid_aktuell
- faelle_covid_aktuell_beatmet
- Anteil_covid_beatmet
- Anteil_COVID_betten
- daten_stand
value_template: '{{ as_timestamp(strptime(value_json.features[0].attributes.daten_stand,"%d.%m.%Y %M:%H Uhr")) | timestamp_local }}'
device_class: timestamp
- platform: rest
name: "Germany Coronavirus Cologne RKI"
resource: https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=AGS=05315&f=json&returnGeometry=false&outFields=%22*%22
json_attributes_path: $.features[0].attributes
json_attributes:
- cases
- death
- cases7_per_100k
value_template: '{{ as_timestamp(strptime(value_json.features[0].attributes.last_update,"%d.%m.%Y, %M:%H Uhr")) | timestamp_local }}'
device_class: timestamp
Generating some Sensors from the data:
sensor:
- platform: template
sensors:
cologne_coronavirus_risklayer_cases:
value_template: "{{ state_attr('sensor.germany_coronavirus_cologne_risklayer', 'cases') }}"
friendly_name: 'Bestätigt'
unit_of_measurement: 'Fälle'
- platform: template
sensors:
cologne_coronavirus_risklayer_current:
value_template: "{{ state_attr('sensor.germany_coronavirus_cologne_risklayer', 'cases_current') }}"
friendly_name: 'Aktuell'
unit_of_measurement: 'Fälle'
- platform: template
sensors:
cologne_coronavirus_risklayer_death:
value_template: "{{ state_attr('sensor.germany_coronavirus_cologne_risklayer', 'death') }}"
friendly_name: 'Tote'
unit_of_measurement: 'Fälle'
- platform: template
sensors:
cologne_coronavirus_risklayer_cases7_per_100k:
value_template: "{{ state_attr('sensor.germany_coronavirus_cologne_risklayer', 'cases7_per_100k') }}"
friendly_name: '7-Tage-Inzidenz'
unit_of_measurement: 'Fälle/100k'
- platform: template
sensors:
cologne_coronavirus_divi_beds_sum:
value_template: "{{ state_attr('sensor.germany_coronavirus_cologne_divi', 'betten_gesamt') }}"
friendly_name: 'Intenisivbetten'
unit_of_measurement: 'Fälle'
- platform: template
sensors:
cologne_coronavirus_divi_beds_free:
value_template: "{{ state_attr('sensor.germany_coronavirus_cologne_divi', 'betten_frei') }}"
friendly_name: 'Intenisivbetten'
unit_of_measurement: 'Fälle'
- platform: template
sensors:
cologne_coronavirus_divi_beds_covid:
value_template: "{{ state_attr('sensor.germany_coronavirus_cologne_divi', 'faelle_covid_aktuell') }}"
friendly_name: 'Stationär'
unit_of_measurement: 'Fälle'
- platform: template
sensors:
cologne_coronavirus_rki_cases7d:
value_template: "{{ state_attr('sensor.germany_coronavirus_cologne_rki', 'cases7_per_100k') | round(0) }}"
friendly_name: '7-Tage-Inzidenz'
unit_of_measurement: 'Fälle'
These are my Lovelace-Cards:
type: vertical-stack
cards:
- entities:
- entities:
- attribute: cases
name: Bestätigt
- attribute: death
name: Tote
- entity: sensor.germany_coronavirus_brd_risklayer_cases7_per_100k
name: 7T.-Inz
entity: sensor.germany_coronavirus_brd_risklayer
icon: 'mdi:virus'
name: Deutschland
secondary_info:
entity: sensor.germany_coronavirus_brd_risklayer_timestamp
format: relative
name: false
show_state: false
type: 'custom:multiple-entity-row'
- entities:
- entity: sensor.cologne_coronavirus_risklayer_cases
name: Bestätigt
unit: false
- entity: sensor.cologne_coronavirus_risklayer_current
name: Aktuell
unit: false
- entity: sensor.cologne_coronavirus_risklayer_death
name: Tote
unit: false
- entity: sensor.cologne_coronavirus_risklayer_cases7_per_100k
name: 7T.-Inz.
unit: false
icon: 'mdi:virus'
name: Köln
entity: sensor.germany_coronavirus_cologne_risklayer
secondary_info:
entity: sensor.germany_coronavirus_cologne_risklayer
format: relative
name: false
show_state: false
type: 'custom:multiple-entity-row'
type: entities
header:
type: picture
image: local/img/header_coronavirus.png
- entities:
- color: red
entity: sensor.cologne_coronavirus_risklayer_current
name: Aktuell
- color: black
entity: sensor.cologne_coronavirus_risklayer_death
name: Tote
hour24: true
name: Fallzahlen in Köln
unit: Fälle
show:
labels: true
type: 'custom:mini-graph-card'
hours_to_show: 168
points_per_hour: 0.25
icon: 'mdi:clipboard-account'
- entities:
- color: orange
entity: sensor.cologne_coronavirus_divi_beds_covid
name: Covid19
- color: purple
entity: sensor.cologne_coronavirus_divi_beds_sum
name: Gesamt
- color: green
entity: sensor.cologne_coronavirus_divi_beds_free
name: Frei
hour24: true
name: Intensivbetten in Köln
unit: Betten
show:
labels: true
type: 'custom:mini-graph-card'
hours_to_show: 168
points_per_hour: 0.25
icon: 'mdi:bed'
I hope that I could facilitate the search for appropriate data or the preparation for some.
Have fun with it!