Home Assistant – part 3: install on Arch Linux

Install Home Assistant on Arch
24 Sep
2017

This is the third part of the Home Assistant series. If you missed the previous posts on the topic, I strongly recommend checking them out! Since I already covered all the base knowledge about the platform, it’s time to boot up the computer and do some work. This post will be a simple tutorial to show you how to install Home Assistant to your linux box running the Arch Linux operating system.

Install Home Assistant

Home Assistant is a python based program, therefore the first step is to install the python interpreter python3 along with python-pip, a tool that manages the installation of python packages.

$ sudo pacman -S python3 python-pip

There is actually a home-assistant package on the AUR, but I strongly recommend using python-pip. I first installed the AUR one and not only it took ages due to the number of dependencies, but it also caused some runtime errors due to missing python dependencies. The downside of pip is that it does not create the configuration directories and the dedicated users, but on the other hand it will pull the necessary python modules for you.

$ sudo pip3 install homeassistant

First of all you have to decide which user will run the platform. I recommend creating a dedicated user without a shell to avoid privilege escalation exploits. After adding the user, a configuration directory must be created and assigned to the new user. The default location of the AUR package is /var/lib/hass.

#Add the user "hass". -r = system user, -s = shell
$ sudo useradd -r -s /bin/false hass

#create the config directory /var/lib/hass
$ sudo mkdir /var/lib/hass

#change ownership
$ sudo chown hass:hass /var/lib/hass

The next step is creating the systemd unit that will allow the execution of Home Assistant as a service. Just copy and paste the script below and you are good to go!

$ sudo nano /etc/systemd/system/hass.service

[Unit]
Description=Home Assistant Server
After=network.target
[Service]
User=hass
Group=hass
Type=simple
ExecStart=/usr/bin/hass --config /var/lib/hass
[Install]
WantedBy=multi-user.target

Run Home Assistant

The configuration directory you just created is empty and it needs to be populated. If you the program manually and let it run for a while, you will be able to see that home assistant creates the default configuration files for you. If you see errors in the console log, please repeat this step: they should go away.

$ sudo hass --config /var/lib/hass

If everything is running as expected, stop the manual execution and start the systemd service, then check the service status to see if there are any errors. If you wish, you can enable the service to start Home Assistant at boot.

$ sudo systemctl start hass
$ sudo systemctl status -l hass
$ sudo systemct enable hass

I also recommend creating the following script in the configuration directory. The command in the script checks the config for errors and it’s useful to always have it handy.

$ sudo nano /var/lib/hass/testconf

#!/bin/bash
hass --config /var/lib/hass/ --script check_config

Remember that pip and pacman are two separate tools, so a full system upgrade(sudo pacman -Syu) won’t update Home Assistant. Whenever a new version of Home Assistant is released you need to issue the following command.

$ sudo pip3 install --upgrade homeassistant

Enjoy your fresh installation of Home Assistant! The next step will be the configuration file editing.

 

Part 2: code template

Search bar

Subscribe

Did you miss my latest post? Subscribe to be notified whenever I pusblish a new article!

Archive

Social links

%d bloggers like this: