How to delay Hass startup?

I need to add a boot delay to My Rpi 3 running Hass.io. I need to do this because after a power outage the Rpi w/Hass.IO boot’s (faster) before my network is fully operational. Whats the appropriate init file to edit to add a boot delay to Hass.IO?

(Edited:Old wrong question asked) Sadly I have encountered several power outages in the past few months. And my Rpi running Hass.io/MQTT never gracefully recovers when power is back up. The MQTT broker always seems to start After Hass. So it need intervention to get back running after a power outages.

What do I need to tweak to have MQTT start before Hass.io so It’s self reliant after a power outage?
(old)

(Edit:) I can’t seem to find the init scripts to edit. I wanted to see if I could add a delay to the startup of the main Hass process. I’m not well versed in Docker/resinOS and I think the init script I’m after is in a docker image? Maybe. . I’m lost …Any pointers to the file that controls the MQTT/Hass startup is greatly appreciated.

(Edit:2) hmm… If I yank the power from the Rpi and wait a couple of minutes to re-power, everything boots fine… Maybe the network/wifi/router/dhcp isn’t ready after the power comes back, Editing this question topic now =)

Many Thanks.

I’d recommend putting a battery pack (e.g. one you can use to recharge your mobile phone and has enough Amps for the RPi3) in place to keep your RPi running in the first place.

This will hopefully not only save the re-booting sequence problem, but also prevent your SD-Card from getting corrupted during a power outage.
I never had this issue myself, but I’ve heard from people that their SD-Cards got corrupted when “re-booting by power cord”.

@chairstacker thank you.
Yes, A battery can save the SD card. (I personally buy small expensive SD card’s and backup frequently)

However I’m looking to have Hass.IO boot slower to let my network recover after a power loss.

I’m thinking the file I need to add a “sleep” command, perhaps in “inittab”. However I"m not positive and still researching till I receive a pointer in the correct direction.

I figured it out. (I think)

I had my mqtt broker set to the actual IP of the Rpi running Hass.IO.

I’ve now set it to the loop back ip “127.0.0.1”. It should have no problem connecting now. =)

Time well tell, till the next power outage.

I’m actually interested in this as well. I am having trouble with the notify and iOS components and from what I have read home Assistant is starting up before the docker container has completely connected to the network. If a component tried to load before the network is active it will error out and never start up again. Which is a separate problem that the dev team needs to solve but I’m looking for a hack to fix it now. If I could delay HA from starting wishing the container until the container has finished connecting to the network I think it would solve the problem. Or at least eliminate the theory.

I’m not an extreme Linux expert myself. I know enough to get by, But I need to find someone that can help me figure this one out lol.

Hi,

Have you found an answer to this?

Mine is the same, power failures and i use the Vera for zigbee devices and it takes alot longer to boot than hassio. So when hass is back it never picks up the Vera…

Thanks
Derick

Any of the Raspberry Pi Kernel parameters documented here can be added to HASSIO’s /mnt/boot/cmdline.txt file. You can force a delay using boot_delay, and/or bootcode_delay. I’ve not tried the delay options myself but I have tried other parameters successfully, so I am fairly confident the delay functions should work too.

Has this to your knowledge changed? I can’t get any directories or files to stick in /mnt

cmdline.txt is still used when booting a raspberry pi.

However, you might be trying to use the file in the wrong place. You have to be connecting to the host OS, not to a docker container. For example, the ssh that you get from the “SSH & Web Terminal” add-in will not work. The file already exists, so if you don’t see it in /mnt, then you are connecting from the wrong shell environment.

If you want to edit cmdline.txt from a running instance of HASS, you must connect from either a serial console, desktop console, or the debug SSH.

To connect to the desktop console, connect an HDMI monitor and a USB keyboard to your Pi and then reboot.

Alternatively, you might as well just pull the sdcard, mount it in a PC and directly edit cmdline.txt from the FAT32 boot partition.