最終結(jié)論婴氮,2021年10月os-agent更新以后博助,樹莓派OS已經(jīng)退出了支持列表。
目前的版本不建議安裝Supervised版本蒸痹。
參考了官網(wǎng)指南和網(wǎng)絡(luò)經(jīng)驗(yàn)https://github.com/home-assistant/supervised-installer
更新系統(tǒng)源至清華源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak #備份源文件
sudo nano /etc/apt/sources.list #編輯源列表
清空文件后僻爽,填入以下內(nèi)容虫碉,系統(tǒng)版本為最新樹莓派系統(tǒng)(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確認(rèn) Ctrl+X退出
更換系統(tǒng)源至國內(nèi)清華源
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
替換成以下內(nèi)容
deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bullseye main
編輯Python-pip來源列表
sudo nano /etc/pip.conf #編輯PIP來源列表
清空文件后,填入以下內(nèi)容:
[global]
extra-index-url=https://www.piwheels.org/simple
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
Ctrl+O 寫入 Enter確認(rèn) Ctrl+X退出
升級系統(tǒng)渠道源
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
從最后一行加入以下內(nèi)容
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確認(rèn) 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
因?yàn)闃漭?默認(rèn)情況下每次重啟會產(chǎn)生隨機(jī)mac地址
所以需要關(guān)閉mac地址隨機(jī)
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服務(wù)敦捧,因?yàn)榘凑誋omeassitant的官方說法,可能會影響外圍設(shè)備的通訊碰镜。
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組
設(shè)置docker的日志驅(qū)動兢卵,以及鏡像的國內(nèi)下載點(diǎn)(參考),結(jié)論:(這幾個(gè)加速鏡像幾乎沒有特別好用的绪颖,設(shè)置了反而可能會造成大量的1.1.1.1和1.0.0.1的DNS訪問請求秽荤,造成局域網(wǎng)速度降速铺根,建議省略它)
這一步的主要作用:daemon.json文件可以對docker容器的啟動參數(shù)進(jìn)行設(shè)定边器,請具體搜索其他教程。
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 #檢查是否安裝成功
一定記得給樹莓派有線網(wǎng)卡設(shè)置固定IP
否則會出現(xiàn)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
包安裝完成后會讓你選擇系統(tǒng)版本
generic-x86-64
odroid-c2
odroid-n2
odroid-xu
qemuarm
qemuarm-64
qemux86
qemux86-64
raspberrypi
raspberrypi2
raspberrypi3
raspberrypi4
raspberrypi3-64
raspberrypi4-64 #我們選這個(gè)
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
查看正在運(yùn)行的Docker容器數(shù)量和名稱
docker ps -a
docker ps [OPTIONS]
OPTIONS說明:
-a :顯示所有的容器牍氛,包括未運(yùn)行的晨继。
-f :根據(jù)條件過濾顯示的內(nèi)容。
–format :指定返回值的模板文件搬俊。
-l :顯示最近創(chuàng)建的容器紊扬。
-n :列出最近創(chuàng)建的n個(gè)容器。
–no-trunc :不截?cái)噍敵觥?-q :靜默模式唉擂,只顯示容器編號珠月。
-s :顯示總的文件大小
接下來安裝HACS
第一步添加SSH的Add-ons,完成設(shè)置楔敌。
第二步更改Hosts文件,注釋github的hosts驻谆。
第三步打開SSH的Add-ons卵凑,輸入以下命令:
wget -O - https://get.hacs.xyz | bash -
CTRL+SHIFT+V
第四步清理瀏覽器緩存,重新打開瀏覽器:
第五步打開-》homeassistant-》設(shè)置-》集成-》右下角添加集成-》搜索HACS胜臊,完成設(shè)置勺卢,設(shè)置參考下述步驟: