If you lose power and the power is restored, Home Assistant will start without network because the router and other network equipment are still starting up. This will cause Home Assistant to never load completely, requiring another restart when the network comes back up. I don’t see a “Wait for Network” option when running hass.io on a Raspberry Pi. This has been causing issues recently due to a string of power outages.
I need to solve the same issue. Have HASS running in a remote cottage, where we have, unfortunately frequent outages. Many are short and could be mitigated by a UPS (but this is another device to maintain) but the one last week was a bad storm and 3 day outage. No matter, even if my router and HASS are on a UPS, they lose network as the Bell shed 500m away is disrupted.
A large part of the value of HASS to me is knowing the cottage state - power up or down. In the winter, if down extended I need to drive a few hours to deal with or it burst pipes.
When power is restored, both the router and HASS start at the same time, and HASS finds no network (yet). Solutions:
- I want to be able to configure HASS to be able to retry network connection periodically if it does not have internet access (i.e., I cannot reach it). Say it tests ICMP to google.com.
- Or configure HASS reboot periodically twice per day. Professionally as an IT guy I find rebooting distasteful, but reality is many systems benefit from a reboot to restore to initial running state.)
It has no network, I cannot reach it, so HASS has to do this independently.
My router is not yet exposed to the internet. I could maybe expose its management interface, but since HASS is not caring about the network, I don’t think I can coax it to restart.
Ideas?
These are pretty much workarounds to the actual issue, but might work to resolve the issues cased by it.
You could create an automation that triggers when HA starts, then waits 5-10 minutes, and restarts home-assistant.
Or you could also use the same trigger, and instead use a wait
in the automation action to wait for a good response from a ping sensor pointed at 8.8.8.8 or something, so it reboots once the network in confirmed as running.
Restart HA using the “homeassistant.restart
” service call.
Detect HA startup using
- platform: homeassistant
event: start
Thanks! I have not spent much time with automations, but will look at it. I was toying with the idea of building an add-on.
First idea - is an endless loop. Every time it restarts, it restarts again. In this scenario I need to detect whether I forced the restart, by saving state, and only re-start on a power up. I don’t think HASS supports this - defining custom platform attributes and modifying values from scripts. BTW the ‘configuration guide’ badly needs a reference manual, the topics on the web appear to just be a sample.
Second idea… it never gets the WAN, so I would need it to timeout, say 15 minutes for a really rough internet modem startup. Have to code the automation to check every 3 hours, wait 15 minutes, and reboot if it fails. When I am ack local to the device I may see what the value of sensor.myip (public IP) is when WAN is down. Or the value of sensor.speedtest.ping. And use these to trigger a restart.
For now I have an automation script to restart at 7 am and 9 pm daily. 7 am to wake up, check the status and decide whether to drive up. 9 PM for the outages where crews are out working, I see that service levels are often “by 8 pm” i.e. before night falls.