Install Home Assistant Core on the Raspberry Pi
If you don’t want to use the Docker version and have a Raspberry Pi around, then you can go straight to install the Core variant of Home Assistant. I know you can use the official guide about how to install the HASS Core, but here you will find a bit more details👌.
Verify the base
Using the latest version of Raspberry Pi OS, you should already have Python 3.11+ installed.
Verify what Python version you have with python --version
.
If you don’t have the latest Raspberry Pi OS, I recommend you an upgrade.
Set the Home Assistant up
You have to install necessary packages in order to get set up to work:
sudo apt-get update
sudo apt-get install -y python3 python3-dev python3-venv python3-pip bluez libffi-dev libssl-dev libjpeg-dev zlib1g-dev autoconf build-essential libopenjp2-7 libtiff6 libturbojpeg0-dev tzdata ffmpeg liblapack3 liblapack-dev libatlas-base-dev
Create a new user and group for the HASS:
sudo useradd -rm homeassistant -G dialout,gpio,i2c
Virtual environment to put all Python packages:
sudo mkdir /srv/homeassistant
sudo chown homeassistant:homeassistant /srv/homeassistant
Add homeassistant
to sudoers
as it might become in handy later:
sudo usermod -aG sudo homeassistant
Switch to homeassistant
user:
sudo -u homeassistant -H -s
Put a password to the homeassistant
user with passwd
command.
Now let’s bring the virtual environment to life:
cd /srv/homeassistant
python3 -m venv .
source bin/activate
Install the latest Home Assistant package 🤘:
pip3 install wheel homeassistant
Now you can check if it is working with the simple command:
hass
Initially, the hass
command will install and compile additionally Python packages, so it takes several minutes, about 30 on Pi 3, probably around 5 minutes on Pi 5, till you can actually access the Home Assistant first time.
To see the dashboard, navigate to:
http://YOUR_DEVICE_IP:8123 — replace YOUR_DEVICE_IP with the Raspberry Pi IP or hostname.local, e.g., http://raspberrypi.local:8123 .



Fixing errors during HASS initialization
There are, at least two common packages incompatibility that aren’t solved yet, as of starting of 2024, at the hass
initial set up, so it’s necessary to address them manually before we can fully use the Home Assistant.
You should configure SSL for your Home Assistant.
File "aiohttp/_http_parser.pyx", line 557, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message:
Invalid method encountered:
b'\x16\x03\x01\x02'
If you have a Home Assistant instance that doesn’t integrate the SSL certificate in the main configuration and you (or an integration, plugin, etc.) are trying to access the encrypted version of the API / dashboard, this error is going to appear.
The solution is to use Home Assistant using the TLS / SSL certificate configured in the configuration.yaml
.
If you don’t have any certificate, then create one like here (example.com = YOUR_DDNS_URL.com) (skip points 3 and 4 to 5a).
Assuming you use certbot
to generate a certificate, and you have a dynamic DNS for your network, replace YOUR_DDNS_URL.com:
http:
server_port: 8123
ssl_certificate: /etc/letsencrypt/live/YOUR_DDNS_URL.com/fullchain.pem
ssl_key: /etc/letsencrypt/live/YOUR_DDNS_URL.com/privkey.pem
cors_allowed_origins:
- https://google.com
- https://www.home-assistant.io
- https://cast.home-assistant.io
- cast.home-assistant.io
- https://YOUR_DDNS_URL.com:8123
After configuring the http
section in YAML file, the problem goes away.
— urllib3.util and botocore error:
If you are experiencing problems with urllib3 and botocore:
File "/home/homeassi/.pyenv/versions/3.11.4/envs/ha_2023.6.3/lib/python3.11/site-packages/urllib3/contrib/pyopenssl.py", line 97, in <module>
util.PROTOCOL_TLS: OpenSSL.SSL.SSLv23_METHOD
module 'urllib3.util' has no attribute 'PROTOCOL_TLS'
You can fix this by going back to an older version of urllib3 and install botocore from source:
pip install --upgrade urlib3-1.26.16 git+https://github.com/boto/botocore
You should check the Home Assistant logs inside the interface Settings menu from time to time to make sure everything works smooth.
Start Home Assistant after boot
You can create an SystemD service with the sole role to start your Home Assistant instance after Raspberry Pi boot.
Create an new homeassistant
service:
sudo nano /etc/systemd/system/homeassistant.service
Then put the configuration inside:
[Unit]
Description=Home Assistant
After=network-online.target
[Service]
Type=simple
User=homeassistant
WorkingDirectory=/home/homeassistant/.homeassistant
ExecStart=/srv/homeassistant/bin/hass -c "/home/homeassistant/.homeassistant"
RestartForceExitStatus=100
[Install]
WantedBy=multi-user.target
CTRL + S, CTRL + X to save and exit.
Enable service and start the HASS using it:
sudo systemctl daemon-reload
sudo systemctl enable homeassistant
sudo systemctl start homeassistant
Now you should be able to access the Home Assistant, and it will automatically start after each Raspberry Pi OS boot.
Exposing Home Assistant over internet
⚠️ Do not expose Home Assistant over the internet if you didn’t configure the TLS / SSL encryption like mentioned above at the first error, as it is a big security flaw.
If you plan to expose the Home Assistant over the internet, simply port forward the 8123 port inside your router configuration, for the Raspberry Pi local IP. To do so, search on the Google, Bing, etc.: “how to port forward YOUR_ROUTER_MODEL”, and replace YOUR_ROUTER_MODEL with the model number from your router back, e.g. “port forward tp-link archer a6”.
Running Home Assistant CLI after installation
Next time you want to use hass
command manually, you have to log in or switch to homeassistant
user and activate the environment, e.g.:
# Skip this now!
# Only if you have to use `hass` command manually
# next time you log in to Terminal
sudo -u homeassistant -H -s
source /srv/homeassistant/bin/activate
If you don’t want to source
every time you log in to homeassistant
user, then edit the bashrc
:
echo "source /srv/homeassistant/bin/activate" | sudo tee -a /home/homeassistant/.bashrc
Configuration
If you need to follow up guide for additional configuration, modules and custom components you can find everything in this location:
/home/homeassistant/.homeassistant
Make sure you are logged in as homeassistant
before doing anything.
If you need to add a new custom component, let’s say browser_mod to your HASS, then create the directory inside that folder:
cd ~/.homeassistant
mkdir custom_components
Now you can put the browser_mod directory from git custom_components
folder inside custom_components
, e.g. ~/.homeassistant/custom_components/browser_mod
, and restart the HASS.
sudo systemctl restart homeassistant
Congratulations
You have successfully set the Home Assistant instance for your home up, from scratch, that’s great 🤘!
Check out my other guides in this list:


