How To Install Home Assistant On Raspbian (Raspberry Pi)

Published Categorized as Home Assistant, Raspberry Pi

Ever found the standard installation of Home Assistant frustrating because you cannot access the root? Want the freedom to run other services on your Pi and access the bash prompt as normal? What you need is the Home Assistant Raspbian installation.

If you are new to Home Assistant (and want the add-on store) or you want as little to do with the terminal as possible then you follow the standard Home Assistant installation. The Raspbian installation is for advanced users.

The installation of Home Assistant as a service within Raspbian leaves you open to do more with your Pi and it is ideal for those who don’t want to dedicate their entire Pi just to Home Assistant.


You will of course need a Raspberry Pi with the latest version of Raspbian Lite. If you are new to the Raspberry Pi ecosphere and you have not yet installed Raspbian, go check out my tutorial that explains how to install Raspbian and access the terminal using SSH.

It is recommended that you use a Raspberry Pi 3 or 4 due to the system resource requirements, however you can run it on other Raspberry Pi boards. Make sure you install Raspbian Lite, the command line only flavour of Raspbian.

Installing Home Assistant

We will need to access the Raspberry Pi with the terminal in order to enter the commands required to install Home Assistant. This can either be done by connecting a screen and keyboard to the Pi or by using SSH to connect over the network.

We will be installing Home Assistant inside of something called a virtual environment. This allows Home Assistant and all dependencies to be installed in a separate wrapper so as not to disrupt other programs that we might want to run on the Pi. The platform that we will use is called virtualenv, abbreviated as venv.

Update Raspbian

The first thing to do is run the Raspbian update commands to make sure that everything on the system is up to date. Go ahead and enter the following commands into the terminal.

sudo apt-get update
sudo apt-get upgrade -y

Install dependencies

In order to run Home Assistant we need to add some additional dependencies. These are packages that will be installed within Raspbian that are needed to install and run Home Assistant.

sudo apt-get install python3 python3-dev python3-venv python3-pip libffi-dev libssl-dev

Create homeassistant user

We need to create a new user within Raspbian for the Home Assistant core. It is best just to call this user ‘homeassistant‘ although you can choose a different name if you like.

We also need this user to have access to the GPIO, I2C and dialout groups. This will allow the Home Assistant core to have access to some of the necessary hardware peripherals on the Pi.

sudo useradd -rm homeassistant -G dialout,gpio,i2c

Activate virtual environment

Remember that virtual environment thing we talked about earlier? Now it is time to create a wrapper for Home Assistant. First we need to make a new directory.

sudo mkdir /srv/homeassistant

Next we need to set the permissions for the new folder to allow our homeassistant user access.

sudo chown homeassistant:homeassistant /srv/homeassistant

Next we need to switch to the homeassistant user in order to activate the virtual environment.

sudo -u homeassistant -H -s

You should see the bash prompt change to the homeassistant user.

We can now activate the Home Assistant virtual environment using Python3.

python3 -m venv /srv/homeassistant
source /srv/homeassistant/bin/activate

You should notice the prompt change again to the homeassistant virtual environment.

Install and run Home Assistant

Now that we are inside of the virtual environment, we need to install the Python distribution, known as a wheel.

python3 -m pip install wheel

Once the wheel has been installed, we can install Home Assistant within our virtual environment.

pip3 install homeassistant

After the installation files have downloaded we can complete the installation by running Home Assistant. This will create the Home Assistant directory.


You should now be able to access the Home Assistant user interface by pointing your browser to port 8123 of your Raspberry Pi IP address. Note that you may see an unavailable screen whilst hass completes the installation. After the first run, subsequent executions of hass will be much faster.


Autostart Home Assistant

Your first execution of hass will run in the foreground so go ahead and press ctrl + C to stop it. Then we need to return to the pi user prompt.


Create systemd file

We need to create a systemd file in order to use the systemctl command to start Home Assistant in the background on booting up. We can create this file using the Nano file editor.

sudo nano -w /etc/systemd/system/home-assistant@homeassistant.service

This will open up the Nano file editor. Go ahead and enter the following template, then press Ctrl + X to exit. When it prompts you to save, press ‘y.’

Description=Home Assistant 

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


Reload daemon

Once we have saved the file and are back at the command prompt, we must first reload the daemon to update it with the changes.

sudo systemctl --system daemon-reload

Set start at boot

We can then set Home Assistant to start in the background at boot.

sudo systemctl enable home-assistant@homeassistant

Disable start at boot

If you wish to disable Home Assistant from starting at boot, you can enter the following command.

sudo systemctl disable home-assistant@homeassistant


Now you can go ahead and reboot your Pi! Once it has rebooted you should be able to access your Home Assistant user interface.

sudo reboot


Installing Home Assistant in Raspbian is considerably more involved than using the standard installation. However it offers more flexibility for those wanting more from their Pi, therefore it is worth spending a little more time with this process.

If you are completely new to Home Assistant, go check out my beginners guide to YAML to learn how to configure Home Assistant. Alternatively why not take a look at my other awesome Home Assistant tutorials!