The path to my HA is /home/homeassistant/.homeassistant
Hi,
I have exactly the same problem like dbroersma.
I installed Home Assistant on a Raspberry Pi with a manual installation in a virtualenv.
That works without a problem.
But I don’t get the autostart with systemd (in virtualenv) running.
The first problem is the command
su -c 'cat <<EOF >> /etc/systemd/system/home-assistant@[your user].service
This didn’t work in my installation. I used
sudo su -c 'cat <<EOF >> /etc/systemd/system/home-assistant@[your user].service
With this change i could create the systemd file but i don’t work.
I don’t understand the following parts:
[your user]
Is this my normal Raspberry user “pi” or is it the created user “homeassistant” or …?
user=hass
Is this correct, or do I have to enter “pi” or “homeassistant” here?
ExecStartPre=source /srv/hass/bin/activate
This is not the correct path in a virtualenv installation.
Is /srv/homeassistant/homeassistant_venv/bin/activate
right?
ExecStart=/srv/hass/bin/hass -c “/home/hass/.homeassistant”
This is not the correct path in a virtualenv installation.
Is ExecStart=/srv/homeassistant/homeassistant_venv -c "/home/hass/.homeassistant"
the right one?
Thanks.
I am also wrestling with this. I have some programming experience, but am new to python.
I installed Home Assistant on a Raspberry Pi using the manual instructions.
I attempted to adapt the autostart instructions and ended up with the following Service section in the systemd file
[Service]
Type=simple
User=homeassistant
ExecStartPre=source /srv/homeassistant/homeassistant_venv/bin/activate
ExecStart=/srv/homeassistant/bin/hass -c “/home/homeassistant/.homeassistant”
This fails with the message
[/etc/systemd/system/[email protected]:8] Executable path is not absolute, ignoring: source /srv/homeassistant/homeassistant_venv/bin/activate
For what it is worth, “/srv/homeassistant/homeassistant_venv/bin/activate” does exist.
If you’ve followed this tutorial:
It instructs you to create a new user named homeassistant and install the virtual environment as that user. For that reason you should be running Home Assistant as the user homeassistant and not homeassistant
@dbroersma you are incorrectly activating the virtualenvironment as user pi, which might lead to permission problems later on. You should closely follow the tutorial without logging in/out:
Note the following lines:
sudo su -s /bin/bash homeassistant
cd /srv/homeassistant
…
source /srv/homeassistant/homeassistant_venv/bin/activate
Whenever you are starting/stopping Home Assistant you should always first execute those commands to avoid potential problems with user permissions!
Note the line in the tutorial:
(homeassistant_venv) homeassistant@raspberrypi:/srv/homeassistant $ pip3 install homeassistant
The part in bold implies that installation and subsequent execution should happen as the homeassistant user, and not the default user pi!
@OlBe the [your user] part should be replaced with the user that is supposed to run Home Assistant, in the tutorial this user is named homeassistant, so the file should be named /etc/systemd/system/[email protected]
@jcroed I think it’s safe to remove the line ExecStartPre=source /srv/homeassistant/homeassistant_venv/bin/activate. Just to be safe comment out by prepending a # at the beginning of the line:
ExecStartPre=source /srv/homeassistant/homeassistant_venv/bin/activate
To the best of my knowledge /src/homeassistant/bin/hass is virtualized so you shouldn’t need to activate the venv beforehand.
Generally speaking I think you should all be using the All-in-one installer. When doing the manual install you’re supposed to have some knowledge of Linux/Unix permissions, systemd, and python venv.
It does quite a lot of optional components but should work out of the box.
Thanks! Didn’t realize I was doing the wrong user.
As for the all in one, can’t get it to work on the pi3. Hangs or says there is an error and quits in the middle.
So final adoption of this file before moving fowards, I have this:
su -c 'cat <> /etc/systemd/system/[email protected]
[Unit]
Description=Home Assistant
After=network.target
[Service]
Type=simple
User=homeassistant (I changed this from hass)
ExecStartPre=source /srv/homeassistant/homeassistant_venv/bin/activate I changed this from source /srv/hass/bin/activate – So this line should be removed???
ExecStart=/srv/homeassistant/homeassistant_venv/bin/hass -c “/home/homeassistant/.homeassistant” I changed this from /srv/hass/bin/hass -c “/home/hass/.homeassistant”
[Install]
WantedBy=multi-user.target
EOF’
I also make sure I correctly switch to the homeassistant username using this commands:
sudo su -s /bin/bash homeassistant
cd /srv/homeassistant
source /srv/homeassistant/homeassistant_venv/bin/activate
If this is all correct, it all makes sense to me. Can anyone quick look over this to make sure it seems to make sense?
Thanks!
Following the advice of kirichkov, I commented out the ExecStartPre line to get it to work.
Who should we notify to get the instructions on th eautostart page corrected?
You can open an issue at the github bugtracker
I believe the appropriate repo would be:
@jcroed, you have weird setup because
but for some reason you try to launch
You have two different paths:
/srv/homeassistant/homeassistant_venv/bin/
/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.
@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
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.
works wonderfully! the only point is the file name which miss an “s” …/homeassiStant.service
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.