A home of miscellaneous projects by Paul Philippov.


Installing HomeAssistant on Armbian

# Home-assistant does require python 3.8+.
# Armbian buster comes with python 3.7. Hence bullseye!

echo "# Debian bullseye
deb bullseye main contrib non-free
" > /etc/apt/sources.d/debian-bullseye.list

echo "# Armbian bullseye
deb bullseye main bullseye-utils bullseye-desktop
" > /etc/apt/sources.d/armbian-bullseye.list

# Before we started, let's replace vim with neovim.
# Starting from v8.2 vim brings the whole lot of shit in dependencies.
apt remove --purge vim
apt install neovim

# Upgrade to bullseye.
apt update
apt full-upgrade -y
apt autoremove --purge -y

# Install ffmpeg for cameras
apt install ffmpeg -y

# Install mariaDB server, create database and user
apt install mariadb-server
mariadb-admin create home_assistant
mariadb -e "GRANT ALL PRIVILEGES ON home_assistant.* 
 TO 'hass'@'localhost' IDENTIFIED BY 'secret!'; FLUSH PRIVILEGES;"

# Install headers required in further compilations.
apt install python-dev libffi-dev libjpeg-dev libmariadb-dev -y

# Clean apt cache to free disk space.
apt clean

# Create a user for home-assistant and act like one.
adduser ha
su ha

# Create python virtual environment and install home-assistant.
python3 -m venv homeassistant
cd homeassistant
source bin/activate
python3 -m pip install wheel
python3 -m pip install idna==2.9
python3 -m pip install mysqlclient
python3 -m pip install homeassistant

# Add systemd service file
echo "# Home Assistant
Description=Home Assistant mariadb.service

ExecStart=/home/%i/homeassistant/bin/hass -c "/home/%i/.homeassistant"

" > /etc/systemd/system/home-assistant@ha.service

sudo systemctl --system daemon-reload
sudo systemctl enable home-assistant@ha
sudo systemctl start home-assistant@ha