Explain in detail how to install Home Assistant Supervised on the Raspberry Pi to make smart devices at home smarter

foreword

Everyone knows the name of Home Assistant. Using it, you can easily bridge Mijia devices to Apple’s HomeKit, allowing users to control Xiaomi devices with Siri. Of course, if we use Raspberry Pi, we don’t want to use HA system, but if we want to get a more comprehensive HA experience, we can try HAS.

First, let's look at the difference between Home Assistant Supervised and Home Assistant System and Core, refer to compare-installation-methods :
the difference

So, using Home Assistant Supervised is basically the full version of Home Assistant, of course, there are certain requirements.

During the installation of Docker and Supervised, a stable power supply is required; especially before installing Supervised, when restarting and loading new configurations, if the power supply is not up, the SSH connection is likely to be unstable.

Therefore, it is strongly recommended to use a high-wattage PD head to power the Raspberry Pi 4B (eg: 30W PD charging head).

Show results

The final effect is very simple. Home Assistant Supervised depends on Docker, so there will be these Dockers that belong to Home Assistant Supervised:
Ultimate Docker

Use IP:8123to access the web control panel: After
web panel
installing Xiaomi MIoT , you can bridge Xiaomi devices to platforms such as HomeKit:
web control panel

Bridge effect:
Bridge to HomeKit (iPhone)
Bridge to HomeKit (macOS)

In this way, you can operate Mijia devices on macOS (without downloading Mijia...), or directly operate with Siri.

Huh, now I write code in my room, and when it gets dark, I go to the living room, and finally I don’t need to use a flashlight to turn on the lights (*≧ω≦)

You can also install the Home Assistant APP on multiple devices to realize multi-device information sharing:
Multiple devices share information

Raspberry Pi verification

Now, let's start the installation process~~

First, let's successfully connect to the Raspberry Pi:
Successful remote login to Raspberry Pi

Pay attention to update the software:

sudo apt update -y
sudo apt upgrade -y

Check the Linux version of Raspberry Pi:

# 查看Linux版本
lsb_release -a

Linux version

If you want to fully support HomeAssistantSupervised, it is best to check whether the local system is satisfied according to the official HomeAssistantSupervised support system description
March 2022
: As you can see, as of the publication of the article, the official document states that Debian11 is required, and my Raspberry Pi system is satisfactory.

In fact, other systems can also be used, but Supervisedthe functions may be limited, for example: the Supervised version of Nginx or Php cannot be used. for basic functions.
However, bridging the device to Apple's HomeKit, has no effect. (When I installed it with Debian10, it was like this).

auxiliary video

Hey, it’s not easy to make tutorial videos (Station B will not recommend drainage at all), please be sure to click three consecutive times ~ Video address of Station B: https://www.bilibili.com/video/BV1Bq4y1a7Bs

NetworkManager

HomeAssistantSupervised needs the support of NetworkManager. Raspberry Pi officially uses ModemManager, openresolv and dhcpcd5.

The original configuration can be left unchanged, but the Mac address needs to be fixed and ModemManger disabled.

Because NetworkManager starts working once installed. So we first create a NetworkManager configuration file to fix the Mac address to prevent the Mac address of the Raspberry Pi from changing frequently when we restart the subsequent operations.

Fixed Mac address

Pre-written NetworkManager configuration:

# 创建配置目录和文件
sudo mkdir -p /etc/NetworkManager/conf.d/
# 对文件追加内容
sudo vim /etc/NetworkManager/conf.d/100-disable-wifi-mac-randomization.conf

Append content:

[connection]
wifi.mac-address-randomization=1

[device]
wifi.scan-rand-mac-address=no

Create configuration file

After that you can install network-manager.

Install Network-Manager

After installing Network-Manager, there may be transient packet loss on the network. Just wait a little longer at this time, and ModemManagerdo not restart the Raspberry Pi system before the complete disable! ! !

Install:

sudo apt install -y network-manager

Install network manager

Disable ModemManager

Some tutorials will allow you to uninstall dhcpcd5, but you need to reconfigure the network after restarting, and you can’t use the Raspberry Pi method to configure it, which makes me a user without a monitor very distressed... So we don’t uninstall here, just disable dhcpcd5it ModemManager.

# 停止ModemManager
sudo systemctl stop ModemManager
# 禁止ModemManager开机自启
sudo systemctl disable ModemManager

ModemManager

At this point, the NetworkManager part is ready.

Apparmor

Installing Apparmor is easy:

sudo apt install -y apparmor-utils jq software-properties-common apt-transport-https avahi-daemon ca-certificates curl dbus socat

install dependencies
However, it should be noted that the startup configuration parameters of Apparmor need to be added to the startup parameters of the Raspberry Pi (reference from: https://github.com/Kanga-Who/home-assistant/issues/25 ):

# 使用vim打开/boot/cmdline.txt
sudo vim /boot/cmdline.txt

Add at the end: apparmor=1 security=apparmor.

OS Agent

OS Agent also needs to be installed. This is not in the Debian repositories, so we need to install it using dpkg. Download address of the latest OS Agent: https://github.com/home-assistant/os-agent/releases/latest :
Raspberry Pi selects the aarch64 version

For example, I download and install 1.2.2the version of OS Agent here:

# 下载OS Agent 1.2.2
wget https://github.com/home-assistant/os-agent/releases/download/1.2.2/os-agent_1.2.2_linux_aarch64.deb
# 使用dpkg安装
sudo dpkg -i os-agent_1.2.2_linux_aarch64.deb

OS-Agent installed successfully

other dependencies

There are some other dependencies that need to be installed, refer to: https://github.com/home-assistant/supervised-installer

sudo apt-get install \
jq \
wget \
curl \
udisks2 \
libglib2.0-bin \
dbus -y

install dependencies

Docker

If you have installed Docker before, you can skip this step.

After that, download the official Docker script, and use the Ali source to install Docker:

# 下载Docker安装脚本
sudo curl -fsSL https://get.docker.com -o get-docker.sh
# 使用阿里镜像源下载并安装Docker
sudo sh get-docker.sh --mirror Aliyun

Install Docker
Docker installation complete

Add our own piusers to the docker user group:

sudo usermod -aG docker pi

Reboot the device

In the appeal operation, we have reconfigured the network, installed dependencies and added startup parameters, so Home Assisistant Supervisedwe need to restart the device before the official installation.

After restarting the device, pingcheck the device to see if a stable package can be returned:
ping detection

When restarting, some new processes will be added, and the ping response will be intermittent during the period. Wait until the return is stable before starting the SSH connection:
Stablize

It should be noted that if the device lasts for a long time and Request timeout for icmp_seqthe network is OK, the power supply of the Raspberry Pi may be insufficient. If it is not possible, a 65W PD charger can be used.

Supervised

Install

Now start the installation Home Assisistant Supervised.

Because there are tabs, please do not operate in the screen! ! !

# 下载deb安装包
wget https://github.com/home-assistant/supervised-installer/releases/latest/download/homeassistant-supervised.deb
# 安装
sudo dpkg -i homeassistant-supervised.deb

After that, the tab will appear without problems, we choose Raspberry Pi 4B:
Select Raspberry Pi 4B
Choose Raspberry Pi 4B-64

Mine is Raspberry Pi 4B, if you are Raspberry Pi 3, you should know how to operate it? Pay attention to the extra points, there is a Raspberry Pi raspberrypi4-64version.

The installation process... Depending on your network, this step may be stuck for a long time. If it still doesn't work, remember to be scientific and then reinstall:
stuck for a long time

If you have gruba configuration error, such as:
grub error
the solution is simple:

sudo vim /etc/default/grub

Add to:systemd.unified_cgroup_hierarchy=false

sudo vim /boot/cmdline.txt

Add to:systemd.unified_cgroup_hierarchy=false

Then restart the system, re-enter the system, and use the command install( sudo dpkg -i homeassistant-supervised.deb) again to install successfully:
Successful installation

If an error like this occurs during the process:
installation failed

Generally, it is a network problem. Re-execute the command install ( sudo dpkg -i homeassistant-supervised.deb) to install and try.

achievement

Use the docker command to view the status of the supervised container:
Docker is normal

Enter IP:4357, you can view Supervisedthe status:
normal status

IP:8123However, you cannot enter the Home Assistant Supervised management page at this time , you need to restart the server once:

# 重启服务器
sudo reboot

After restarting, wait for about 5 minutes (the first startup of Home Assistant Supervised is relatively slow), and then you can IP:8123access it in the browser:
successful access

normal status

configuration file

find the configuration file

In addition, to install some plug-ins (such as the famous xiaomi_miot_raw , you need to edit the configuration file of Home Assistant yourself.

However, the official does not seem to say where this configuration file is. Actually /usr/share/hassio/homeassistantinside :
configuration file

If subsequent versions are updated, not here. You can findsearch with the command:

sudo find / -name "homeassistant"

Find configuration files

How to reverse generation of Nginx

In addition, if there is a need for Nginx Https reverse generation, Nginx needs to support the reverse generation of websocket services; refer to the configuration:

location / {
    
    
    proxy_pass  http://127.0.0.1:8123;
    proxy_set_header Host $host;
    proxy_http_version 1.1;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

END

At this point, the Raspberry Pi installation Home Assisistant Supervisedis over. Anyone else wondering how to bridge Xiaomi devices to Apple HomeKit?

This... Next time I have a chance to talk to you, and then I will talk about Nginx's anti-generation and FRP mapping in detail, so that we can remotely access Home Assistant.

Guess you like

Origin blog.csdn.net/weixin_43890033/article/details/124204909
Recommended