12

Home Assistant (Supervisor) 安装

 1 year ago
source link: https://zgh551.github.io/2022/12/26/Home-Assistant-Supervised-%E5%AE%89%E8%A3%85/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Home Assistant (Supervisor) 安装

2022-12-26 2023-01-02Home Assistant

8

本文讲述 Home Assistant Supervisor 的安装步骤,虽然官方有详细的安装指导,但是由于软件源大都在国外,某些步骤可能需要科学上网才能解决。本文实际部署的硬件平台是 Raspberry Pi 3 Model,请参考 树莓派系统安装 做好硬件和软件环境的准备。

eca88d886cc33e9a.jpg

参考官方说明文档 Operating System 获取目前支持的系统信息,可知,目前 Home Assistant Supervisor 支持的操作系统类型是 Debian 11 (Bullseye),参考 树莓派系统安装 完成系统的准备工作。

Apparmor 配置

默认树莓派最新的发布版本是安装了 apparmor 工具的,Supervisor 要求系统开机时激活 apparmor 服务,需要在 /boot/cmdline.txt 文件中,追加 apparmor=1 security=apparmor 内容。详细参考 how to enable apparmor 内容。

cgroup 配置

打开 /etc/default/grub 文件,如果不存该文件则创建,并在文件中写入 systemd.unified_cgroup_hierarchy=false 内容。

打开 /boot/cmdline.txt 文件,并追加 systemd.unified_cgroup_hierarchy=false 内容。

NetworkManager 配置

由于 Home Assistant Supervisor 需要 NetworkManager 的支持,而树莓派官方系统默认采用 dhcpcd 网络配置工具。所以需要通过 raspi-config 工具切换网络配置工具。

通过如下命令,打开树莓派配置工具

$ sudo raspi-config

如下图所示,选择 Advanced Options :

进入后,选择 Network Config :

最后将网络配置器切换到 NetworkManager,按下回车键 Enter 保存配置,此时需要会提示是否 reboot , 请选择 yes,重启树莓派。

Supervisor 安装步骤

依赖软件安装

首先更新系统软件源:

sudo apt-get update --fix-missing
sudo apt-get upgrade -y

然后通过如下命令安装依赖软件:

sudo apt-get install \
apparmor \
jq \
wget \
curl \
udisks2 \
libglib2.0-bin \
network-manager \
dbus \
lsb-release \
systemd-journal-remote -y

Docker-CE 安装

下载安装脚本,命令如下:

curl -fsSL get.docker.com -o get-docker.sh

国内用户建议通过阿里镜像源进行安装:

sh get-docker.sh --mirror Aliyun

将当前用户添加进 dockert 组中:

sudo usermod -aG docker $USER

需要重启才能生效。

OS-Agent 安装

由于 Supervisor 依赖 OS-Agent 软件包,但该软件不在 Debian 官方软件源内,需要前往 Github 仓库 os-agent 下载。

通过如下指令查看芯片架构类型:

uname -m

如果输出 aarch64 ,则下载 os-agent_1.4.1_linux_aarch64.deb 软件包。

wget -c https://github.com/home-assistant/os-agent/releases/download/1.4.1/os-agent_1.4.1_linux_aarch64.deb

如果网络无法正常下载,可以尝试添加代理,例如如下代理服务:

wget -c https://ghproxy.com/https://github.com/home-assistant/os-agent/releases/download/1.4.1/os-agent_1.4.1_linux_aarch64.deb

然后使用 dpkg 命令安装:

sudo dpkg -i os-agent_1.4.1_linux_aarch64.deb

判断是否安装成功

gdbus introspect --system --dest io.hass.os --object-path /io/hass/os

上述命令如果不输出错误信息,而是输出包含 interface 字段的信息则说明安装成功,树莓派安装后输出如下:

node /io/hass/os {
interface org.freedesktop.DBus.Introspectable {
methods:
Introspect(out s out);
signals:
properties:
};
interface org.freedesktop.DBus.Properties {
methods:
Get(in s interface,
in s property,
out v value);
GetAll(in s interface,
out a{sv} props);
Set(in s interface,
in s property,
in v value);
signals:
PropertiesChanged(s interface,
a{sv} changed_properties,
as invalidates_properties);
properties:
};
interface io.hass.os {
methods:
signals:
properties:
@org.freedesktop.DBus.Property.EmitsChangedSignal("invalidates")
readonly s Version = '1.4.1';
@org.freedesktop.DBus.Property.EmitsChangedSignal("true")
readwrite b Diagnostics = false;
};
};

Supervisor 安装

前往 Releases · home-assistant/supervised-installer · GitHub 下载与 OS-Agent 版本匹配的 Debian 包。

wget -c https://github.com/home-assistant/supervised-installer/releases/download/1.4.1/homeassistant-supervised.deb

如果网络无法下载,可以尝试如下代理:

wget -c https://ghproxy.com/https://github.com/home-assistant/supervised-installer/releases/download/1.4.1/homeassistant-supervised.deb

执行安装命令:

sudo dpkg -i homeassistant-supervised.deb

安装过程中会弹出配置窗口,根据实际硬件和系统位宽选择对应的即可。

[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.2.144:8123

安装成功后,需要等待一段时间,时间长短由实际网络情况决定。如果想确认系统是否在运行相关安装操作,可查看系统进程,如果出现下图中的进程,则说明正在下载相关的 docker 镜像。

通过如下指令可以查看 docker 镜像的下载情况:

docker images | grep ghcr.io/home-assistant

如下镜像列表,说明 Supervisor 需求的所有基础镜像都下载完成。

ghcr.io/home-assistant/raspberrypi3-64-homeassistant   2022.12.8   bdb17d6196f1   10 days ago     1.42GB
ghcr.io/home-assistant/aarch64-hassio-supervisor latest 274d5e89d465 12 days ago 314MB
ghcr.io/home-assistant/aarch64-hassio-cli 2022.11.0 a3ff4e00a9a0 8 weeks ago 116MB
ghcr.io/home-assistant/aarch64-hassio-audio 2022.07.0 c4435f74fa3c 5 months ago 152MB
ghcr.io/home-assistant/aarch64-hassio-dns 2022.04.1 362b749494ab 8 months ago 96.7MB
ghcr.io/home-assistant/aarch64-hassio-multicast 2022.02.0 3ce91958464c 10 months ago 81.5MB
ghcr.io/home-assistant/aarch64-hassio-observer 2021.10.0 9c3593efc7e1 14 months ago 89.2MB

另外可以使用如下命令查看相关容器是否创建成功:

docker ps
CONTAINER ID   IMAGE                                                            COMMAND   CREATED        STATUS        PORTS                                   NAMES
8a35d1671da0 ghcr.io/home-assistant/aarch64-hassio-multicast:2022.02.0 "/init" 21 hours ago Up 21 hours hassio_multicast
fe5d313af4a6 ghcr.io/home-assistant/aarch64-hassio-audio:2022.07.0 "/init" 21 hours ago Up 21 hours hassio_audio
af22688c8288 ghcr.io/home-assistant/aarch64-hassio-dns:2022.04.1 "/init" 21 hours ago Up 21 hours hassio_dns
b5255dbcb17d ghcr.io/home-assistant/aarch64-hassio-cli:2022.11.0 "/init" 21 hours ago Up 21 hours hassio_cli
7acff09641e5 ghcr.io/home-assistant/aarch64-hassio-observer:2021.10.0 "/init" 6 days ago Up 21 hours 0.0.0.0:4357->80/tcp, :::4357->80/tcp hassio_observer
cb3b24d10901 ghcr.io/home-assistant/raspberrypi3-64-homeassistant:2022.12.8 "/init" 7 days ago Up 21 hours homeassistant
7e49186c9adf ghcr.io/home-assistant/aarch64-hassio-supervisor:latest "/init" 7 days ago Up 21 hours hassio_supervisor

进一步访问 IP:4357 端口,确认 Supervisor 工作状态是否正常。

最后通过访问 IP:8123 端口,进行 Home Assisistant 的相关配置,如下图所示,需要等待一段时间,等待系统启动完成,然后创建账户配置基本选项。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK