【笔记】玩客云部署Homeassistant

前言

玩客云部署Homeassistant

玩客云刷入Armbian

传送门

配置Armbian环境

设置时区

1
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

更换软件源(可选)

清华大学软件源

/etc/apt/sources.list
1
2
3
4
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-security main restricted universe multiverse

更新软件列表

1
apt update

安装依赖

1
apt install -y  python3-dev  python3-venv python3-pip libffi-dev libssl-dev libjpeg-dev zlib1g-dev autoconf build-essential libopenjp2-7 libtiff5 libturbojpeg0-dev libpcap-dev tzdata

部署Rust

安装Rust

1
curl https://sh.rustup.rs -sSf | sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
info: downloading installer

Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

/home/ha/.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory is located at:

/home/ha/.cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

/home/ha/.cargo/bin

This path will then be added to your PATH environment variable by
modifying the profile files located at:

/home/ha/.profile
/home/ha/.bashrc
/home/ha/.zshenv

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


default host triple: armv7-unknown-linux-gnueabihf
default toolchain: stable (default)
profile: default
modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1

配置Rust环境

1
2
3
source $HOME/.cargo/env
export CRYPTOGRAPHY_DONT_BUILD_RUST=1
export CARGO_NET_GIT_FETCH_WITH_CLI=true

部署Python

查看Python版本号

  • 确保Python版本为3.10.6
1
python3 -V

设置pip源(可选)

清华大学软件源

1
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

创建pip虚拟环境

1
2
python3 -m venv homeassistant-pip-env
source homeassistant-pip-env/bin/activate

下载Homeassistant

1
python3 -m pip install wheel homeassistant

首次启动

  • 首次启动会很慢,需要耐心等待
1
hass

配置开机自启

创建配置文件

1
touch /etc/systemd/system/homeassistant.service
/etc/systemd/system/homeassistant.service
1
2
3
4
5
6
7
8
9
10
11
12
13
[Unit]
Description=Home Assistant
After=network-online.target

[Service]
Type=simple
User=ha
WorkingDirectory=/home/ha/.homeassistant
ExecStart=/home/ha/homeassistant-pip-env/bin/hass -c /home/ha/.homeassistant
RestartForceExitStatus=100

[Install]
WantedBy=multi-user.target

设置为开机自启

1
systemctl enable homeassistant

完成

参考文献

知乎——赵东颖