• (一)NanoPi m4v2 安装 Home Assistant(含 supervisor)


    一、环境

    硬件:NanoPi m4v2。。。
    系统:Armbian。。。(基于 Debian 11)

    二、尝试的方法

    • 开始直接在 docker 中拉取镜像安装,但是安装完成后,发现没有 supervisor,没法集成米家的设备;

    • 直接安装 hass os 比较方便省事,直接从官网下载对应版本的镜像安装即可。但是shell没办法开启 ssh;

    • 所以最终是通过 supervised 方式安装,这种本质上也是安装在 docker 中,但是根据官网的指引可以达到直接安装 hass os 的效果,而且还可以安装自己的一些其他 docker 容器。

      ps:在 Home Assistant 官网查看各种安装方式 https://www.home-assistant.io/installation/
      官方各种安装方法对比图

    三、安装过程

    进入 Home Assistant 官网安装页面 https://www.home-assistant.io/installation/,点击进入 Linux 选项卡
    Linux方式

    划到页面最下方,找到 Install Home Assistant Supervised 安装方式
    在这里插入图片描述

    点击 requirements 查看以此方式安装的要求:

    • Docker CE >= 19.03
    • Systemd >= 239
    • NetworkManager >= 1.14.6
    • AppArmor == 2.13.x (built into the kernel)
    • Debian Linux Debian 11 aka Bullseye (no derivatives)
    • Home Assistant OS-Agent (Only the latest release is supported)

    点击 home-assistant/supervised-installer 按照指引开始正式的安装步骤:

    注意:后续安装命令请用 root 用户或具有 root 权限的用户 sudo 操作

    1. 安装基础环境

    apt-get install \
    jq \
    wget \
    curl \
    udisks2 \
    libglib2.0-bin \
    network-manager \
    dbus -y
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    2. 安装 Docker-CE

    curl -fsSL get.docker.com | sh
    
    • 1

    建议使用上方命令安装 Docker-CE,如果使用其他方式安装 Docker 后,安装 supervised 时报错:

    The following packages have unmet dependencies:
     homeassistant-supervised : Depends: docker-ce but it is not installable
    E: Unable to correct problems, you have held broken packages.
    
    • 1
    • 2
    • 3

    那么检查一下安装的 Docker 是否是 CE 版本或版本号>= 19.03,使用 docker version 命令查看版本信息,如下:

    Client: Docker Engine - Community
     Version:           20.10.5
    ...
    
    Server: Docker Engine - Community
     Engine:
      Version:          20.10.5
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    3. 下载 OS-Agent

    根据自己的设备架构下载最新版本OS-Agent安装包,我的是 aarch64,所以选择 os-agent_1.2.2_linux_aarch64.deb 下载即可。PS:不知道自己的架构可以输入命令 arch 查看

    4. 安装 OS-Agent

    按照官方指引安装:

    sudo dpkg -i os-agent_1.2.2_linux_aarch64.deb
    
    • 1

    如果提示报错:

    zsh: command not found: dkpg
    
    • 1

    可以用以下命令替代:

    apt install ./os-agent_1.2.2_linux_aarch64.deb
    
    • 1

    安装完成后,使用以下命令测试:

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

    返回结果不报错、包含接口信息等即为正常。

    5. 安装 Home Assisistant Supervised Debian Package

    官方给出的命令:

    # 下载安装包
    wget https://github.com/home-assistant/supervised-installer/releases/latest/download/homeassistant-supervised.deb
    # 安装
    dpkg -i homeassistant-supervised.deb
    
    • 1
    • 2
    • 3
    • 4

    4. 安装 OS-Agent中一样,使用以下命令替换:

    apt install ./homeassistant-supervised.deb
    
    • 1

    我的安装过程中报错:

    root@nanopim4v2:/mydata/pkg# sudo apt install ./homeassistant-supervised.deb 
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    Note, selecting 'homeassistant-supervised' instead of './homeassistant-supervised.deb'
    The following additional packages will be installed:
      apparmor
    Suggested packages:
      apparmor-profiles-extra apparmor-utils
    The following NEW packages will be installed:
      apparmor homeassistant-supervised
    0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
    Need to get 601 kB/607 kB of archives.
    After this operation, 2,591 kB of additional disk space will be used.
    Do you want to continue? [Y/n] y
    Get:1 /mydata/pkg/homeassistant-supervised.deb homeassistant-supervised all 1.2.1 [5,968 B]
    Get:2 http://deb.debian.org/debian bullseye/main arm64 apparmor arm64 2.13.6-10 [601 kB]
    Fetched 601 kB in 1s (753 kB/s)   
    Preconfiguring packages ...
    Selecting previously unselected package apparmor.
    (Reading database ... 42354 files and directories currently installed.)
    Preparing to unpack .../apparmor_2.13.6-10_arm64.deb ...
    Unpacking apparmor (2.13.6-10) ...
    Selecting previously unselected package homeassistant-supervised.
    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] 
    Adding 'diversion of /etc/NetworkManager/NetworkManager.conf to /etc/NetworkManager/NetworkManager.conf.real by homeassistant-supervised'
    Adding 'diversion of /etc/NetworkManager/system-connections/default to /etc/NetworkManager/system-connections/default.real by homeassistant-supervised'
    Adding 'diversion of /etc/docker/daemon.json to /etc/docker/daemon.json.real by homeassistant-supervised'
    Adding 'diversion of /etc/network/interfaces to /etc/network/interfaces.real by homeassistant-supervised'
    Unpacking homeassistant-supervised (1.2.1) ...
    Setting up apparmor (2.13.6-10) ...
    Created symlink /etc/systemd/system/sysinit.target.wants/apparmor.service → /lib/systemd/system/apparmor.service.
    Reloading AppArmor profiles 
    Setting up homeassistant-supervised (1.2.1) ...
    [info] Restarting NetworkManager
    [info] Enable systemd-resolved
    [info] Restarting docker service
    PING version.home-assistant.io (172.67.68.90) 56(84) bytes of data.
    
    --- version.home-assistant.io ping statistics ---
    1 packets transmitted, 0 received, 100% packet loss, time 0ms
    
    [info] Waiting for version.home-assistant.io - network interface might be down...
    PING version.home-assistant.io (104.26.5.238) 56(84) bytes of data.
    
    --- version.home-assistant.io ping statistics ---
    1 packets transmitted, 0 received, 100% packet loss, time 0ms
    
    [info] Waiting for version.home-assistant.io - network interface might be down...
    PING version.home-assistant.io (104.26.4.238) 56(84) bytes of data.
    64 bytes from 104.26.4.238: icmp_seq=1 ttl=52 time=294 ms
    
    --- version.home-assistant.io ping statistics ---
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 293.773/293.773/293.773/0.000 ms
    [info] Install supervisor startup scripts
    [info] Install AppArmor scripts
    dpkg: error processing package homeassistant-supervised (--configure):
     installed homeassistant-supervised package post-installation script subprocess returned error exit status 35
    Processing triggers for man-db (2.9.4-2) ...
    Errors were encountered while processing:
     homeassistant-supervised
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    
    • 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
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68

    至此,查找原因,发现还是 dpkg 的原因,查看 /usr/bin/dpkg 是有这个路径的,也就是说之前提示 command not found: dkpg 是配置的问题,经过网上冲浪,找到了解决办法,就是重新配置 dpkg database,运行如下命令:

    sudo dpkg --configure -a
    
    • 1

    等待一段时间即可安装成功,并且 dpkg 命令也可以正常使用了。

    6. 访问

    等待一段时间后(10分钟左右),在浏览器中输入 设备ip:8123 即可访问Home Assistant。

    7、遗留问题

    不知道为什么访问 设备ip:4357 ,进入看到 Supported: Unsupported,但是可以正常接入设备使用,暂时未发现问题。

    Home Assistant observer
    
    Supervisor:	Connected
    Supported:	Unsupported
    Healthy:	Healthy
    
    • 1
    • 2
    • 3
    • 4
    • 5
  • 相关阅读:
    securecrt设置字体颜色
    第六篇:集合常见面试题
    字符串字符下标
    MySQL数据库——视图-检查选项(cascaded、local)
    luckysheet渲染数据及二维码后进行打印
    我用chatgpt写了一款程序
    配置kibana报错:connect ECONNREFUSED 127.0.0.1:9200
    领域事件和集成事件没那么高大上
    傅里叶级数@正弦级数和余弦级数@奇偶延拓和周期延拓
    私有云盘:lamp部署nextcloud+高可用集群
  • 原文地址:https://blog.csdn.net/weixin_41474364/article/details/125501218