Have Home Assistant periodically try to initialize failed components

Here’s the current problem. If your Home Assistant uses network components (like Dark Sky, REST switches, etc) and you go through a power outage there will be a race condition when HA starts and other devices in your network have not started completely (e.g. NTP might not be synchronized so SSL fails, your router might take some time to connect to your ISP, local devices in your network might take more time to start their services, etc). In this case, when HA starts and loads its config, it will fail to initialize some components (e.g. fail to connect to DarkSky, etc) and does not retry to activate them (at this time).
Currently, one needs to manually reload HA’s config once the network has stabilized to ensure all components are working. Once a component has been loaded, it usually is resilient against failure (reconnects automatically), but this doesn’t happen at system startup.

My suggestion would be to have components try to initialize on a timer (e.g. every minute) after HA’s start, so that events outside of HA’s control (network outage, time sync, etc) would not influence the system’s behavior.

A workaround for this is to have a delayed task in /etc/rc.local that restarts home assistant after 2 minutes from boot (or whatever interval), but it’s a hack and I don’t like it.

My thoughts on this: wouldn’t it make sense to add a generic reload service for every component? I haven’t thought this through, but to me it seems like when HASS is starting, it could simply do the reload for every component, and report (e.g. notify or trigger some timer, essentially a reload-failed-event we could use for automation) back if a reload wasn’t successful.
Depending on how the reload is implemented, this would also enable us to “shut down” a component during runtime and come back up again with a modified configuration.

1 Like

Yes, that’d be a great idea :slight_smile:

This feature would potentially being able to better control REST sensor polling, a problem I’m facing today and having to use a bunch of automations to overcome polling exhaustions.

Also, not all REST services may be available at startup, especially if you’re polling data from an external source. Being able to restart them would support a more robust setup and not having to monitor and restart HA ever so often.

Webos component sometimes fails, and when I restart home assistant, it alive again. It will better, if home assistant will restart component itself.