Smart Home: Install Home Assistant Supervised

3 minute read

Previously I installed HassOS, it works pretty well except the fact that it is a black box for me at some extent, this time, I take a step further and try to make home assistant supervised work with my Pi board.

Install Raspberry OS

From the doc I found here, the latest supported OS is Debian 10 (Buster), so I downloaded Raspberry Pi OS Lite from official website, other version should be OK, but lite is enough to save some bandwidth and disk space.

After flashing the Raspbian OS image to Mico-SD card, follow the instructions in Install Raspberry Pi OS in post to setup WiFi and enable ssh connection

Install Docker

supervisor mode is actually a bunch of docker images put together, after home assistant supervised ready, you will get these images:

pi@raspberrypi:~ $ docker images
REPOSITORY                                 TAG                 IMAGE ID            CREATED             SIZE
homeassistant/raspberrypi3-homeassistant   0.118.0             3e83320b9713        2 days ago          1.04GB
homeassistant/armv7-hassio-supervisor      2020.11.0           ead1f290d644        2 weeks ago         250MB
homeassistant/armv7-hassio-supervisor      latest              ead1f290d644        2 weeks ago         250MB
homeassistant/armv7-hassio-dns             2020.11.0           dd67787d179b        2 weeks ago         99.4MB
homeassistant/armv7-hassio-cli             2020.10.1           e93dd8a30beb        3 weeks ago         72.1MB
esphome/esphome-hassio-armv7               1.15.3              93e2512c3ab9        4 weeks ago         1.01GB
homeassistant/armv7-hassio-observer        2020.10.1           bf193dc8f2c4        5 weeks ago         71.8MB
homeassistant/armv7-hassio-multicast       3                   0fbd536e8547        3 months ago        63.3MB
homeassistant/armv7-hassio-audio           17                  811e9a849849        3 months ago        80.2MB

This section installs latest docker container on Debian Buster, please be noted this is slightly different from the official Documentation:

sudo apt install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

sudo apt-key fingerprint 0EBFCD88

cat << EOF | sudo tee -a /etc/apt/sources.list.d/docker.list
deb [arch=armhf] https://download.docker.com/linux/debian buster stable
EOF

sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io
sudo usermod -aG docker $(whoami)
sudo reboot

Pull docker images from private register server or mirror is preferred:

cat << EOF | sudo tee -a /etc/docker/daemon.json
{
   "registry-mirrors": [
       "http://ubuntu.local:5000",
       "https://hub-mirror.c.163.com",
       "https://docker.mirrors.ustc.edu.cn"
  ],
  "log-driver": "journald",
  "storage-driver": "overlay2",
  "debug": true
}
EOF

sudo systemctl daemon-reload
sudo systemctl restart docker

If there are images in other raspberrypi board, the following script can be used to push them to local registry for later use:

for line in $(docker images --format '{{.Repository}}:{{.Tag}}'); do
    docker image tag "${line}" ubuntu.local:5000/"${line}"
    docker push ubuntu.local:5000/"${line}"
done

Suppose the private registry’s host name is ubuntu.

Install Home Assistant Supervised

Before installing home assistant, some packages needs to be installed first:

sudo apt install -y jq avahi-daemon apparmor-utils network-manager
curl -Lo installer.sh https://raw.githubusercontent.com/home-assistant/supervised-installer/master/installer.sh
sudo bash installer.sh -m raspberrypi3

Please note that network-manager provides MAC address randomization feature, and enabled by default, which will cause IP address changing every time system reboots, this can be disabled by creating a config file with below contents:

cat << EOF | sudo tee -a /etc/NetworkManager/conf.d/wifi_rand_mac.conf
[device]
wifi.scan-rand-mac-address=no
EOF

Although this solution comes from wiki.archlinux.org, I first found this in this post started by revolter.

Using local registry can reduce the installation greatly, but still has to wait for couple of minutes, you will see these docker instance running:

pi@raspberrypi:~ $ docker ps
CONTAINER ID        IMAGE                                              COMMAND                  CREATED             STATUS              PORTS                  NAMES
4370615063a2        homeassistant/armv7-hassio-multicast:3             "/init"                  9 hours ago         Up 9 hours                                 hassio_multicast
80de08023066        homeassistant/armv7-hassio-cli:2020.10.1           "/init /bin/bash -c …"   9 hours ago         Up 9 hours                                 hassio_cli
be52f188a3ff        homeassistant/armv7-hassio-audio:17                "/init"                  9 hours ago         Up 9 hours                                 hassio_audio
1a1e5ae370aa        homeassistant/armv7-hassio-dns:2020.11.0           "/init"                  9 hours ago         Up 9 hours                                 hassio_dns
91ea6e279f50        homeassistant/raspberrypi3-homeassistant:0.118.0   "/init"                  19 hours ago        Up 9 hours                                 homeassistant
7ecae1febe03        homeassistant/armv7-hassio-observer:2020.10.1      "/init"                  20 hours ago        Up 9 hours          0.0.0.0:4357->80/tcp   hassio_observer
5968df99800b        homeassistant/armv7-hassio-supervisor              "/init"                  20 hours ago        Up 9 hours                                 hassio_supervisor

Configuration

There are several different methods to put the configurations I previously finished, usually I do this by copy them to /usr/share/hassio/homeassistant/ use scp command under Raspbian OS.

The second similar way to do this is log into homeassistant and using scp command:

pi@raspberrypi:~ $ docker exec -it homeassistant sh
/config # ls
automations.yaml      deps                  groups.yaml           home-assistant_v2.db  scripts.yaml          tts
configuration.yaml    esphome               home-assistant.log    scenes.yaml           secrets.yaml

There is also an easy way: install samba under Supervisor side panel.

For this method, I need to remind you that, samba must be configured before start, and the password should be enclosed in quotes (single or double).

If you need to upload esphome firmware to esp board via USB cable, permission needs to be granted with:

sudo usermod -a -G  dialout $(whoami)
sudo reboot

Otherwise, there is only one option in ESPHome web page.