custom-components / healthchecksio

Update and display the status of your healthchecks.io checks.
MIT License
52 stars 9 forks source link

Integrations not loading after restart #3

Closed editter closed 4 years ago

editter commented 5 years ago

When I add the Health Checks IO integration through HACs and configure it everything works great but when I restart my home-assistant instance it throws an error. I'm assuming the issue is because of the slow starts so everything isn't initialized but because the error is caught and it will still try and set up the binary_sensor.

I took a look at the code and from what I can tell the error is happening in __init__.py line 87 so self.hass.data[DOMAIN_DATA]["data"] is never being initialized which means the binary sensor blows up later on when the data property is not there to loop through.

Error 1 Could not update data -

Error 2

Log Details (ERROR)
Thu Oct 03 2019 12:37:07 GMT-0500 (Central Daylight Time)
Error while setting up platform healthchecksio
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform
await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
return fut.result()
File "/config/custom_components/healthchecksio/binary_sensor.py", line 11, in async_setup_entry
for check in hass.data[DOMAIN_DATA]["data"].get("checks", []):
KeyError: 'data'
{
                "connection_class": "cloud_poll",
                "data": {
                    "api_key": "[valid api key]",
                    "check": "[valid check guid]"
                },
                "domain": "healthchecksio",
                "entry_id": "[Probably a random string but removing it incase it important]",
                "options": {},
                "source": "user",
                "system_options": {
                    "disable_new_entities": false
                },
                "title": "[valid check guid]",
                "version": 1
}

Version 0.1.2

ludeeus commented 4 years ago

You gave up right?

editter commented 4 years ago

I forgot I wrote this. I removed/re-added it and did a restart and it seems to be working fine.