所谓分组就是把不同设备聚到一起,比如卧室、客厅这样的分组,可以直接开关整个分组;自定义就是设置设备(实体)、组的参数,之前提到的hide in homebridge也算是;Custom UI起到修改UI的作用,可以丰富信息展示,一般先安装这个

分组

官方文档在这里

最简单的就是在配置目录下的groups.yaml中添加。

raspberrypi:
  name: 树莓派
  view: no
  entities:
    - sensor.pi_temp
    - sensor.memory_use
    - sensor.memory_use_percent
    - sensor.disk_use_
    - sensor.disk_use_percent_
    - sensor.ssl_certificate_expiry
    - sensor.since_last_boot_templated

例如这里我添加了一个名为树莓派的组,view是指产生一个分页,否则是以一个卡片展示的。

分组中可以再添加分组,可以点击弹出。在entities中添加- groups.xxx即可。

分组修改后,可以直接从浏览器端配置-通用-重载分组来刷新页面。

自定义

自定义位于customize.yaml,可以修改文件,也可以浏览器端配置-自定义来修改,最基本的有设置图标、名字,不同的组件参数是不一样的。下面会提到配合Custom UI的一些操作。

Custom-UI

目前我用到的也就是显示额外的Badge和额外的文字,这里有写到Custom UI的功能。

安装

参考这里

进入配置目录

curl -o update.sh "https://raw.githubusercontent.com/andrey-git/home-assistant-custom-ui/master/update.sh?raw=true"
chmod u+x update.sh
./update.sh

激活

修改configuration.yaml(旧版不太一样,需要参考文档

customizer:
  custom_ui: local

frontend:
  extra_html_url:
    - /local/custom_ui/state-card-custom-ui.html
    - /local/custom_ui/state-card-weather.html

  extra_html_url_es5:
    - /local/custom_ui/state-card-custom-ui-es5.html
    - /local/custom_ui/state-card-weather.html

添加文字和Badge

修改自定义文件customize.yaml,关于Custom UI的操作都需要添加custom_ui_state_card这一行,extra_data_template就是文字的内容了,这里的template和之前用过的还不太一样,参考这个

这里entities['sensor.memory_use']获取已使用内存的实体,state就是它的状态(值),这个可以在浏览器端开发者工具下面的状态里面看到。${}这种应该是JS的字符串模板写法,前后可以随便加文字。

sensor.memory_use_percent:
friendly_name: RAM使用率
custom_ui_state_card: state-card-custom-ui
extra_data_template: 已使用 ${entities['sensor.memory_use'].state}M

下面这个是给开关加上上次变化时间和开关温度,显示上次变化时间只需要加入show_last_changed: true就可以了,extra_badge可以用开关自身的属性(attribute),也可以是entity_id: sensor.xxxx,显示别的传感器数值。

switch.xiaomi_switch_two:
  friendly_name: 台灯
  custom_ui_state_card: state-card-custom-ui
  show_last_changed: true
  extra_badge:
    attribute: temperature
    unit: °C

参考

https://github.com/andrey-git/home-assistant-custom-ui/blob/master/docs/installing.md#local-install
https://github.com/andrey-git/home-assistant-custom-ui/blob/master/docs/activating.md
https://github.com/andrey-git/home-assistant-custom-ui/blob/master/docs/features.md