Closed whiterober closed 4 years ago
有同样的情况 是DOCKER环境下运行的 0.111.4
0.105 正常 在0.111下有嵌套
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文件
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
论坛一看见帖子 感谢
试了一下楼上的解决方案没成功,需要重启吗
我个人使用的修改(HA 0.114.1):
http.py
中 register_static_path
相关的逻辑。(修改各种值都没用)custom_components/havcs/html/{index,login}.html
中的 /havcs/
替换 为 /local/havcs/
custom_components/havcs/html
目录中所有内容复制到 HA 配置文件夹子目录中 www/havcs
中。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,如下图。迟些再更新代码。
操作系统:win10 HASS:Home Assistant 0.104.2 安装了HAVCS,加载成功,但是点击HAVCS设备菜单,出现的是无限嵌套![QQ20200621-0](https://user-images.githubusercontent.com/7847975/85217172-6fdbf400-b3c0-11ea-8538-038b06e527ec.png)