『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 330|回复: 2

[技术讨论] 解决add-ons无法加载和HACS无法下载或加载慢问题

[复制链接]

1

主题

1

帖子

40

积分

新手上路

Rank: 1

积分
40
金钱
39
HASS币
0
发表于 2024-5-29 11:10:18 | 显示全部楼层 |阅读模式
本帖最后由 foxes 于 2024-5-29 11:09 编辑

基于 hassos 做的, 其它版本需要自行修改, 我也没用过, 原理是拿 https://raw.hellogithub.com/hosts 返回追加到 hosts 文件

感谢 https://github.com/521xueweihan/GitHub520 大佬的项目提供的 hosts 文件


新建 update_github_hosts.sh 脚本, 放在你知道的位置, 我是放在新建了一个 scripts 目录:   scripts/update_github_hosts.sh
#!/bin/bash

curl -s https://raw.hellogithub.com/hosts >> /etc/hosts

if [ -d $(docker exec -i homeassistant /bin/bash -lc 'curl -s https://raw.hellogithub.com/hosts >> /etc/hosts')]; then
    echo "homeassistant hosts update done"
fi

if [ -d $(docker exec -i hassio_supervisor /bin/bash -lc 'curl -s https://raw.hellogithub.com/hosts >> /etc/hosts')]; then
    echo "hassio_supervisor hosts update done"
fi


configuration.yaml 添加 shell_command, 指向脚本位置
shell_command:
    update_github_hosts: bash -c /config/scripts/update_github_hosts.sh

automations.yaml 里添加启动触发就行
- id: update_github_hosts
  alias: update github hosts
  trigger:
  - platform: homeassistant
    event: start
  action:
    - service: shell_command.update_github_hosts
    data: {}



评分

参与人数 1金钱 +12 收起 理由
隔壁的王叔叔 + 12 高手,这是高手!

查看全部评分

回复

使用道具 举报

7

主题

1108

帖子

3524

积分

论坛元老

Rank: 8Rank: 8

积分
3524
金钱
2416
HASS币
0
发表于 2024-5-29 12:39:12 | 显示全部楼层
好东西,core应该也能用
回复

使用道具 举报

0

主题

25

帖子

59

积分

注册会员

Rank: 2

积分
59
金钱
34
HASS币
0
发表于 2024-6-2 16:23:04 | 显示全部楼层
shell_command:
    update_github_hosts: bash -c /config/scripts/update_github_hosts.sh
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-6-26 17:52 , Processed in 0.074410 second(s), 26 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表