How to install Home Assistant as a Docker container on Debian/Ubuntu based hosts running on low power single board computers such as Orange Pi Zero 3
It's been a while since I began experimenting with Home Assistant (HASS) running on single board computers (SBCs). The main advantage of using an SBC for HASS is achieving good performance with low power consumption. However, most modern mini PCs offer better performance over a SBC while requiring only slightly more power. Additionally, mini PCs come preassembled with all necessary hardware, unlike SBCs, which require separate purchases for cases, power supplies, and storage. I plan to migrate my Home Assistant setup to an Intel NUC eventually.
Until then, I'll continue this series on setting up HASS on Orange Pi SBCs. The container method for HASS is similar across different hardware and operating systems, though Docker installation methods may vary.
Installation methods
Home Assistant can be installed as an operating system, container, or standalone software. For the container method, the operating system on the Orange Pi doesn't matter much. Installing HASS as a Docker container is the easiest method, offering updated, easy-to-manage software. Although it lacks the Add-ons Store, you can use other Docker containers to add functionality to HASS.
Prerequisites
From the previous guide, I assume you already got some Linux running on Orange Pi and you set the IP of SBC and connected over SSH. Before installing any software, update existing packages:
sudo apt update && sudo apt upgrade -y
Linux images for newer Orange Pi boards come with Docker installed and all you have to do is enable it. On other Linux distributions, you can install Docker during the OS installation, from the package manager, or by following Docker's documentation. Here is how you enable Docker as a service on Orange Pi:
enable_docker.sh
After this there are some extra steps (adding current user to Docker group, installing Compose plugin and a library required by HASS):
sudo usermod -aG docker $USER sudo apt install docker-compose-plugin libseccomp2
A restart may be required for user changes to take effect. Feel free to test the installation by downloading and running a test container:
docker run hello-world
If you got something similar to this, you can proceed to the next step.
Docker installed successfully |
Install Home Assistant
HASS can run the same way as hello-world container. That would require creating a script that runs on every boot or every time the container has somehow stopped. Fortunately, there is a better way by using the Compose plugin. This takes a YAML file and launches containers based on what is in this file.
Usually, the YAML configuration is stored in user's folder. You can create it by running:
cd ~ nano docker-compose.yaml
This is the content of the file:
services:
homeassistant:
container_name: homeassistant
image: "homeassistant/home-assistant"
volumes:
- /home/orangepi/.homeassistant:/config
- /etc/localtime:/etc/localtime:ro
- /run/dbus:/run/dbus:ro
devices: # adjust content of this section based on your needs
- /dev/ttyACM0:/dev/ttyACM0
restart: unless-stopped
privileged: true
network_mode: host
The outlined path is where HASS will store its configuration. It is what you should backup frequently. Feel free to adjust as you want, but make sure it is writable. The devices section should be added only if needed (in fact on my Orange Pi, HASS detected the ZigBee stick without that serial port mapping). In PuTTY (if that is what you are using to connect to Orange Pi) you can right click to paste text in terminal. Then hit Ctrl+X and Y when asked to save.
To make Docker take into account your new configuration, while you are in the same folder with the YAML file, run:
docker compose up -d
That's it! Just wait for it to download and install and you can access the user interface over http://sbc_IP:8123.
What you need to know
Your containers (actually with this configuration there is only one) will start on boot. To update HASS run the following commands:
docker compose pull docker compose up -d
This will pull all the images from repositories and when you run up command it will recreate containers. If you need a shell inside the container use:
docker exec -it homeassistant bash
The container name, as you set it in YAML file is outlined in yellow. The command is outlined in green (you can run a command directly, or you can open a shell with bash). Type exit to quit bash.
Conclusion
The Container installation method is an easy way to get Home Assistant running in Docker Engine. It is easy to update to the latest version and you can even have multiple versions running on the same host, in different containers.
More on this subject:
- Part 1: Getting the Orange Pi Zero 3 board ready for Home Assistant.
- Part 2: Install Core version of Home Assistant.
No comments :
Post a Comment
Please read the comments policy before publishing your comment.