0.106.3: Coronavirus integration (COVID-19), track the outbreak

@scstraus, Thanks for the alternate solution! I will add this.

1 Like

Hi all

the solution proposed above by @scstraus works. However, the API which scrapes data from worldometers.info does not factor in that countries are ranked based on some criteria, which leads to country-specific json queries (e.g. https://covid-19-apis.herokuapp.com/update/country/23) to point towards a different country when such a displacement occurs.

The snippet below uses the all countries aggregate endpoint (https://covid-19-apis.herokuapp.com/allUpdate) and finds the correct country. So far, it appears to work. If you want to get data for another country, simply substitute ‘world’ with a country of your choice. You can also add additional attributes from the json response if that’s your thing.

rest:
  - scan_interval: 3600
    resource: https://covid-19-apis.herokuapp.com/allUpdate
    timeout: 60
    sensor:
      - name: covid_world
        json_attributes_path: '$.[?(@["Country,_Other"]=="World")]'
        json_attributes:
          - Active_Cases
          - New_Cases
          - Total_Cases
          - Total_Recovered
          - Total_Deaths
        value_template: 'Covid World'
      - name: covid_world_active_cases
        value_template: '{{ states.sensor.covid_world.attributes["Active_Cases"] | replace(",","")| int | round(0) }}'
        unit_of_measurement: '#'
      - name: covid_world_new_cases
        value_template: '{{ states.sensor.covid_world.attributes["New_Cases"] | replace(",","")| int | round(0) }}'
        unit_of_measurement: '#'
      - name: covid_world_total_cases
        value_template: '{{ states.sensor.covid_world.attributes["Total_Cases"] | replace(",","")| int | round(0) }}'
        unit_of_measurement: '#'
      - name: covid_world_total_recovered
        value_template: '{{ states.sensor.covid_world.attributes["Total_Recovered"] | replace(",","")| int | round(0) }}'
        unit_of_measurement: '#'
      - name: covid_world_total_deaths
        value_template: '{{ states.sensor.covid_world.attributes["Total_Deaths"] | replace(",","")| int | round(0) }}'
        unit_of_measurement: '#'

Combine this with the covid vaccination tracker here: COVID-19 Vaccination Tracker - #9 by Florian.Schmidt and you can have all the info you need.

3 Likes

Nice find @hfalev. So far the reordering has only happened once to me, but I will be glad to not have it happen again :wink: .

Indeed, for countries further down the list it happens quite often resulting in some very jittery plots.

Has the covid tracker gone offline and is there a backup source for this info? Does anyone maintain the Heroku page?

I found it to be quite dead, and no one wants to support that integration anymore… I ended up writing my own simple tracker for the USA, maybe you will find this useful?

-Jim

this didnt age well

Please do not revive a thread to start an argument. @roussell do not respond. Thanks.

1 Like

What is your *.yaml configuration?

my yaml already included?

So you only have it installed Coronavirus (COVID-19) integration and the selected country of Indonesia and the Worldwide?

do you have any additional settings in the * .yaml (configuration or sensor) file?

You need to have additional settings under the sensors!

sensor.worldwide_corona_percentage_recovered
sensor.worldwide_corona_percentage_deceased
sensor.worldwide_corona_percentage_infected

and so on with other sensors. In configuration.yaml under sensor:
Or you have a special sensor.yaml file and settings in it.

Some make inferences based on data (what, why, and where the matter goes). People who have done their doctorates in pubs, hairdressers, psychiatrists, etc. And they firmly believe that the earth is flat, for the reason that they cannot fly. How to help such people if they do not want help?

Let’s keep it on topic please

2 Likes

With all due respect this thread is titled “Coronavirus”.

Are you saying that talking about coronavirus is not appropriate ? ,

I’m new to the HA forum but is this really how tight and regulated it is… ? Wow…

No personal views or comments allowed. ?

Do you live in the UK or China … Really ?

This is a topic about the 0.106 release, which includes an integration for tracking COVID-19 statistics. It’s not a forum for posting your views on the pandemic. It is a forum with a code of conduct that excludes personal attacks, such as the ones you posted.

4 Likes

Hello. Does anyone happen to know how to retrieve data from this site as a sensor? Perhaps for the parameters below for Slovenia. Thanks

https://covid-19-apis.herokuapp.com/allUpdate

{"Active_Cases/1M_pop":"8,647","#":"70","Total_Deaths":"5,603","Total_Tests":"2,083,466","New_Cases/1M_pop":"","Tot_Cases/_1M_pop":"224,373","1_Death_every_X_ppl":"371","New_Recovered":"","Continent":"Europe","New_Deaths/1M_pop":"","Deaths/_1M_pop":"2,695","1_Case_every_X_ppl":"4","New_Cases":"","Active_Cases":"17,980","Serious,_Critical":"173","Country,_Other":"Slovenia","Population":"2,079,367","Total_Cases":"466,554","Tests/_1M_pop":"1,001,971","New_Deaths":"","1_Test_every_X_ppl":"1","Total_Recovered":"442,971"},

I found a solution. Only the prime is not over yet.

#======================================        
#                         Covid-19 Svet
#======================================
  - platform: rest
    name: covid_world
    resource: https://covid-19-apis.herokuapp.com/allUpdate
    json_attributes_path: '$.[?(@["Country,_Other"]=="World")]'
    json_attributes:
      - Active_Cases
      - New_Cases
      - Total_Cases
      - Total_Recovered
      - Total_Deaths
      - Total_Tests
      - 1_Death_every_X_ppl
      - New_Recovered
      - New_Deaths
      - Deaths
      - 1_Case_every_X_ppl
      - Serious,_Critical
      - Population
      - Tests/_1M_pop
      - 1_Test_every_X_ppl
    value_template: 'Covid-19 Svet'

  - platform: template
    sensors:
      covid_world_active_cases:
        value_template: '{{ states.sensor.covid_world.attributes["Active_Cases"] | replace(",","")| int | round(0) }}'
        unit_of_measurement: ' '
      covid_world_new_cases:
        value_template: '{{ states.sensor.covid_world.attributes["New_Cases"] | replace(",","")| int | round(0) }}'
        unit_of_measurement: ' '
      covid_world_total_cases:
          value_template: '{{ states.sensor.covid_world.attributes["Total_Cases"] | replace(",","")| int | round(0) }}'
          unit_of_measurement: ' '
      covid_world_total_recovered:
          value_template: '{{ states.sensor.covid_world.attributes["Total_Recovered"] | replace(",","")| int | round(0) }}'
          unit_of_measurement: ' '
      covid_world_total_deaths:
          value_template: '{{ states.sensor.covid_world.attributes["Total_Deaths"] | replace(",","")| int | round(0) }}'
          unit_of_measurement: ' '

Hi all, it looks like the covid-19-apis.herokuapp.com api is dead now… Is there any other alternative or is it time to give up on tracking covid finally?