How to autostart HASS in virtualenv?

Hi. I have HASS installed using this tutorial on raspberry with Jessie. it creates virtualenv and homeassistant user. But HASS has to be started manually.

I tried:
su -c 'cat <> /etc/systemd/system/[email protected]
[Unit]
Description=Home Assistant
After=network.target

[Service]
Type=simple
User=%i
ExecStart=/srv/homeassistant/homeassistant_venv/bin/hass

[Install]
WantedBy=multi-user.target
EOF’

But without success it asks me for a password if run under “homeassistant” or in virtualenv, which I don´t know… How could I set this command? As “pi” or as “homeassistant” or under virtualenv?
Or do you know some other way?

Just to clarify, you are saying if you specifically set this service to run as User=homeassistant with the following info, that it asks for a password? Is it asking for a root password or what?

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

[Service]
Type=simple
User=homeassistant
ExecStart=/srv/homeassistant/homeassistant_venv/bin/hass -c "/home/homeassistant/.homeassistant"

[Install]
WantedBy=multi-user.target
1 Like

I just installed HASS using the tutorial on homeassistant page (for raspberry) and I want HASS to autorun after start. That is all. Does anybody knows how? It would be great to note it in tutorial as the link in tutorial on “how to autostart” point to manual where is everything set using standard “pi” user not via virtualenv.

Anybody this shouldn´t be so hard to do…?

Hi Jiran,

According to the readme the All-in-one installer automatically updates your systemd services to run both Home Assistant and Mosquitto at boot.

If you need to start/stop/restart your instsnce simply issue:
sudo services [start|stop|restart] home-assistant.service

Hope that helps.

Edit:
Seems I may have misunderstood your question.
The service config jbardi posted above should a drop-in replacement for the example in the Autostart article.

The sections in your configuration that may be causing problems:

User=%i
ExecStart=/srv/homeassistant/homeassistant_venv/bin/hass

User should equal homeassistant
The first path in the ExecStart line should reference the hass binary
/srv/homeassistant/homeassistant_venv/bin/hass
and -c should point to the .homeassistant folder in the homeassistant user’s home folder “/home/homeassistant/.homeassistant”

Also make sure you have created the homeassitant user is created with the -rm options.

sudo useradd -rm homeassistant

1 Like

The question was asked for manual installation with virtual env, not for All-In-One. The instructions for autostart, located here:

should be updated for virtual environment installations, which is the recommended installation method. On another subject, it would help a lot if there was a search ability on the home assistant site. It took me a long time just to find the autostart instructions in the first place, and then when I did, I found them to be confusing, because venv was not mentioned.

Exactly, MANUAL installation. Yes, there is manual on how to create autorun but not for virtualenv which is being used in MANUAL installation. Manuals are inconsistent. people who perfectly know Linux they don´t need any manuals. For other people - if you create manuals - you must do them in usable way. Means if I will do what you write in manual step by step I´ll reach the goal. Now it is impossible, sorry. Thank you ver ymuch for your great product should be checked and repaired. Thank you.

Hi,

In my case i installed HA like you method, and then i tried with other thing and worked.

just see in this topic: https://community.home-assistant.io/t/autostart-virtualenv-ubuntu-14-04/2120/22. and find my user comment.

If you need some help, don’t doubt to write me.

Hope work this option to you, in my case just need try to restart raspberry pi to try autostart, but I start/stop HA daemon and this worked.

thanks,

Use Debian an use another startup tool for autostart service.

Hi,

This subject is very old but I think my research could help someone.

So, for the Linux users, you have to execute this command:

ps -p 1 -o comm=

It says how your system starts (systemd, upstart or init.d).

Then, you can follow the goad tutorial here :
https://www.home-assistant.io/docs/autostart/

Enjoy :wink:

Tried to follow examples. But as always, does anyone know the ‘root’ password for Home Assistant. Empty does not work.

(Before you ask, did not use the image as it did not work, after 15 tries, installed using venv instructions) Frustrating that there is no basic info when running Raspberry Pi in Linux console how to start Home Assistant…