本帖最后由 aktifin 于 2018-6-25 10:51 编辑
hass更新到了0.72,最大的变化就是增加了lovelace全新的用户界面系统,
将核心功能和界面分离,以后更改界面直接刷新就好了,由于目前还在测试,默认界面还是老版本的
新界面需要手动开启
https://www.home-assistant.io/blog/2018/06/22/release-72/#
https://developers.home-assistant.io/docs/en/lovelace_index.html
官方样例:
CustomUI 旧版界面:
lovelace新版界面:
很快就调试出来的,实在太方便了
参考代码:
config根目录下建立ui-lovelace.yaml
在hass网址后加入 /lovelace,即可访问新界面
name: Rokey's Home
type: module
views:
- name: 主页
theme: dark-mode
tab_icon: mdi:home
cards:
- type: entities
title: 开关
entities:
- input_boolean.xxx
- cover.xxx
- switch.xxx
- fan.xxx
- input_boolean.xxx
- type: weather-forecast
entity: weather.localweather
- type: glance
title: 生活讯息
entities:
- sensor.aircat_temperature_xxx
- sensor.aircat_humidity_xxx
- sensor.aircat_pm25_xxx
- sensor.aircat_hcho_xxx
- type: glance
title: 无线设备状态
entities:
- device_tracker.xxx
- type: media-control
entity: media_player.mpd
- type: media-control
entity: media_player.bt
- type: glance
title: 灯光
entities:
- light.gateway_light_xxx
- switch.hassmart_keting_xxx
- light.bedroom_yeelight_xxx
默认直接进入新界面的办法:
1、在configuration.yaml里修改加入如下代码
frontend:
javascript_version: auto
extra_html_url:
- /local/lovelace.html
2、在www文件夹下建立lovelace.html
<script>
if (window.location.pathname === "/states") {
window.location.href = "/lovelace"
}
window.addEventListener("location-changed", function (e) {
if (e.currentTarget.location.pathname === "/states") {
window.location.href = "/lovelace"
}
});
</script>
|