Auto-start on Raspberry pi

@jcroed, you have weird setup because

but for some reason you try to launch

You have two different paths:

  1. /srv/homeassistant/homeassistant_venv/bin/
  2. /srv/homeassistant/bin/hass

Again, if you use su -c 'cat ...' then you must use a root password.
If you want to execute this as non-root user then you must use sudo cat ...
And of course that user must be in sudoers.

If you use this line then you don’t need to use user prefix in service filename.
Change this: su -c 'cat <> /etc/systemd/system/[email protected]
to that: su -c 'cat <> /etc/systemd/system/homeassistant.service

At last, you can use simple editor called ‘nano’ to create that file.
Just execute sudo nano /etc/systemd/system/homeassistant.service and copy/paste the contents of file.
Then press Ctrl+x and ‘y’ for saving changes.

1 Like

@omeasire, thanks for pointing that out. I tried a bunch of variants trying to get it to start properly, and obviously that was one of the bad ones. I did not notice it when I posted it, because I was focusing on the preceding “ExecStartPre” line that was generating the error.
By commenting the “ExecStartPre” line out I was able to get it to start, but by that time I had also seen the advice to try the “All in One” installation method. I wiped out my previous installation and reinstalled with the “All in One” method, which worked perfectly.

Hi guys, exactly based on the guide

https://home-assistant.io/docs/installation/raspberry-pi/

I used the below config in “/etc/systemd/system/homeassitant.service” and it works fine!

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

[Service]
Type=simple
User=homeassistant
WorkingDirectory=/svr/homeassistant
ExecStartPre=source /svr/homeassistant/bin/activate
ExecStart=/svr/homeassistant/bin/hass

[Install]
WantedBy=multi-user.target

be sure to use the systemctl command to play with it

start/stop/restart the service

sudo systemctl start homeassitant

check the status

sudo systemctl status homeassitant

enable/disable (auto-start) the service

sudo systemctl enable homeassitant

reload-daemon when the .service file is altered

sudo systemctl daemon-reload
1 Like

Yes, Finally! After configuring the pi with rasbian-stretch. and then doing the all-in-one install for the 3rd time. I think I finally got it going, even restarts after reboot. Whew!

Now time to learn how to add things…1st, my MQTT switched outlet.

very good! It works fine.

Only I need to change all /svr/xxxx to /srv/xxxx.

1 Like

works wonderfully! the only point is the file name which miss an “s” …/homeassiStant.service :slight_smile:

Thank you!

This way didn’t work for me.

But following which is described on this link worked perfectly: Autostart using systemd

I’m using Python virtual environment.

Regarding the all-in-one installer: do we burn the HA image to our Pi SD?

After some rebranding that happened recently the easiest, and recommended, way to get Home Assistant installed is indeed to burn “Home Assistant” (formerly known as HassOS) on a new SD Card and boot from it!

I understand that the Pi does not have R/W memory other than the SD card. Which contains the whole OS.

I don’t understand how the booted HA co-exists with the OS.

Thanks.