侧边栏壁纸
  • 累计撰写 81 篇文章
  • 累计创建 50 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

homeassistant无法安装hacs解决方法

shawn
2023-09-02 / 0 评论 / 0 点赞 / 5 阅读 / 2781 字

homeassistant无法安装hacs解决方法

  1. 下载附件,把文件replace_hacs_download_mirror.sh放到HA主目录/config下(和configuration.yaml文件同一个目录)
# Run this file with sh command in HA docker to auto REPLACE the github download website in HACS download.py file /config/custom_components/hacs/helpers/function/download.py
# Script by chuixue
#! /bin/bash

# The following is the default HACS download URL file path. Change it if yours is not the current path
ha_path="/config"
github_com_mirror="hub.fastgit.org"
raw_githubusercontent_com_mirror="raw.fastgit.org"

#######
ha_path=$(cd ${ha_path}; pwd)
old_download_url_path="${ha_path}/custom_components/hacs/helpers/functions/download.py"
new_download_url_path="${ha_path}/custom_components/hacs/base.py"

if [ -f "${old_download_url_path}" ]; then
  download_url_path=${old_download_url_path}
  url_blank="    "
else
  download_url_path=${new_download_url_path}
  url_blank="        "
fi

# Delete the old lines in hacs url file if it is available
sed  -i '/url = url.replace("raw.githubusercontent.com", "'"${raw_githubusercontent_com_mirror}"'")/,/url = url.replace("\\\\\\\\/\\\\\\\\/github.com\\\\\\\\/", "\\\\\\\\/\\\\\\\\/'"${github_com_mirror}"'\\\\\\\\/")/d' $download_url_path

# Add the new lines in hacs url file
sed -i '/if "tags\\\\\\\\/" in url:/i\\\\\\\\'"${url_blank}"'url = url.replace("raw.githubusercontent.com", "'"${raw_githubusercontent_com_mirror}"'")\\\\\\\\n'"${url_blank}"'if "releases/download/" in url or "archive/refs/" in url:\\\\\\\\n'"${url_blank}"'    url = url.replace("//github.com/", "//'"${github_com_mirror}"'/")' $download_url_path
  1. 为防止HACS更新后下载源文件被覆盖,需设置HA启动后,自动更新HACS下载源: 在/config/packages 文件夹(没有这个文件夹就新建一个)下新建文件update_hacs_download_source.yaml
shell_command:
  update_hacs_download_source: sh /config/replace_hacs_download_mirror.sh

automation:
  - alias: HA启动自动更新HACS下载源
    trigger:
      - platform: homeassistant
        event: start
    action:
      - service: shell_command.update_hacs_download_source
0

评论区