Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | 51CTO学院 | CSDN程序员研修院 | OSChina 博客 | 腾讯云社区 | 阿里云栖社区 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏多维度架构

第 189 章 Home Assistant

目录

189.1. 安装 Home Assistant
189.1.1. Docker 安装
189.1.2. Debian
189.1.3. Ubuntu
189.1.4. 升级
189.2. 配置文件
189.3. Home Assistant Community Store
189.3.1. 正常安装
189.3.2. 遇到 Github 无法访问的情况怎么处理
189.3.3. 手工安装
189.3.4. Node-Red
189.3.5. Xiaomi Miot Auto
189.4. ha 命令
189.4.1. 检查版本
189.4.2. network
189.4.3. 修改 DNS
189.4.4. supervisor 管理
189.4.5. core
189.4.6. jobs
189.5. FAQ
189.5.1. Media change: please insert the disc labeled

Home Assistant 建议安装在 Debian 系的 Linux 中

189.1. 安装 Home Assistant

189.1.1. Docker 安装

安装 Docker

  			 
mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null

apt update -y
apt install -y curl gnupg2 
apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
  			
			

189.1.2. Debian

安装依赖包

  			 
apt update
apt install udisks2
  			
			

Agent for Home Assistant OS

  			 
wget https://github.com/home-assistant/os-agent/releases/latest/download/os-agent_1.5.1_linux_x86_64.deb
apt install ./os-agent_1.5.1_linux_x86_64.deb
systemctl status haos-agent

https://github.com/home-assistant/os-agent/releases/tag/1.5.1
  			
			

			 
wget https://github.com/home-assistant/supervised-installer/releases/download/1.4.3/homeassistant-supervised.deb
dpkg -i homeassistant-supervised.deb

wget https://github.com/home-assistant/supervised-installer/releases/latest/download/homeassistant-supervised.deb
apt install ./homeassistant-supervised.deb
			
			
	
sudo docker run --restart always -d --name homeassistant \
-v /PATH_TO_YOUR_CONFIG:/config \
--device=/PATH_TO_YOUR_USB_STICK \
-e TZ=Australia/Melbourne --net=host \
ghcr.io/home-assistant/home-assistant:stable

sudo dpkg -i https://github.com/home-assistant/supervised-installer/releases/download/1.4.3/homeassistant-supervised.deb

sudo docker run --restart always -d --name homeassistant \
--restart=unless-stopped \
-v /srv/homeassistant:/config \
-p 8123:8123 -p 4357:4357 \
-e TZ=Asia/Shanghai --net=host \
ghcr.io/home-assistant/home-assistant:stable
	
			

重启 debian

  			 
reboot
			
			

 			
version: '3'
  services:
	homeassistant:
	  container_name: homeassistant
	  image: "ghcr.io/home-assistant/home-assistant:stable"
	  volumes:
		- /PATH_TO_YOUR_CONFIG:/config
		- /etc/localtime:/etc/localtime:ro
	  restart: unless-stopped
	  privileged: true
	  network_mode: host  
			
			

189.1.3. Ubuntu

			 

wget https://github.com/home-assistant/os-agent/releases/latest/download/os-agent.deb
apt install ./homeassistant-supervised.deb

wget https://github.com/home-assistant/os-agent/releases/latest/download/os-agent_1.5.1_linux_x86_64.deb
apt install ./os-agent_1.5.1_linux_x86_64.deb

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -  
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"  
apt install docker-ce

wget https://github.com/home-assistant/supervised-installer/releases/latest/download/homeassistant-supervised.deb
apt install ./homeassistant-supervised.deb
			
			

189.1.4. 升级

			
root@homeassistant:~# apt list --installed | grep homeassistant-supervised

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

homeassistant-supervised/now 1.4.2 all [installed,local]			
			
			

前往 https://github.com/home-assistant/supervised-installer/releases 找到需要升级的版本

			
root@homeassistant:~# wget https://github.com/home-assistant/supervised-installer/releases/download/1.5.0/homeassistant-supervised.deb			
			
			

使用下面命令更新

			
dpkg -i --ignore-depends=systemd-resolved ./homeassistant-supervised.deb
			
			

更新过程演示

			
root@homeassistant:~# dpkg -i --ignore-depends=systemd-resolved ./homeassistant-supervised.deb
(Reading database ... 35672 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.5.0) over (1.4.2) ...
Setting up homeassistant-supervised (1.5.0) ...
[info] Restarting NetworkManager
[info] Restarting docker service


PING checkonline.home-assistant.io (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.391 ms

--- checkonline.home-assistant.io ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.391/0.391/0.391/0.000 ms
[info] Install supervisor startup scripts
[info] Install AppArmor scripts
[info] Start Home Assistant Supervised
[info] Installing the 'ha' cli
[warn] Could not find /etc/default/grub or /boot/firmware/cmdline.txt failed to switch to cgroup v1
[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://10.10.0.10:8123