homeassistant安装HACS应用商店

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

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

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

查看容器:docker ps

进入容器:docker exec -it homeassistant bash

homeassistant安装HACS应用商店_第1张图片

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

homeassistant安装HACS应用商店_第2张图片

4、添加hacs模块

配置-设备与服务

homeassistant安装HACS应用商店_第3张图片

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

homeassistant安装HACS应用商店_第4张图片

homeassistant安装HACS应用商店_第5张图片

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

homeassistant安装HACS应用商店_第6张图片

填入号码 

homeassistant安装HACS应用商店_第7张图片

homeassistant安装HACS应用商店_第8张图片

homeassistant安装HACS应用商店_第9张图片

homeassistant安装HACS应用商店_第10张图片

完成添加HACS 

homeassistant安装HACS应用商店_第11张图片

添加自定义存储库

homeassistant安装HACS应用商店_第12张图片

添加地址 

https://github.com/theneweinstein/somneo

homeassistant安装HACS应用商店_第13张图片

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

homeassistant安装HACS应用商店_第14张图片

 

你可能感兴趣的:(智能家居)