我的上一篇文章【在嵌入式x86上构建我的智能家居(home assistant)】中本来希望在一个低功耗的x86嵌入式上安装home assistant,但是因为一些限制没有成功。
找到一个低功耗的笔记本(东芝的dynabook SS RX2,cpu:U9400 1.4G ram:2G SSD:128G),拆了光驱,简单测试大概10W功耗,比之前的高好多,但也还不错了。就用他了,安装home assistant。
第一步安装debian11. 我使用的是网络版镜像文件debian-11.3.0-amd64-netinst.iso,安装时使用的中文并多选择了ssh server,这样安装完成后就可以直接ssh登录了。
使用debian11是为了安装home assistant Supervised版。根据官网需求列表中说明,安装此版本需要debian11.
第一步安装debian12. 我使用的是网络版镜像文件debian-12.4.0-amd64-netinst.iso,安装时使用的中文并多选择了ssh server,这样安装完成后就可以直接ssh登录了。
使用debian12是为了安装home assistant Supervised版。根据官网需求列表中说明,安装此版本需要debian12.
参考:
architecture/0014-home-assistant-supervised.md at master · home-assistant/architecture · GitHubRepo to discuss Home Assistant architecture. Contribute to home-assistant/architecture development by creating an account on GitHub.https://github.com/home-assistant/architecture/blob/master/adr/0014-home-assistant-supervised.md
GitHub - home-assistant/supervised-installer: Installer for a generic Linux systemInstaller for a generic Linux system. Contribute to home-assistant/supervised-installer development by creating an account on GitHub.https://github.com/home-assistant/supervised-installer
系统安装完成后,不需要x环境,而且可以节省资源。变更登录环境
su -
systemctl set-default multi-user.targetsudo update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.11
或者
sudo apt install python-is-python3 #(推荐)
根据安装指导(home-assistant/supervised-installer ),进入root用户(su - 或 sudo -s)
1.安装需要的依赖命令(从官网网页上直接复制的命令在putty中粘贴好像有问题。)apt-get install jq wget curl udisks2 libglib2.0-bin network-manager dbus -y
apt install apparmor cifs-utils curl dbus jq libglib2.0-bin lsb-release network-manager nfs-common systemd-journal-remote systemd-resolved udisks2 wget -y
可能需要修正dns问题
参考DNS设置为systemd的127.0.0.53 – 如何永久更改? Ubuntu 中文网
在 /etc/systemd/resolved.conf 里设置了 DNSStubListener=no 解放了 53 端口。
systemd-resolved 的工作模式是怎样的?本地建了 adguard home 还有必要开着 resolved 吗?_技术解析_文章_数据地带
使用nmtui设置网卡ip和dns
jq: json解释器
udisk2 :u盘自动装载,重命名 库。
2.安装docker curl -fsSL get.docker.com | sh
3.安装OS-Agent
安装系统代理的说明可以在下面连接找到
GitHub - home-assistant/os-agent: Daemon allowing to control OS features through D-Bus
Using Home Assistant Supervised on Debian
Download the latest Debian package from OS Agent GitHub release page at:
https://github.com/home-assistant/os-agent/releases/latest
打开以上网址,查找最新的deb包,(有可能打不开,需要另想办法 v_v),下载
wget https://github.com/home-assistant/os-agent/releases/download/1.2.2/os-agent_1.2.2_linux_x86_64.deb
wget https://github.com/home-assistant/os-agent/releases/download/1.6.0/os-agent_1.6.0_linux_x86_64.deb
Next, install (or update) the downloaded Debian package using:
sudo dpkg -i os-agent_1.2.2_linux_x86_64.debsudo dpkg -i os-agent_1.6.0_linux_x86_64.deb
Note: Replace the deb
file in the above example with the file you have downloaded from the releases page.
You can test if the installation was successful by running:
运行以下命令,没返回错误就表示正常
gdbus introspect --system --dest io.hass.os --object-path /io/hass/os
This should not return an error. If you get an object introspection with interface
etc. OS Agent is working as expected.
You might need to install libglib2.0-bin
to get the gdbus
command.
Uninstall
To remove OS Agent from your system use the Debian packaging system:
sudo dpkg -r os-agent
4.安装Home Assisistant Supervised Debian 包
wget https://github.com/home-assistant/supervised-installer/releases/latest/download/homeassistant-supervised.deb
sudo dpkg -i homeassistant-supervised.deb
sudo apt install ./homeassistant-supervised.deb
如果出现以下错误
[warn] A reboot is required to apply changes to grub.
N: Download is performed unsandboxed as root as file '/root/homeassistant-supervised.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
执行以下命令
sudo cp homeassistant-supervised.deb /mnt
sudo chmod 777 /mnt/homeassistant-supervised.deb
然后再重新执行sudo apt reinstall /mnt/homeassistant-supervised.deb
sudo reboot
重启系统
执行完成后,home assistant Supervised安装完成。(需要等待很长时间去拉取docker的镜像, 最好有代理可以访问网站)
ps aux命令中有docker pull ......home-assistant.....
更可能根本下载不了.
使用以下命令试试
#sudo docker pull ghcr.nju.edu.cn/home-assistant/home-assistant:stable
修改/etc/hassio.json文件中的ghcr.io/home-assistant为ghcr.nju.edu.cn/home-assistant
kill掉进程中的docker pull ghcr.io/home-assistant
安装并启动后,就可以继续。
我没有代理,也没改地址,只是放到第二天,用下面的命令查看8123端口是否存在了,一般情况下,存在的话就可以了.
查ha 是否运行 ss -anopt|grep 8123
浏览器访问http://机器ip:8123 提示以下内容(8123是默认端口),意思是请等待准备中
使用ps查看有很多后台git相关进程。
。。。。。 20分钟后
网页显示如下
按照页面要求填写相关资料(填写资料输入法会飞,可以使用复制粘贴方法),
然后next。
到这个页面的时候完成。
安装完成。
完成后有以下问题:
重启系统后,这个问题提示消失了.
--------------
如果有新版本的话,会在配置项的最上面出现提示。
启动homeassistant
docker restart homeassistant