环境: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保存内容(注意有冒号:)
#!/bin/bash
# wget -O - https://get.hacs.xyz | bash -
set -eRED_COLOR='\033[0;31m'
GREEN_COLOR='\033[0;32m'
GREEN_YELLOW='\033[1;33m'
NO_COLOR='\033[0m'declare haPath
declare -a paths=("$PWD""$PWD/config""/config""$HOME/.homeassistant""/usr/share/hassio/homeassistant"
)
declare currentVersion
declare currentYear
declare currentMonth
declare currentPatch
declare targetVersion
declare targetYear
declare targetMonth
declare targetPatchfunction info () { echo -e "${GREEN_COLOR}INFO: $1${NO_COLOR}";}
function warn () { echo -e "${GREEN_YELLOW}WARN: $1${NO_COLOR}";}
function error () { echo -e "${RED_COLOR}ERROR: $1${NO_COLOR}"; if [ "$2" != "false" ]; then exit 1;fi; }function checkRequirement () {if [ -z "$(command -v "$1")" ]; thenerror "'$1' is not installed"fi
}checkRequirement "wget"
checkRequirement "unzip"info "Trying to find the correct directory..."
for path in "${paths[@]}"; doif [ -n "$haPath" ]; thenbreakfiif [ -f "$path/.HA_VERSION" ]; thenhaPath="$path"fi
doneif [ -n "$haPath" ]; theninfo "Found Home Assistant configuration directory at '$haPath'"cd "$haPath" || error "Could not change path to $haPath"if [ ! -d "$haPath/custom_components" ]; theninfo "Creating custom_components directory..."mkdir "$haPath/custom_components"fiinfo "Changing to the custom_components directory..."cd "$haPath/custom_components" || error "Could not change path to $haPath/custom_components"info "Downloading HACS"wget "https://github.com/hacs/integration/releases/latest/download/hacs.zip"if [ -d "$haPath/custom_components/hacs" ]; thenwarn "HACS directory already exist, cleaning up..."rm -R "$haPath/custom_components/hacs"fiinfo "Creating HACS directory..."mkdir "$haPath/custom_components/hacs"info "Unpacking HACS..."unzip "$haPath/custom_components/hacs.zip" -d "$haPath/custom_components/hacs" >/dev/null 2>&1echoinfo "Verifying versions"targetVersion=$(sed -n -e '/^MINIMUM_HA_VERSION/p' "$haPath/custom_components/hacs/const.py" | cut -d '"' -f 2)currentVersion=$(cat "$haPath/.HA_VERSION")info "Current version is ${currentVersion}, minimum version is ${targetVersion}"targetYear=$(echo "${targetVersion}" | cut -d "." -f 1)currentYear=$(echo "${currentVersion}" | cut -d "." -f 1)if [ "${currentYear}" -lt "${targetYear}" ]; thenrm -R "$haPath/custom_components/hacs"error "Version ${currentVersion} is not new enough, needs at least ${targetVersion}"fiif [ "${currentYear}" == "${targetYear}" ]; thentargetMonth=$(echo "${targetVersion}" | cut -d "." -f 2)currentMonth=$(echo "${currentVersion}" | cut -d "." -f 2)if [ "${currentMonth}" -lt "${targetMonth}" ]; thenrm -R "$haPath/custom_components/hacs"error "Version ${currentVersion} is not new enough, needs at least ${targetVersion}"fiif [ "${currentMonth}" == "${targetMonth}" ]; thentargetPatch=$(echo "${targetVersion}" | cut -d "." -f 3)currentPatch=$(echo "${currentVersion}" | cut -d "." -f 3)if [ "${currentPatch}" -lt "${targetPatch}" ]; thenrm -R "$haPath/custom_components/hacs"error "Version ${currentVersion} is not new enough, needs at least ${targetVersion}"fififiechoinfo "Removing HACS zip file..."rm "$haPath/custom_components/hacs.zip"info "Installation complete."echoinfo "Remember to restart Home Assistant before you configure it"elseechoerror "Could not find the directory for Home Assistant" falseecho "Manually change the directory to the root of your Home Assistant configuration"echo "With the user that is running Home Assistant"echo "and run the script again"exit 1
fi
3、运行hacs.sh脚本
运行脚本:./hacs.sh
等待几分钟,会自动安装hacs,看到restart后安装成功,重启homeassistant
4、添加hacs模块
配置-设备与服务
添加集成-选择品牌-输入HACS
点击链接,这里需要访问github,网络要加速器。没有github网站的账户要注册一个。
填入号码
完成添加HACS
添加自定义存储库
添加地址
https://github.com/theneweinstein/somneo
完成后,就可以添加插件了