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 :
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:
Use IP:8123
to access the web control panel: After
installing Xiaomi MIoT , you can bridge Xiaomi devices to platforms such as HomeKit:
Bridge effect:
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:
Raspberry Pi verification
Now, let's start the installation process~~
First, let's successfully connect to the 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
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
: 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
Supervised
the 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
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
ModemManager
do not restart the Raspberry Pi system before the complete disable! ! !
Install:
sudo apt install -y 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 dhcpcd5
it ModemManager
.
# 停止ModemManager
sudo systemctl stop ModemManager
# 禁止ModemManager开机自启
sudo systemctl disable 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
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 :
For example, I download and install 1.2.2
the 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
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
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
Add our own pi
users 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 Supervised
we need to restart the device before the official installation.
After restarting the device, ping
check the device to see if a stable package can be returned:
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:
It should be noted that if the device lasts for a long time and
Request timeout for icmp_seq
the 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:
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-64
version.
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:
If you have grub
a configuration error, such as:
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:
If an error like this occurs during the process:
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:
Enter IP:4357
, you can view Supervised
the status:
IP:8123
However, 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:8123
access it in the browser:
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/homeassistant
inside :
If subsequent versions are updated, not here. You can find
search with the command:
sudo find / -name "homeassistant"
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 Supervised
is 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.