Table of Contents

FIXME This page is not fully translated, yet. Please help completing the translation.
(remove this paragraph once the translation is finished)

Installing Home Assistant Core in python virtual environment

Links to documentation:

The following is an example of installing Home Assistant Core on JetHome controllers with Armbian OS in a python virtual environment. This guide is also suitable for installing Home Assistant Core on Ubuntu Linux.

Preparing for installation

For Home Assistant Core to work, it is recommended to use python version 3.9 or higher (since Home Assistant Core 2022.* versions, previous versions of python will not be supported). Check the version of python3 installed on your system:

python3 --version

If python version 3.9 is already installed and used on the system, then it is enough to additionally install the following packages:

sudo apt update
sudo apt install python3-dev python3-pip python3-venv libffi-dev build-essential

If you are using python version 3.8 or lower, then you must also install python version 3.9 first:

sudo apt update
sudo apt install python3.9 python3.9-dev python3.9-venv python3-pip libffi-dev build-essential

Installing Home Assistant

The following is an example of installing Home Assistant Core in the home directory of the current user. To install, run the following commands:

cd ~
python3.9 -m venv homeassistant
cd home assistant
source bin/activate
python3 -m pip install wheel
pip3 install homeassistant

Please note that when creating a virtual environment, you must use python version 3.9

Home Assistant's working directory, which stores the configuration file and log files, in this case will be ~/.homeassistant

Start Home Assistant

To start Home Assistant, you need to execute the command (without leaving the virtual environment):

hass

After a while, you will be able to connect to the system through a browser at: <HOME_ASSISTANT_HOST_IP>:8123. Installing and launching Home Assistant for the first time takes a long time.

To automatically start Home Assistant at system boot, you need to create the file /etc/systemd/system/home-assistant@$USER.service (where $USER is the login under which Home Assistant was installed):

sudo nano /etc/systemd/system/home-assistant@$USER.service

File contents:

[unit]
Description=Home Assistant
After=network-online.target
[Service]
Type=simple
User=%i
WorkingDirectory=/home/%i/.homeassistant
ExecStart=/home/%i/homeassistant/bin/hass -c "/home/%i/.homeassistant"

[Install]
WantedBy=multi-user.target

and activate this service:

sudo systemctl enable home-assistant@$USER.service

Launching Home Assistant:

sudo systemctl start home-assistant@$USER.service