Help with HA service startup delay (Debian)

Hi, I’m far from an expert on Linux and even after reading about it everywhere, I still have issues understanding and applying this to my specific setup…
I use HA on a NUC in a Debian OS.
I installed HA using the “advanced procedure”
https://www.home-assistant.io/docs/installation/raspberry-pi/

And I set it up as service following this (Python virtual env):
https://www.home-assistant.io/docs/autostart/systemd/

It works fine but when I reboot the NUC, a bunch of services fails and to resolve, I just need to restart HA to resolve this so I presume I need to setup a startup delay for HA when rebooting the NUC.

Can anyone help me configuring a 30s startup delay that applies specifically to my setup?

Thanks in advanced guys!

Without more details on what is failing to load, I would start with adding:
[Unit]
Wants=network-online.target
After=network-online.target

If that doesn’t work, then add a delay
[Service]
ExecStartPre=/bin/sleep 30

Thanks, still not sure exactly where to add this…

This is my “home-assistant.homeassistant.service”

[Unit]
Description=Home Assistant
After=network-online.target

[Service]
Type=simple
User=%i
ExecStart=/srv/homeassistant/bin/hass -c “/home/homeassistant/.homeassistant”

[Install]
WantedBy=multi-user.target

During the install, I ran this to autostart:

sudo systemctl enable home-assistant@homeassistant

So where do I add the:

[Unit]
Wants=network-online.target
After=network-online.target

or this if I just do the delay start):

[Service]
ExecStartPre=/bin/sleep 30

I simply add those at the end of the section in this service file?

Sorry, as you can see, I followed the procedure step by step but am really not good with Linux OS…

Really depends,sometimes it’s Hue, Lutron or others that fails… rebooting HA resolves it every time so I figured I needed a delay… It’s a NUC with SSD…

Both of those are external hubs. They may not load right away, but shouldn’t cause an issue. NUC should be fast enough, many are running on a raspberry pi.

I would add Wants=network-online.target before After=network-online.target

I don’t think delay will help, both of those hubs shouldn’t cause any issues that restarting would fix. To delay, change your service section to look like this:

[Service]
ExecStartPre=/bin/sleep 30
Type=simple
User=%i
ExecStart=/srv/homeassistant/bin/hass -c “/home/homeassistant/.homeassistant”

1 Like

Thanks!
I tried to simply add Wants=network-online.target before After=network-online.target
After rebooting, I still had issues.
The list is long of failing components (discovery, nest, Lutron, Hue, icloud, SABNZBD, etc…)
All related to network.

but, the 30s resolved it, rebooted and when HA started, prefect.

Thank you so much!

Hi,

I know it’s been a year but I can’t find the answer. Multiple topics speaks about this solution but non say where to put this little piece of text.
I’m sorry I’m totally new to Linux and HA …
@sfnetwork, if you have 1sec to spare and tell how you did it that would be awesome!

Thanks.