Autostart not working on ubuntu

Hi,
I’m running ubuntu 16.10. I installed HA using the method “sudo pip3 install homeassistant”
I can’t get autostart working. I followed the instructions on the HA site to no avail: https://home-assistant.io/docs/autostart/systemd/

This is what I tried:

  • determined my system was using systemd

  • ran “whereis hass” - it returned: /home/dan/.local/bin/hass

  • I then created the file using the command “sudo nano -w /etc/systemd/system/[email protected]”, entering the text below and saving (ctrl-x / y)

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

    [Service]
    Type=simple
    User=%i
    ExecStart=/home/dan/.local/bin/hass

    [Install]
    WantedBy=multi-user.target

I then ran:

  • sudo systemctl --system daemon-reload
  • sudo systemctl enable home-assistant@homeassistant
  • sudo systemctl start home-assistant@homeassistant

Then when checking the status using the command: - sudo systemctl status home-assistant@homeassistant

I receive the errors:

Loaded:   loaded (/etc/systemd/system/[email protected]; enabled; vendor preset: enabled)
Active:   failed (Result: exit-code) since Wed 2017-03-08 15:21:42 GMT; 2s ago
Process:  15415 ExectStart=/home/dan/.local/bin/hass (code=existed, status=217/USER)
Main PID: 15415 (code-exited, status=217/USER)

I also tried running:

  • sudo ln -s /lib/systemd/system/home-assistant.service /etc/systemd/system/home-assistant.service

This also didn’t work. I’m pretty stuck now. Any help appreciated!

I know in my service file I’m pointing to the config directory under ExecStart

trying adding the
-c your/config/dir/here
at the ExecStart=/home/dan/.local/bin/hass line

also are you running it through a virtualenv? You might need to add the path in as well to $PATH

The line User= indicates that systemd will try to run the program as user homeassistant (the name after the @ in the filename).

You are using your user to run HA, so you need to rename the system file to /etc/systemd/system/[email protected].

It really isn’t recommended run as a normal user long term. Creating a separate user for running HA enables you to restrict its permissions so that it cannot do anything that would endager the system.

1 Like

I’m running mine this way, how would I do this?

edit the system file in /etc/systemd/system and make sure your service points to the correct location and user

ExecStart=/srv/homeassistant/bin/hass -c “/home/homeassistant/.homeassistant” ← or whatever your instance location is.