Coronavirus broke

Quit for me a couple of hours ago. I was able to reinstall it for US, but still “unavailable”.

Edit: It’s back

Coronavirus Integration via NR straight from WHO. Import the below config and change the country name node.

[{"id":"10cbe271.08c8ae","type":"www-request","z":"39d45ee1.7a82b2","name":"","method":"GET","ret":"txt","url":"https://services.arcgis.com/5T5nSi527N4F7luB/arcgis/rest/services/COVID_19_CasesByCountry(pt)_VIEW/FeatureServer/0/query?f=json&where=1%3D1&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=*&orderByFields=cum_conf%20desc&resultOffset=0&resultRecordCount=115&cacheHint=true","follow-redirects":true,"persistent-http":true,"tls":"","x":510,"y":200,"wires":[["4e4d99e0.686f28"]]},{"id":"b15d752e.3c4af8","type":"inject","z":"39d45ee1.7a82b2","name":"","topic":"","payload":"","payloadType":"date","repeat":"1800","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":200,"wires":[["6e45df48.472e5"]]},{"id":"4e4d99e0.686f28","type":"json","z":"39d45ee1.7a82b2","name":"Convert to object","property":"payload","action":"","pretty":false,"x":730,"y":200,"wires":[["cbb8b069.848d5"]]},{"id":"cbb8b069.848d5","type":"function","z":"39d45ee1.7a82b2","name":"calculate","func":"obj = msg.payload;\ncountry = flow.get(\"country\");\nvar errorProp = 'error';\nif(obj.hasOwnProperty(errorProp)){\n    msg.payload = {'total_cases': '0', 'total_death': '0', 'total_cases_country': '0', 'total_cases_country_death': '0'}\n}\nelse\n{\n    total_cases = 0;\n    total_death = 0;\n    total_cases_country = 0;\n    total_cases_country_death = 0;\n    \n    for (const key of obj.features) \n    {   total_cases = total_cases + key.attributes.cum_conf;\n        total_death = total_death + key.attributes.cum_death;\n\n        if(key.attributes.ADM0_NAME == country)\n            {\n                total_cases_country = total_cases_country + key.attributes.cum_conf;\n                total_cases_country_death = total_cases_country_death + key.attributes.cum_death;\n            }\n    }\n    msg.payload = {'total_cases': total_cases, 'total_death': total_death, 'total_cases_country': total_cases_country, 'total_cases_country_death': total_cases_country_death}\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":940,"y":200,"wires":[["5967ddab.b63364","be521acc.58ee48","93a9cbb8.aea688","890ca730.2bd008"]]},{"id":"6e45df48.472e5","type":"change","z":"39d45ee1.7a82b2","name":"Country Name","rules":[{"t":"set","p":"country","pt":"flow","to":"INDIA","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":200,"wires":[["10cbe271.08c8ae"]]},{"id":"f1c50216.cdb31","type":"comment","z":"39d45ee1.7a82b2","name":"Fetch COVID19 Cases","info":"","x":140,"y":160,"wires":[]},{"id":"5967ddab.b63364","type":"ha-entity","z":"39d45ee1.7a82b2","name":"Covid19 Wordwide","server":"82494656.b2ac98","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Covid19 Wordwide Cases"},{"property":"device_class","value":"none"},{"property":"icon","value":"mdi:biohazard"},{"property":"unit_of_measurement","value":""}],"state":"payload.total_cases","stateType":"msg","attributes":[{"property":"name","value":"covid19","valueType":"str"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":1190,"y":80,"wires":[[]]},{"id":"be521acc.58ee48","type":"ha-entity","z":"39d45ee1.7a82b2","name":"Covid19 Wordwide Deaths","server":"82494656.b2ac98","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Covid19 Wordwide Deaths"},{"property":"device_class","value":"none"},{"property":"icon","value":"mdi:emoticon-dead"},{"property":"unit_of_measurement","value":""}],"state":"payload.total_death","stateType":"msg","attributes":[{"property":"name","value":"covid19_death","valueType":"str"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":1220,"y":140,"wires":[[]]},{"id":"93a9cbb8.aea688","type":"ha-entity","z":"39d45ee1.7a82b2","name":"Covid19 Country Specific","server":"82494656.b2ac98","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Covid19 India Cases"},{"property":"device_class","value":"none"},{"property":"icon","value":"mdi:biohazard"},{"property":"unit_of_measurement","value":""}],"state":"payload.total_cases_country","stateType":"msg","attributes":[{"property":"name","value":"covid19_india","valueType":"str"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":1210,"y":200,"wires":[[]]},{"id":"890ca730.2bd008","type":"ha-entity","z":"39d45ee1.7a82b2","name":"Covid19 Country Specific Deaths","server":"82494656.b2ac98","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Covid19 India Deaths"},{"property":"device_class","value":"none"},{"property":"icon","value":"mdi:emoticon-dead"},{"property":"unit_of_measurement","value":""}],"state":"payload.total_cases_country_death","stateType":"msg","attributes":[{"property":"name","value":"covid19_india_death","valueType":"str"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":1240,"y":260,"wires":[[]]},{"id":"82494656.b2ac98","type":"server","z":"","name":"Home Assistant"}]

image

Mine isn’t. Family stopped looking at it. Super cool but you know “users”, if they try something a couple times and doesn’t give them what they want go elsewhere. I don’t get how the worldwide version seems to mostly work but the US and unsure of other locations, keeps failing. Are they from different places?

Mine is fully working now

Worldwide was working. I added mine back in just a few ago and US came back. Reloaded the page and bam!!! Working awesome!!!

image

Errors like this all the time.

2020-03-09 18:03:11 ERROR (MainThread) [homeassistant.components.coronavirus] Unexpected error fetching coronavirus data: 'features'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 115, in async_refresh
    self.data = await self.update_method()
  File "/usr/src/homeassistant/homeassistant/components/coronavirus/__init__.py", line 81, in async_get_cases
    aiohttp_client.async_get_clientsession(hass)
  File "/usr/local/lib/python3.7/site-packages/coronavirus/__init__.py", line 81, in get_cases
    for item in data["features"]:
KeyError: 'features'

I can’t even get this integration to add. I followed the instructions and get a message that “not all integrations can be configured via the UI”.

Logger: aiohttp.server
First occured: 4:04:16 PM (6 occurences)
Last logged: 4:05:20 PM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/real_ip.py", line 39, in real_ip_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 72, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 135, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 123, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 130, in post
    return await super().post(request)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 50, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 62, in post
    handler, context={"source": config_entries.SOURCE_USER}
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 109, in async_init
    result = await self._async_handle_step(flow, flow.init_step, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 172, in _async_handle_step
    result: Dict = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/components/coronavirus/config_flow.py", line 30, in async_step_user
    coordinator.data.values(), key=lambda case: case.country
TypeError: '<' not supported between instances of 'str' and 'NoneType'

Yep, its also like this for me as well after the 106.6 change, was working fine, deleted the integration, restarted and all that good stuff, same error message as above…

I just upgraded to 106.6 from .2 and I don’t even see the Coronavirus integration in the list.

I’m still on HA 0.106.5 and the Coronavirus integration was working fine last night, this morning all sensors showing as unavailable. Haven’t changed anything since it was working…

found this in the HA log:

Logger: homeassistant.components.coronavirus
Integration: coronavirus (documentation, issues)
First occured: 7:31:46 AM (2 occurences)
Last logged: 8:31:47 AM

Unexpected error fetching coronavirus data: ‘features’

Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py”, line 115, in async_refresh self.data = await self.update_method() File “/usr/src/homeassistant/homeassistant/components/coronavirus/init.py”, line 81, in async_get_cases aiohttp_client.async_get_clientsession(hass) File “/usr/local/lib/python3.7/site-packages/coronavirus/init.py”, line 81, in get_cases for item in data[“features”]: KeyError: ‘features’

I’m on 0.106.3 and all is working. Must be an issue with versions above that?

Update: without doing anything, it started working again… :thinking:

Yep, it’s an odd one. I’ve gone a couple days now since the last update of the integration without it going down. Knock on wood.

Comment Removed.

Interesting. I have been using the Coronavirus add-on since it was made available and have have had no issues like that. I’m monitoring US and worldwide. The only issue I noticed was today where it shows 1600 cases then dropped to 1286 then went up to over 2000. During this time, the number on the Johns Hopkins site also went up to 1600, down to 1286 then up to over 2000 so it was properly reading that data. I’m currently running 0.107.0b1.

Yeah mine screwed up today for the first time as well but it’s not HA it’s an issue with the source. Mines come good again now.

I’d like to say it’s comical but it’s not. You look at the graph, looks like people are dying and coming back to life.

image

1 Like

Everyone in the US that recovered died at once it would seem
image

1 Like

SparkyDave,

Love your layout of your card. Can you post config of that card?

1 Like

Sure, no problem. You will need the custom mini graph card and a couple of template sensors to provide the mortality rates, posted below.

lovelace:

- type: vertical-stack
        cards:
          - type: entities
            show_header_toggle: false
            header:
              type: picture
              image: 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcS7ovkoWSZdub9adLaiuFEdXYUzjZ6bSSNXPA6vT3z3gmCccuMr'
            entities:
              - sensor.australia_coronavirus_confirmed
              - sensor.australia_coronavirus_current
              - sensor.australia_coronavirus_deaths
              - sensor.australia_coronavirus_recovered
              - sensor.coronavirus_australia_mortality
              - type: divider
              - sensor.worldwide_coronavirus_confirmed
              - sensor.worldwide_coronavirus_current
              - sensor.worldwide_coronavirus_deaths
              - sensor.worldwide_coronavirus_recovered
              - sensor.coronavirus_worldwide_mortality
          - type: 'custom:mini-graph-card'
            name: Coronavirus Mortality Rate (%)
            entities:
              - entity: sensor.coronavirus_australia_mortality
              - entity: sensor.coronavirus_worldwide_mortality
            show:
              state: false
              labels: true
            lower_bound: 0
            upper_bound: 5
            points_per_hour: 6
            hours_to_show: 240
            height: 150

template sensors:

sensor:
  - platform: template
    sensors:
      coronavirus_australia_mortality:
        friendly_name: "Australian Coronavirus Mortality Rate"
        unit_of_measurement: '%'
        value_template: "{{ '%.2f'|format(((states('sensor.australia_coronavirus_deaths') | float * 100) / (states('sensor.australia_coronavirus_confirmed') | float ))) }}"
      coronavirus_worldwide_mortality:
        friendly_name: "Worldwide Coronavirus Mortality Rate"
        unit_of_measurement: '%'
        value_template: "{{ '%.2f'|format(((states('sensor.worldwide_coronavirus_deaths') | float * 100) / (states('sensor.worldwide_coronavirus_confirmed') | float ))) }}"

EDIT: I just realised that my previous post didn’t have the graph, so here it is. You can leave out the graph and vertical stack if you want it to look like my old post. I will probably join them together better now that the ‘stack-in-card’ is available

1 Like

Thanks it took some bending around but I got it to work great. I have not used the stack-in-card yet either.