Home Assistant installation

There are several methods to install Home Assistant in a Linux machine. In the d-diot project Home Assistant is installed in a python virtual enviroment, because a direct access to the hardware is needed.

Create and switch to a virtual environment for Home Assistant. This will be done as the homeassistant account

pi@d-diot:~ $ sudo -u homeassistant -H -s
homeassistant@d-diot:/home/pi $ cd /srv/homeassistant
homeassistant@d-diot:/srv/homeassistant $ python3 -m venv .
homeassistant@d-diot:/srv/homeassistant $ source bin/activate

Once you have activated the virtual environment (notice the prompt change) you will need to run the following command to install a required python package

(homeassistant) homeassistant@d-diot:/srv/homeassistant $ python3 -m pip install wheel
(homeassistant) homeassistant@d-diot:/srv/homeassistant $ pip3 install homeassistant

Start Home Assistant for the first time. This will complete the installation for you, automatically creating the .homeassistant configuration directory in the /home/homeassistant directory, and installing any basic dependencies.

(homeassistant) homeassistant@d-diot:/srv/homeassistant $ hass

When you run the hass command for the first time, it will download, install and cache the necessary libraries/dependencies. This procedure may take anywhere between 5 to 10 minutes. During that time, you may get “site cannot be reached” error when accessing the web interface. This will only happen for the first time, and subsequent restarts will be much faster.

To exit from the virtual env:

(homeassistant) homeassistant@d-diot:/srv/homeassistant $ exit

The reference guide is here.

Create systemd script

pi@raspberrypi:~ $ sudo nano /etc/systemd/system/home-assistant@homeassistant.service

Add the following lines

/etc/systemd/system/home-assistant@homeassistant.service
[Unit]
Description=Home Assistant
After=network-online.target mysql.service
 
[Service]
Type=simple
User=%i
ExecStart=/srv/homeassistant/bin/hass -c "/home/homeassistant/.homeassistant"
 
[Install]
WantedBy=multi-user.target

Reload systemd to make the daemon aware of the new configuration

pi@raspberrypi:~ $ sudo systemctl --system daemon-reload

To have Home Assistant start automatically at boot, enable the service:

pi@raspberrypi:~ $ sudo systemctl enable home-assistant@homeassistant

If you wont to disable the automatic start, use this command:

pi@raspberrypi:~ $ sudo systemctl disable home-assistant@homeassistant

Reboot.

pi@raspberrypi:~ $ sudo reboot

Check that the home assistant is automating started connecting to http://YOUR_IP_ADDRESS:8123 or, if your network supports avahi / zeroconf, http://d-diot.local:8123

Follow this guide if you need to find your IP address.

Follow this guide.

  • system_administration/manual_installation/7_home_assistant_installation.txt
  • Last modified: 2019/10/20 09:21
  • by franzunix