homeassistant安装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保存内容(注意有冒号:)

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

RED_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 targetPatch

function 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")" ]; then
        error "'$1' is not installed"
    fi
}

checkRequirement "wget"
checkRequirement "unzip"

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

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

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

    info "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" ]; then
        warn "HACS directory already exist, cleaning up..."
        rm -R "$haPath/custom_components/hacs"
    fi

    info "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>&1


    echo
    info "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}" ]; then
        rm -R "$haPath/custom_components/hacs"
        error "Version ${currentVersion} is not new enough, needs at least ${targetVersion}"
    fi

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

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

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

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

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

else
    echo
    error "Could not find the directory for Home Assistant" false
    echo "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

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

 

  • 3
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值