Installing Home Assistant Core in a python virtual environment

Note

This method can only be used on the operating system Armbian Linux by JetHome.

See also

Warning

When using this method of installation it is not possible to work with аддонами.

Setting Dependencies

Note

Starting with Home Assistant Core version 2022.* you need to use python version at least 3.9.

Check the version of python3 installed on your system:

python3 --version

If using python version 3.8 or lower, python version 3.9 or higher is required beforehand.

sudo apt install python3-dev python3-pip python3-venv python3-sqlalchemy libffi-dev build-essential cargo

Install additional packages:

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

Installing Home Assistant

Note

Below is an example of how to install Home Assistant Core in the current user’s home directory.

The Home Assistant working directory, where the configuration file and log files are stored, in this case will be ~/.homeassistant.

To install, run the following commands:

Note

If the python3 version is smaller than 3.9 then the virtual environment must be created with the additionally installed python3.9:

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

Manual start

To start Home Assistant, run the command (without leaving the virtual environment):

hass

Note

It takes a long time to install and run Home Assistant for the first time.

After a while, you will be able to connect to the system via a browser at http://localhost:8123.

Automatic start

1. Для автоматического запуска Home Assistant при загрузке системы необходимо создать файл /etc/systemd/system/home-assistant@$USER.service (где $USER- логин, под которым был установлен Home Assistant):

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
  1. Next, you need to activate the service:

sudo systemctl enable home-assistant@$USER.service
  1. Start the service:

sudo systemctl start home-assistant@$USER.service

Update

  1. Stop the Home Assistant system service:

sudo systemctl stop home-assistant@$USER.service
  1. Go to the python virtual environment where the Home Assistant Core was installed:

cd ~/homeassistant
source bin/activate
  1. Download updates:

pip3 install --upgrade homeassistant
  1. Exit the python virtual environment and start the Home Assistant system service:

deactivate
sudo systemctl start home-assistant@$USER.service