当前位置:   article > 正文

homeassistant安装HACS应用商店_安装hacs插件商店

安装hacs插件商店

环境:iStoreOS,已在商店中安装homeassistant。

homeassistant在iStoreOS中是以docker容器运行的。

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

查看容器:docker ps

进入容器:docker exec -it homeassistant bash

2、下载hacs

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

wget -O - https://get.hacs.xyz | bash - 

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

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

创建文件:touch hacs.sh && chmod +x hacs.sh

编辑文件: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

3、运行hacs.sh脚本 

运行脚本:./hacs.sh

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

4、添加hacs模块

配置-设备与服务

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

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

填入号码 

完成添加HACS 

添加自定义存储库

添加地址 

https://github.com/theneweinstein/somneo

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

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/463403
推荐阅读
相关标签
  

闽ICP备14008679号