Parsing JSON data into sensor and scraping for daily file

I’m hoping to get county data for Illinois in regards to coronavirus. The only data source I can seem to find is here: https://observablehq.com/@chicagoreporter/coronavirus-illinois-county-counts.

There’s a daily file I could possibly scrape for data, but I’m curious what the best route in getting this data displayed in HA. The two obstacles I need to overcome, in my opinion are:
- Pointing the data to a new URL depending on the day, due to the format of the JSON file:
. https://www.dph.illinois.gov/sites/default/files/COVID19/COVID19CountyResultsYYYYMMDD.json
- Ingesting this data and transforming / reading it into a sensor

Any thoughts? Any help is appreciated!

1 Like

Take a look at the scrape sensor, it may be what you need.

It’s a bit trickier than that. I changed the date in that URL to today’s date (20200330) and it failed because they don’t have today’s data ready yet. It works if I use yesterday’s date 20200329. That means you need to download the previous day’s data (which involves some date math).

The second challenge is that the RESTful sensor integration uses json_attributes to extract attributes from the received data and it’s not very flexible, especially given the complexity of this data. That means it limits you to using value_template to acquire one value (that will represent the sensor’s state) from the received data.

Maybe it would be just as useful and maybe easier to grab the map here and put it in an iframe card? Just not sure how to get the source url for the map.

http://dph.illinois.gov/topics-services/diseases-and-conditions/diseases-a-z-list/coronavirus

I don’t see a map at that link…?

This one mid page:

Weird…I don’t see that when I open the page. It’s just a big empty space there. And I didn’t see any reference to it looking in the page source code either.

I use this with a rest sensor to get vaccine data for my county

https://idph.illinois.gov/DPHPublicInformation/api/covidVaccine/getVaccineAdministration?countyName=Kankakee