cnk700i / havcs

Home Assistant Voice Control Skill
https://ljr.im/articles/plugins-havcs-edible-instructions/
Apache License 2.0
311 stars 97 forks source link

HAVCS菜单无限嵌套显示 #30

Closed whiterober closed 4 years ago

whiterober commented 4 years ago

操作系统:win10 HASS:Home Assistant 0.104.2 安装了HAVCS,加载成功,但是点击HAVCS设备菜单,出现的是无限嵌套 QQ20200621-0

xe5700 commented 4 years ago

有同样的情况 是DOCKER环境下运行的 0.111.4

sxx1314 commented 4 years ago

0.105 正常 在0.111下有嵌套 1

dscao commented 4 years ago

http.py文件

local = hass.config.path("custom_components/" + INTEGRATION + "/html")
        if os.path.isdir(local):
            hass.http.register_static_path('/havcs', local, False)
        panels = hass.data.setdefault(DATA_PANELS, {})
        if INTEGRATION not in panels:
            hass.components.frontend.async_register_built_in_panel(
                component_name = "iframe",
                sidebar_title = 'HAVCS设备',
                sidebar_icon = 'mdi:home-edit',
                frontend_url_path = INTEGRATION,
                config = {"url": '/havcs/index.html'},
                require_admin = True
            )

修改:

local = hass.config.path("custom_components/" + INTEGRATION + "/html")
        if os.path.isdir(local):
            hass.http.register_static_path('/havcshtml', local, False)   #修改
        panels = hass.data.setdefault(DATA_PANELS, {})
        if INTEGRATION not in panels:
            hass.components.frontend.async_register_built_in_panel(
                component_name = "iframe",
                sidebar_title = 'HAVCS设备',
                sidebar_icon = 'mdi:home-edit',
                frontend_url_path = INTEGRATION,
                config = {"url": '/havcshtml/index.html'},   #修改
                require_admin = True
            )

html/index.html 和 login.html 文件 将 /havcs/ 替换为: /havcshtml/

瞎捣鼓了两天,自己的正常显示了。大家可以测试一下。

我的系统环境是openwrt软路由中docker搭建 Home Assistant 0.112.4(目前最新版本) arch x86_64
dev false
docker true
hassio false
installation_type Home Assistant Container
os_name Linux
os_version 4.19.122
python_version 3.7.7
timezone UTC
version 0.112.4
virtualenv false
sxx1314 commented 4 years ago

http.py文件

local = hass.config.path("custom_components/" + INTEGRATION + "/html")
        if os.path.isdir(local):
            hass.http.register_static_path('/havcs', local, False)
        panels = hass.data.setdefault(DATA_PANELS, {})
        if INTEGRATION not in panels:
            hass.components.frontend.async_register_built_in_panel(
                component_name = "iframe",
                sidebar_title = 'HAVCS设备',
                sidebar_icon = 'mdi:home-edit',
                frontend_url_path = INTEGRATION,
                config = {"url": '/havcs/index.html'},
                require_admin = True
            )

修改:

local = hass.config.path("custom_components/" + INTEGRATION + "/html")
        if os.path.isdir(local):
            hass.http.register_static_path('/havcshtml', local, False)   #修改
        panels = hass.data.setdefault(DATA_PANELS, {})
        if INTEGRATION not in panels:
            hass.components.frontend.async_register_built_in_panel(
                component_name = "iframe",
                sidebar_title = 'HAVCS设备',
                sidebar_icon = 'mdi:home-edit',
                frontend_url_path = INTEGRATION,
                config = {"url": '/havcshtml/index.html'},   #修改
                require_admin = True
            )

html/index.html 和 login.html 文件 将 /havcs/ 替换为: /havcshtml/

瞎捣鼓了两天,自己的正常显示了。大家可以测试一下。

我的系统环境是openwrt软路由中docker搭建 Home Assistant 0.112.4(目前最新版本)

arch x86_64 dev false docker true hassio false installation_type Home Assistant Container os_name Linux os_version 4.19.122 python_version 3.7.7 timezone UTC version 0.112.4 virtualenv false

论坛一看见帖子 感谢

rockiecxh commented 4 years ago

试了一下楼上的解决方案没成功,需要重启吗

ttimasdf commented 4 years ago

我个人使用的修改(HA 0.114.1):

  1. 删除 http.pyregister_static_path 相关的逻辑。(修改各种值都没用)
  2. custom_components/havcs/html/{index,login}.html 中的 /havcs/ 替换 为 /local/havcs/
  3. custom_components/havcs/html 目录中所有内容复制到 HA 配置文件夹子目录中 www/havcs 中。
  4. 重启 HA 容器。
cnk700i commented 4 years ago

http.py文件

local = hass.config.path("custom_components/" + INTEGRATION + "/html")
        if os.path.isdir(local):
            hass.http.register_static_path('/havcs', local, False)
        panels = hass.data.setdefault(DATA_PANELS, {})
        if INTEGRATION not in panels:
            hass.components.frontend.async_register_built_in_panel(
                component_name = "iframe",
                sidebar_title = 'HAVCS设备',
                sidebar_icon = 'mdi:home-edit',
                frontend_url_path = INTEGRATION,
                config = {"url": '/havcs/index.html'},
                require_admin = True
            )

修改:

local = hass.config.path("custom_components/" + INTEGRATION + "/html")
        if os.path.isdir(local):
            hass.http.register_static_path('/havcshtml', local, False)   #修改
        panels = hass.data.setdefault(DATA_PANELS, {})
        if INTEGRATION not in panels:
            hass.components.frontend.async_register_built_in_panel(
                component_name = "iframe",
                sidebar_title = 'HAVCS设备',
                sidebar_icon = 'mdi:home-edit',
                frontend_url_path = INTEGRATION,
                config = {"url": '/havcshtml/index.html'},   #修改
                require_admin = True
            )

html/index.html 和 login.html 文件 将 /havcs/ 替换为: /havcshtml/ 瞎捣鼓了两天,自己的正常显示了。大家可以测试一下。 我的系统环境是openwrt软路由中docker搭建 Home Assistant 0.112.4(目前最新版本) arch x86_64 dev false docker true hassio false installation_type Home Assistant Container os_name Linux os_version 4.19.122 python_version 3.7.7 timezone UTC version 0.112.4 virtualenv false

论坛一看见帖子 感谢

套娃问题是http.py中async_register_built_in_panel方法注册的面板URL和静态资源URL重复了,可以按上面方法调整静态资源URL,简单的调整面板URL,如下图。迟些再更新代码。 image