How to start HA if Raspberry PI is rebooted

Hi guys,

A silly question, I installed HA following manual installation.

I did some changes to the yaml config and wanted to restart the service, which I was not able to do.
Tried:
pi@raspberrypi:~ $ sudo service hass-daemon restart
Failed to restart hass-daemon.service: Unit hass-daemon.service not found.
pi@raspberrypi:~ $ sudo systemctl restart home-assistant.service
Failed to restart home-assistant.service: Unit home-assistant.service not found.
pi@raspberrypi:~ $

So I decided to reboot raspberry and now I cannot understand how to start HA after pi is rebooted.

This commands helped me, but looks like it just reinstalled or reset the config file:
$ sudo su -s /bin/bash homeassistant
$ cd /srv/homeassistant
$ python3 -m venv .
$ source bin/activate
(homeassistant) $ hass

I am a complete noob in linux and feels like I am doing something wrong. Can you give me a hint please, how to restart HA and how to start it if pi is rebooted.
Thanks.

you can use this one:
sudo systemctl start homeassistant.service on ssytemd enabled linux and if used the AIO to install HA.

IMO you’re better off with either the All In One, or Hassbian installs if you’re new to Linux.

That said, place the following in /etc/systemd/system/ and call it home-assistant.service (you’ll need to use sudo to create and edit files there). If you don’t have your HA configuration files in /home/homeassistant/.homeassistant then change that path as appropriate.

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

[Service]
Type=simple
User=homeassistant
Environment="TZ=Europe/London"
ExecStart=/srv/homeassistant/venv/bin/hass -c "/home/homeassistant/.homeassistant"

[Install]
WantedBy=multi-user.target

Once you’ve done that, run the following commands:

sudo systemctl daemon-reload
sudo systemctl enable home-assistant
sudo systemctl start home-assistant
2 Likes

The documented instructions are here

Hi @Tinkerer. I notice your script varies from the one provided in the link from @gpbenton (from the HA docs) in the following ways:

  1. After=network.target instead of After=network-online.target
  2. ExecStart=/srv/homeassistant/venv/bin/hass instead of ExecStart=/srv/homeassistant/bin/hass

Can you explain these differences? Not too familiar with systemd and trying to figure out how to set this up.

The second is the easy one to explain - mine’s in a different location. I have multiple virtual environments, so that I can test out things like Python upgrades safely and easily.

The first is more complicated, but very (very) briefly:

  • network.target: the network stack exists
  • network-online.target: … and the network interfaces are configured

Of course, you’re asking about something from two years ago - these days I use network-online.target

Glad you’re still around two years later to help me out. Thanks!

1 Like