谢大蟀智能家居

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 30|回复: 0

homeassistant安装HACS

[复制链接]

46

主题

52

帖子

199

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
199
发表于 2025-4-20 21:03:13 | 显示全部楼层 |阅读模式

进入终端,输入账号和密码(默认:root,password)

查看容器:

  1. docker ps
复制代码

进入容器:

  1. docker exec -it homeassistant bash
复制代码

下载hacs

使用命令下载hacs,会转向github,可能无法访问

  1. wget -O - https://get.hacs.xyz | bash -
复制代码

如果能够访问成功,安装完成后请重启homeassistant,即可完成安装,以下第3步不用再操作

如果上面地址无法访问,可以使用以下命令安装:

创建文件:

  1. touch hacs.sh && chmod +x hacs.sh
复制代码

编辑文件:

  1. vi hacs.sh
复制代码

粘贴下面内容:先按a,表示开始编辑,右键粘贴进去后,按esc退出编辑,输入:wq保存内容(注意有冒号:)

  1. #!/bin/bash
  2. # wget -O - https://get.hacs.xyz | bash -
  3. set -e

  4. RED_COLOR='\033[0;31m'
  5. GREEN_COLOR='\033[0;32m'
  6. GREEN_YELLOW='\033[1;33m'
  7. NO_COLOR='\033[0m'

  8. declare haPath
  9. declare -a paths=(
  10.     "$PWD"
  11.     "$PWD/config"
  12.     "/config"
  13.     "$HOME/.homeassistant"
  14.     "/usr/share/hassio/homeassistant"
  15. )
  16. declare currentVersion
  17. declare currentYear
  18. declare currentMonth
  19. declare currentPatch
  20. declare targetVersion
  21. declare targetYear
  22. declare targetMonth
  23. declare targetPatch

  24. function info () { echo -e "${GREEN_COLOR}INFO: $1${NO_COLOR}";}
  25. function warn () { echo -e "${GREEN_YELLOW}WARN: $1${NO_COLOR}";}
  26. function error () { echo -e "${RED_COLOR}ERROR: $1${NO_COLOR}"; if [ "$2" != "false" ]; then exit 1;fi; }

  27. function checkRequirement () {
  28.     if [ -z "$(command -v "$1")" ]; then
  29.         error "'$1' is not installed"
  30.     fi
  31. }

  32. checkRequirement "wget"
  33. checkRequirement "unzip"

  34. info "Trying to find the correct directory..."
  35. for path in "${paths[@]}"; do
  36.     if [ -n "$haPath" ]; then
  37.         break
  38.     fi

  39.     if [ -f "$path/.HA_VERSION" ]; then
  40.         haPath="$path"
  41.     fi
  42. done

  43. if [ -n "$haPath" ]; then
  44.     info "Found Home Assistant configuration directory at '$haPath'"
  45.     cd "$haPath" || error "Could not change path to $haPath"
  46.     if [ ! -d "$haPath/custom_components" ]; then
  47.         info "Creating custom_components directory..."
  48.         mkdir "$haPath/custom_components"
  49.     fi

  50.     info "Changing to the custom_components directory..."
  51.     cd "$haPath/custom_components" || error "Could not change path to $haPath/custom_components"

  52.     info "Downloading HACS"
  53.     wget "https://github.com/hacs/integration/releases/latest/download/hacs.zip"

  54.     if [ -d "$haPath/custom_components/hacs" ]; then
  55.         warn "HACS directory already exist, cleaning up..."
  56.         rm -R "$haPath/custom_components/hacs"
  57.     fi

  58.     info "Creating HACS directory..."
  59.     mkdir "$haPath/custom_components/hacs"

  60.     info "Unpacking HACS..."
  61.     unzip "$haPath/custom_components/hacs.zip" -d "$haPath/custom_components/hacs" >/dev/null 2>&1


  62.     echo
  63.     info "Verifying versions"
  64.     targetVersion=$(sed -n -e '/^MINIMUM_HA_VERSION/p' "$haPath/custom_components/hacs/const.py" | cut -d '"' -f 2)
  65.     currentVersion=$(cat "$haPath/.HA_VERSION")

  66.     info "Current version is ${currentVersion}, minimum version is ${targetVersion}"

  67.     targetYear=$(echo "${targetVersion}" | cut -d "." -f 1)
  68.     currentYear=$(echo "${currentVersion}" | cut -d "." -f 1)

  69.     if [ "${currentYear}" -lt "${targetYear}" ]; then
  70.         rm -R "$haPath/custom_components/hacs"
  71.         error "Version ${currentVersion} is not new enough, needs at least ${targetVersion}"
  72.     fi

  73.     if [ "${currentYear}" == "${targetYear}" ]; then
  74.         targetMonth=$(echo "${targetVersion}" | cut -d "." -f 2)
  75.         currentMonth=$(echo "${currentVersion}" | cut -d "." -f 2)

  76.         if [ "${currentMonth}" -lt "${targetMonth}" ]; then
  77.         rm -R "$haPath/custom_components/hacs"
  78.             error "Version ${currentVersion} is not new enough, needs at least ${targetVersion}"
  79.         fi

  80.         if [ "${currentMonth}" == "${targetMonth}" ]; then
  81.             targetPatch=$(echo "${targetVersion}" | cut -d "." -f 3)
  82.             currentPatch=$(echo "${currentVersion}" | cut -d "." -f 3)

  83.             if [ "${currentPatch}" -lt "${targetPatch}" ]; then
  84.                 rm -R "$haPath/custom_components/hacs"
  85.                 error "Version ${currentVersion} is not new enough, needs at least ${targetVersion}"
  86.             fi
  87.         fi
  88.     fi

  89.     echo
  90.     info "Removing HACS zip file..."
  91.     rm "$haPath/custom_components/hacs.zip"
  92.     info "Installation complete."
  93.     echo
  94.     info "Remember to restart Home Assistant before you configure it"

  95. else
  96.     echo
  97.     error "Could not find the directory for Home Assistant" false
  98.     echo "Manually change the directory to the root of your Home Assistant configuration"
  99.     echo "With the user that is running Home Assistant"
  100.     echo "and run the script again"
  101.     exit 1
  102. fi
复制代码

运行hacs.sh脚本

运行脚本:

  1. ./hacs.sh
复制代码

等待几分钟,会自动安装hacs,看到restart后安装成功,重启homeassistant

添加hacs模块

配置-设备与服务

添加集成-选择品牌-输入HACS

点击链接,这里需要访问github,网络要加速器。没有github网站的账户要注册一个。

填入号码








完成添加HACS


添加自定义存储库


添加地址


https://github.com/theneweinstein/somneo


完成后,就可以添加插件了





本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|谢大蟀智能家居 ( 闽ICP备18020392号-1 )

GMT+8, 2025-6-6 21:08 , Processed in 0.073792 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表