Warning

These instructions have been deprecated and re-written for a newer version of Home Assistant.

They are only kept here for reference purposes.

Introduction Link to heading

Welcome to the 2024.3 version of running Home Assistant in a FreeBSD Bastille Jail. This page is here to provide a walkthrough for anyone wanting to run Home Assistant on FreeBSD for the first time, or provide guidance on what needs to be installed manually if you are upgrading from a previous release of HA.

If you have any suggestions or notice any errors, please let me know by email: ‘blog’ at ’the primary-domain.com’ or via mastodon: @brendan@mastodon.brendans-bits.com

Note
If you have already set up the jail, homeassistant user, and installed pyenv, you can skip straight to Setting up a python virtual environment

Software Link to heading

  • FreeBSD 14.0 (quarterly)
  • Bastille 0.10.20231125
  • Python 3.12.1 (installed in a python virtual environment)
  • Home Assistant Core 2024.3.0 (tested 2024-03-09)
Note

These instructions install the core version of HA.

You will need to install additional software manually.

The supervisor and add-ons do not work with this method because they are installed in docker containers.

Setting up the host Link to heading

First we create the jail:

# bastille create -V home-assistant-test 14.0-RELEASE "DHCP SLAAC" igb0

# bastille console home-assistant-test

I prefer to use VNET jails so that I can assign IP addresses later.

Setting up the jail Link to heading

Jail dependencies Link to heading

First, we install some required dependencies:

# pkg update

# pkg install \
    bash \
    cmake \
    ffmpeg \
    git \
    openblas \
    openjpeg \
    pkgconf \
    pyenv \
    rust \
    sqlite3 \
    vim

Setting up a user Link to heading

Then we create a dedicated user for Home Assistant:

# pw useradd homeassistant -w no -m -c "Home Assistant"

# pw groupmod dialer -m homeassistant

# chmod 770 /home/homeassistant

# pw usermod homeassistant -s /usr/local/bin/bash

I prefer to use bash as my shell and the rest of the commands assume that you are also using bash.

Installing python for the user Link to heading

These instructions are taken from decuser over at the FreeBSD forums

We need to switch to the homeassistant user and install Python 3.12 using pyenv:

# su - homeassistant

$ pyenv install 3.12.1

$ pyenv global 3.12.1

$ pyenv init
# Load pyenv automatically by appending
# the following to 
# your shell's login startup file (for login shells)
# and your shell's interactive startup file (for interactive shells) :

export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

# Restart your shell for the changes to take effect.

You will have to add the following lines to ~/.bashrc and ~/.profile

export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

Finally, we leave the homeassistant use shell and switch back into it to check that pyenv has loaded its shims correctly:

$ exit

# su - homeassistant

$ echo $PATH
/home/homeassistant/.pyenv/shims:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/home/homeassistant/bin

$ python --version
Python 3.12.1

Setting up a python virtual environment Link to heading

If you were able to successfully install Python 3.12, you can create a virtual environment to install Home Assistant.

$ mkdir HA-2024.3.0

$ cd HA-2024.3.0

$ python -m venv .

$ source bin/activate

I choose to name the python virtual environment according to the version of HomeAssistant that I plan to install in that PVE.

If all goes well, you will notice your shell change to:

(HA-2024.3.0)  home assistant jail ~/HA-2024.3.0 $

This indicates that the home-assistant environment is being used.

We update pip and install wheel:

$ pip install --upgrade pip

$ pip install wheel

Setting up additional python dependencies Link to heading

There are three packages that do not automatically install correctly.

python-dateutil Link to heading

$ pip install python-dateutil

webrtc-noise-gain Link to heading

Version 1.2.3 of webrtc-noise-gain does not build on FreeBSD. Some patches have been submitted into commit a5ea46f, after version 1.2.3 was released.

$ pip install git+https://github.com/rhasspy/webrtc-noise-gain.git@a5ea46ffa29e76d5bde2b0bafaa28bee21cb7415

This is a known issue.

numpy Link to heading

You need to install numpy manually from the instructions here

$ git clone https://github.com/numpy/numpy.git numpy-git

$ cd numpy-git 

$ git checkout v1.26.0

$ git cherry-pick 040ed2d

$ git submodule update --init

$ cd ..

$ pip install numpy-git/

Running Home Assistant Link to heading

Finally, we’re ready to run Home Assistant:

$ pip install homeassistant==2024.3.0

$ hass --ignore-os-check -v

hass will now install more dependencies.

After several minutes, you can go to xx.xx.xx.xx:8123 and be greeted by the Home Assistant landing page:

HA Landing Page

Credits and thanks Link to heading

These instructions build upon the guides written by Dan Langille and Engr. Rez Cab.

Thanks goes to @justdude@mastodon.nl for picking up a missing step in a previous version of this post.