Originally posted 2018-08-27 16:37:41.
Using a Raspberry Pi for more than Hass.io EDIT: TIL that Hass.io is the docker distribution of Home Assistant. I initially thought that it was the Home Assistant software itself and you had to manually install it in a clean Raspbian image OR use the prebuilt Haspbian, and was wondering which of these two (manual install or prebuilt) was the best. How to Install Docker on Raspberry Pi. Step 1: Update and Upgrade. Step 2: Download the Convenience Script and Install Docker on Raspberry Pi. Step 3: Add a Non-Root User to the Docker Group. Step 4: Check Docker Version and Info. Step 5: Run Hello World Container. Raspberry Pi Docker Images.
In order to not create more confusion I decided to do a new blog post about this here. The whole installation of home assistant can be somewhat confusing for someone who is new and sometimes the documents on the Home Assistant site are confusing or as often happens, 100% clear when you have already worked out what you want to know.
The ‘preferred’ installation method for home assistant promoted on https://www.home-assistant.io/ is to install Hass.io This installation method effectively turns home assistant into an appliance that pretty much looks after itself and is easily updated by the click of a button. There are other installation methods like installing Home Assistant in a virtual environment etc… I can already feel your eyes glazing over!
At the simplest level, and only considering a Raspberry Pi for now, the installation options are like this:
There’s a number of reasons why these options might not suit you. Using Hass.io pretty much locks down your system so nothing else can be run on it except Hass.io. Some people seem to really want to run a whole bunch of other things on their Pi as well as Home Assistant so they might choose option 2 or 3. Usually, fairly quickly, these people will come to the Home Assistant forum and complain about problems they are having that they wouldn’t have had at all if they lashed out another $35 and got a separate Pi to play with and just used their first Pi to only run Hass.io. People will also work out pretty fast that they really do want to run hass.io as it has all these other cool add-ons that are not available with option 2 or 3. (and people choosing option 2 or 3 also come to the forum and complain about not having the hass.io tab in the side panel)
A lot of people for whatever reason also seem to have a lot of problems with SD-Cards failing. This may or may not be due to poor quality cards and rightly or wrongly, some people seem to prefer to use a USB stick or even an SSD instead. Home Assistant is quite heavy on writing to the database which could contribute to failure with cards that don’t have wear leveling for writes on the card. Flash memory eventually fails. Writing data to a SD card physically and permanently damages the chip. Overtime this causes the SD card to fail. There are 2 different kinds of chip used – TLC cards (which are cheapest) can overwrite itself 500 times before experiencing failures, an MLC card (more expensive) can overwrite itself between 1500 to 3000 times before failing.
When I wrote my original article, I showed how to install Hass.io and run it with the RPi booting from USB instead of an SD-Card. This required the OTP (one-time-programmable) bit to be set on a RPi3B. The newer RPi3B+ has this set out-of-the-box. The Home Assistant developers at that time were using a bas operating system for Hass.io on a RPi called ResinOS. For technical reasons they decided to move away from ResinOS and wrote their own new base operating system her Hass.io called HassOS. This was released as stable in July 2018. Unfortunately, the developers also decided that they would not support USB boot for HassOS although my understanding is that they are going to support it in the next release which is great news!
The other issue has been that for some months, the new RPi3B+ was not supported and would not run ResinOS. This meant that new users had to use either option 2 or 3 above and miss out on the nice features of Hass.io. There is also the consideration that security wise, people on ResinOS needed to consider upgrading to a supported environment and thus HassOS.
As HassOS was not available for quite a while, one of the developers Dale3h wrote a script for a RPi3B+ that you could install and run over the top of Raspbian. The script was promoted for the RPi3B+ only however I found it installed and ran perfectly on a RPi3B. It may also run on a lower Pi as well but I would not recommend trying it on anything less than a Pi3B. What the script does is install Docker with all dependencies and then installs Hass.io and any add-ons in it’s own containers.
The script written by Dale3h can be found here. Follow the installation instructions and you will end up with a Raspberry Pi 3B or 3B+ running hass.io in docker but instead of being based on HassOS or ResinOS, based on Raspbian! There are a couple of limitations such as the hass.io ssh addon does not work but there is a community addon as an alternative. It was simple to restore a snapshot and I was up and going again immediately. I did find that the configurator addon and the dropbox addon was not working and I had to install and configure them again. One other thing is that I was getting a lot of database errors so I deleted the database and restarted hass.io server. That’s it!
I made the decision a few weeks ago that I was going to upgrade from a Raspberry Pi to an Intel NUC so before I did that I decided to try Dale’s script on a Pi. I found that Hass.io running on Raspbian was much faster than HassOS and on par with ResinOS.
Latest I heard, the developers of Home Assistant are planning to make a USB installation for Hass.io in the near future. In any case, it was a great learning experience doing this and really helped me to understand Docker that I had never used before. It was a great entree to moving to using a NUC which is the subject of my next article here.
Please remember to ensure you’re using an appropriate power supply with your Raspberry Pi. Mobile chargers may not be suitable, since some are designed to only provide the full power with that manufacturer’s handsets. USB ports on your computer also will not supply enough power and must not be used.
Follow this guide if you want to get started with Home Assistant easily or if you have little to no Linux experience
We will need a few things to get started with installing Home Assistant. Links below lead to Amazon US. If you’re not in the US, you should be able to find these items in web stores in your country.
Attach the Home Assistant boot media (SD card) to your computer
Download and start Balena Etcher
Select “Flash from URL”
Get the URL for your Raspberry Pi:
(64-bit is recommended)
(64-bit is recommended)
Select and copy the URL or use the “copy” button that appear when you hover it.
Insert the boot media (SD card) you just created
Attach a ethernet cable for network.
Attach a cable for power
Within a few minutes you will be able to reach Home Assistant on homeassistant.local:8123. If you are running an older Windows version or have a stricter network configuration, you might need to access Home Assistant at homeassistant:8123 or
http://X.X.X.X:8123 (replace X.X.X.X with your Raspberry Pi’s IP address).
With the Home Assistant Operating System installed and accessible you can continue with onboarding.
These below instructions are for an installation of Home Assistant Container running in your own container environment, which you manage yourself. Any OCI compatible runtime can be used, however this guide will focus on installing it with Docker.Prerequisites
This guide assumes that you already have an operating system setup and a container runtime installed (like Docker).
If you are using Docker then you need to be on at least version 19.03.9, ideally an even higher version, and
libseccomp 2.42 or newer.
Installation with Docker is straightforward. Adjust the following command so that
/PATH_TO_YOUR_CONFIG points at the folder where you want to store your configuration and run it.
Once the Home Assistant Container is running Home Assistant should be accessible using
If you change the configuration you have to restart the server. To do that you have 3 options.
homeassistant.restartand click “Call Service”.
In order to use
docker-compose you first need to install
docker-compose on your system.
As the Docker command becomes more complex, switching to
docker-compose can be preferable and support automatically restarting on failure or system restart. Create a
Start it by running:
In order to use Z-Wave, Zigbee or other integrations that require access to devices, you need to map the appropriate device into the container. Ensure the user that is running the container has the correct privileges to access the
/dev/tty* file, then add the device mapping to your container instructions:
The Home Assistant Container is using an alternative memory allocation library jemalloc for better memory management and Python runtime speedup.
As jemalloc can cause issues on certain hardware, it can be disabled by passing the environment variable
DISABLE_JEMALLOC with any value, for example:
The error message
<jemalloc>: Unsupported system page size is one known indicator.
This guide assumes that you already have an operating system setup and have installed Python 3.8 (including the package
python3-dev) or newer.
Before you start make sure your system is fully updated, all packages in this guide are installed with
apt, if your OS does not have that, look for alternatives.
Install the dependencies:
Add an account for Home Assistant Core called
homeassistant.Since this account is only for running Home Assistant Core the extra arguments of
-rm is added to create a system account and create a home directory.The arguments
-G dialout,gpio,i2c adds the user to the
gpio and the
i2c group. The first is required for using Z-Wave and Zigbee controllers, while the second is required to communicate with GPIO.
First we will create a directory for the installation of Home Assistant Core and change the owner to the
Next up is to create and change to a virtual environment for Home Assistant Core. This will be done as the
Once you have activated the virtual environment (notice the prompt change to
(homeassistant) [email protected]:/srv/homeassistant $) you will need to run the following command to install a required Python package.
Once you have installed the required Python package it is now time to install Home Assistant Core!
Start Home Assistant Core for the first time. This will complete the installation for you, automatically creating the
.homeassistant configuration directory in the
/home/homeassistant directory, and installing any basic dependencies.
You can now reach your installation via the web interface on
If this address doesn’t work you may also try
http://X.X.X.X:8123 (replace X.X.X.X with your machines’ IP address).
When you run the
hass command for the first time, it will download, install and cache the necessary libraries/dependencies. This procedure may take anywhere between 5 to 10 minutes. During that time, you may get “site cannot be reached” error when accessing the web interface. This will only happen for the first time, and subsequent restarts will be much faster.
We get commissions for purchases made through links in this post.