最终结论,2021年10月os-agent更新以后,树莓派OS已经退出了支持列表。
目前的版本不建议安装Supervised版本。
参考了官网指南和网络经验https://github.com/home-assistant/supervised-installer
更新系统源至清华源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak #备份源文件
sudo nano /etc/apt/sources.list #编辑源列表
清空文件后,填入以下内容,系统版本为最新树莓派系统(Raspberry Pi4 64bit Bullseye)
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
Ctrl+O 写入 Enter确认 Ctrl+X退出
更换系统源至国内清华源
sudo cp /etc/apt/sources.list.d/raspi.list /etc/apt/sources.list.d/raspi.list.bak
sudo nano /etc/apt/sources.list.d/raspi.list
替换成以下内容
deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bullseye main
编辑Python-pip来源列表
sudo nano /etc/pip.conf #编辑PIP来源列表
清空文件后,填入以下内容:
[global]
extra-index-url=https://www.piwheels.org/simple
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
Ctrl+O 写入 Enter确认 Ctrl+X退出
升级系统渠道源
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
安装爬虫常用包
sudo pip install selenium
sudo pip install pillow
sudo pip install opencv-python
sudo pip install onnxruntime
sudo apt-get install chromium-chromedriver
更换GitHub Hosts,加速操作
sudo nano /etc/hosts
从最后一行加入以下内容
185.199.108.154 github.githubassets.com
140.82.112.21 central.github.com
185.199.108.133 desktop.githubusercontent.com
185.199.108.153 assets-cdn.github.com
185.199.108.133 camo.githubusercontent.com
185.199.108.133 github.map.fastly.net
199.232.69.194 github.global.ssl.fastly.net
140.82.114.4 gist.github.com
185.199.108.153 github.io
140.82.113.4 github.com
140.82.113.6 api.github.com
185.199.108.133 raw.githubusercontent.com
185.199.108.133 user-images.githubusercontent.com
185.199.108.133 favicons.githubusercontent.com
185.199.108.133 avatars5.githubusercontent.com
185.199.108.133 avatars4.githubusercontent.com
185.199.108.133 avatars3.githubusercontent.com
185.199.108.133 avatars2.githubusercontent.com
185.199.108.133 avatars1.githubusercontent.com
185.199.108.133 avatars0.githubusercontent.com
185.199.108.133 avatars.githubusercontent.com
140.82.113.9 codeload.github.com
52.217.199.121 github-cloud.s3.amazonaws.com
52.217.229.65 github-com.s3.amazonaws.com
52.217.96.28 github-production-release-asset-2e65be.s3.amazonaws.com
52.217.77.92 github-production-user-asset-6210df.s3.amazonaws.com
52.217.172.9 github-production-repository-file-5c1aeb.s3.amazonaws.com
185.199.108.153 githubstatus.com
64.71.144.202 github.community
185.199.108.133 media.githubusercontent.com
Ctrl+O 写入 Enter确认 Ctrl+X退出
安装Home Assistant
GitHub - home-assistant/supervised-installer: Installer for a generic Linux system
安装各种依赖包(必须安装)
sudo apt-get install \
jq \
wget \
curl \
udisks2 \
libglib2.0-bin \
network-manager \
apparmor \
dbus -y
因为树莓派4默认情况下每次重启会产生随机mac地址
所以需要关闭mac地址随机
sudo mkdir -p /etc/NetworkManager/conf.d/
cat << EOF | sudo tee /etc/NetworkManager/conf.d/100-disable-wifi-mac-randomization.conf
[connection]
wifi.mac-address-randomization=1
[device]
wifi.scan-rand-mac-address=no
EOF
安装Docker之前,要禁用ModemManager服务,因为按照Homeassitant的官方说法,可能会影响外围设备的通讯。
sudo systemctl stop ModemManager
sudo systemctl disable ModemManager
安装Docker(必须安装)
sudo curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh --mirror Aliyun #使用阿里云镜像安装
sudo rm get-docker.sh
sudo usermod -aG docker pi #将pi用户加入docker组
设置docker的日志驱动,以及镜像的国内下载点(参考),结论:(这几个加速镜像几乎没有特别好用的,设置了反而可能会造成大量的1.1.1.1和1.0.0.1的DNS访问请求,造成局域网速度降速,建议省略它)
这一步的主要作用:daemon.json文件可以对docker容器的启动参数进行设定,请具体搜索其他教程。
if [ ! -d /etc/docker ];then
sudo mkdir -p /etc/docker
fi
cat << EOF | sudo tee /etc/docker/daemon.json
{
"log-driver": "journald",
"registry-mirrors": [
"https://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn"
]
}
EOF
重启Docker
sudo systemctl daemon-reload
sudo systemctl restart docker
下载&安装OS-Agent包
sudo wget https://github.com/home-assistant/os-agent/releases/download/1.2.2/os-agent_1.2.2_linux_aarch64.deb #下载os-agent
sudo dpkg -i os-agent_1.2.2_linux_aarch64.deb #安装os-agent
sudo rm os-agent_1.2.2_linux_aarch64.deb
gdbus introspect --system --dest io.hass.os --object-path /io/hass/os #检查是否安装成功
一定记得给树莓派有线网卡设置固定IP
否则会出现eth0 does not exsist
sudo wget https://github.com/home-assistant/supervised-installer/releases/download/1.1.0/homeassistant-supervised.deb
sudo dpkg -i homeassistant-supervised.deb
包安装完成后会让你选择系统版本
generic-x86-64
odroid-c2
odroid-n2
odroid-xu
qemuarm
qemuarm-64
qemux86
qemux86-64
raspberrypi
raspberrypi2
raspberrypi3
raspberrypi4
raspberrypi3-64
raspberrypi4-64 #我们选这个
tinker
khadas-vim3
安装正常的话,有如下提示:
sudo dpkg -i homeassistant-supervised.deb
(Reading database ... 92648 files and directories currently installed.)
Preparing to unpack homeassistant-supervised.deb ...
[warn]
[warn] If you want more control over your own system, run
[warn] Home Assistant as a VM or run Home Assistant Core
[warn] via a Docker container.
[warn]
Leaving 'diversion of /etc/NetworkManager/NetworkManager.conf to /etc/NetworkManager/NetworkManager.conf.real by homeassistant-supervised'
Leaving 'diversion of /etc/NetworkManager/system-connections/default to /etc/NetworkManager/system-connections/default.real by homeassistant-supervised'
Leaving 'diversion of /etc/docker/daemon.json to /etc/docker/daemon.json.real by homeassistant-supervised'
Leaving 'diversion of /etc/network/interfaces to /etc/network/interfaces.real by homeassistant-supervised'
Unpacking homeassistant-supervised (1.1.0) over (1.1.0) ...
Setting up homeassistant-supervised (1.1.0) ...
[info] Restarting NetworkManager
[info] Restarting docker service
PING version.home-assistant.io (104.26.4.238) 56(84) bytes of data.
64 bytes from 104.26.4.238 (104.26.4.238): icmp_seq=1 ttl=50 time=252 ms
--- version.home-assistant.io ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 251.624/251.624/251.624/0.000 ms
[info] Install supervisor Docker container
[info] Install supervisor startup scripts
[info] Install AppArmor scripts
[info] Start Home Assistant Supervised
[info] Installing the 'ha' cli
[info] Within a few minutes you will be able to reach Home Assistant at:
[info] http://homeassistant.local:8123 or using the IP address of your
[info] machine: http://192.168.***.***:8123
查看安装日志:
journalctl -f
查看正在运行的Docker容器数量和名称
docker ps -a
docker ps [OPTIONS]
OPTIONS说明:
-a :显示所有的容器,包括未运行的。
-f :根据条件过滤显示的内容。
–format :指定返回值的模板文件。
-l :显示最近创建的容器。
-n :列出最近创建的n个容器。
–no-trunc :不截断输出。
-q :静默模式,只显示容器编号。
-s :显示总的文件大小
接下来安装HACS
第一步添加SSH的Add-ons,完成设置。
第二步更改Hosts文件,注释github的hosts。
第三步打开SSH的Add-ons,输入以下命令:
wget -O - https://get.hacs.xyz | bash -
CTRL+SHIFT+V
第四步清理浏览器缓存,重新打开浏览器:
第五步打开-》homeassistant-》设置-》集成-》右下角添加集成-》搜索HACS,完成设置,设置参考下述步骤: