跳到主要内容

徽章

徽章是位于面板顶部、所有卡片上方的小部件。

面板顶部的徽章。

面板顶部的徽章。

将徽章添加到你的仪表板

  1. 前往 设置 > 仪表板

  2. 如果你有多个视图,请打开你想要添加徽章的视图。

  3. 在屏幕右上角,选择编辑 按钮。

  4. 要添加徽章,选择加号 按钮。 显示如何添加徽章的截图

  5. 选择你想要显示徽章的实体。

  6. 配置你的徽章。

  • 可用选项取决于实体。
  • 添加你想要看到的状态。
  • 如果你想,添加一个名称显示如何配置徽章的截图
  1. 交互下,你可以定义点击行为。

  2. 如果你只想让特定用户看到此徽章或在特定条件下显示,打开可见性选项卡来定义这些条件

  3. 选择保存显示如何将徽章添加到仪表板的屏幕录像

    显示如何将徽章添加到仪表板的屏幕录像

实体徽章

实体徽章允许你在徽章上显示实体的状态。此徽章支持操作。

type: entity
entity: light.living_room

配置变量

type 字符串 必填

entity

entity 字符串 必填

实体 ID。

name 字符串 (可选)

覆盖实体名称。

icon 字符串 (可选)

覆盖实体图标。

color 字符串 (可选,默认值: state)

设置实体激活时的颜色。默认情况下,颜色基于你实体的 statedomaindevice_class。它接受颜色令牌或十六进制颜色代码。

show_entity_picture 布尔值 (可选,默认值: false)

如果你的实体有图片,它将替换图标。

show_name 布尔值 (可选,默认值: false)

显示名称

show_icon 布尔值 (可选,默认值: true)

显示图标

show_state 布尔值 (可选,默认值: true)

显示状态

state_content 字符串 | 列表 (可选)

显示状态的内容。可以是 statelast_changedlast_updated 或实体的任何属性。可以是包含单个项目的字符串,也可以是字符串项目列表。默认值取决于实体域。

tap_action 映射 (可选)

点击卡片时执行的操作。查看操作文档。默认情况下,它将显示"更多信息"对话框。

hold_action 映射 (可选)

点击并按住时执行的操作。查看操作文档

double_tap_action 映射 (可选)

双击时执行的操作。查看操作文档

实体过滤器徽章

此徽章允许你定义一个实体列表,当这些实体处于特定状态时才进行跟踪。非常适合显示你忘记关闭的灯光或者仅当人在家时显示人员列表。

配置变量

type 字符串 必填

entity-filter

entities 列表 必填

实体 ID 列表或 entity 对象,见下文。

conditions 列表 (可选)

要检查的条件列表。查看可用条件。*

state_filter 列表 (可选)

(遗留) 表示要检查的状态或过滤器的字符串列表。查看可用的遗留过滤器。*

*必须选择一个(conditionsstate_filter

实体选项

如果你将实体定义为对象而不是字符串(通过在实体 ID 前添加 entity:),你可以添加更多自定义和配置:

配置变量

type 字符串 (可选)

设置自定义徽章类型:custom:my-custom-badge

entity 字符串 必填

实体 ID。

name 字符串 (可选)

覆盖友好名称。

icon 字符串 (可选)

覆盖图标或实体图片。你可以使用Material Design Icons中的任何图标。图标名称前加上 mdi:,例如 mdi:home

conditions 列表 (可选)

要检查的条件列表。查看可用条件。*

state_filter 列表 (可选)

(遗留) 表示要检查的状态或过滤器的字符串列表。查看可用的遗留过滤器。*

*只会应用一个过滤器:如果没有 conditions,则使用 state_filter

你还可以向实体添加所选徽章类型支持的任何其他配置选项(如果未选择类型,则为 Entity 徽章类型)。

条件选项

你可以指定多个 conditions,在这种情况下,如果实体满足所有条件,它将被显示。

状态

测试实体是否具有指定状态。

type: entity-filter
entities:
- climate.thermostat_living_room
- climate.thermostat_bed_room
conditions:
- condition: state
state: heat
type: entity-filter
entities:
- climate.thermostat_living_room
- climate.thermostat_bed_room
conditions:
- condition: state
state_not: "off"
type: entity-filter
entities:
- sensor.gas_station_1
- sensor.gas_station_2
- sensor.gas_station_3
conditions:
- condition: state
state: sensor.gas_station_lowest_price

配置变量

condition 字符串 必填

state

state 列表 | 字符串 (可选)

实体状态或 ID 等于此值。可以包含状态数组。*

state not 列表 | 字符串 (可选)

实体状态或 ID 不等于此值。可以包含状态数组。*

*必须选择一个(statestate_not

数值状态

测试实体状态是否符合阈值。

type: entity-filter
entities:
- sensor.outside_temperature
- sensor.living_room_temperature
- sensor.bed_room_temperature
conditions:
- condition: numeric_state
above: 10
below: 20

配置变量

condition 字符串 必填

numeric_state

above 字符串 (可选)

实体状态或 ID 高于此值。*

below 字符串 (可选)

实体状态或 ID 低于此值。*

*至少需要一个(abovebelow),两者也可用于表示介于两个值之间。

屏幕

指定每个屏幕尺寸的实体可见性。UI 中提供了一些屏幕尺寸预设,但你可以在 YAML 中使用任何 CSS 媒体查询。

type: entity-filter
entities:
- sensor.outside_temperature
- sensor.living_room_temperature
- sensor.bed_room_temperature
conditions:
- condition: screen
media_query: "(min-width: 1280px)"

配置变量

condition 字符串 必填

screen

media_query 字符串 必填

媒体查询,用于检查允许显示实体的屏幕尺寸。

用户

指定每个用户的实体可见性。

type: entity-filter
entities:
- sensor.outside_temperature
- sensor.living_room_temperature
- sensor.bed_room_temperature
conditions:
- condition: user
users:
- 581fca7fdc014b8b894519cc531f9a04

配置变量

condition 字符串 必填

user

users 列表 必填

可以看到实体的用户 ID(在用户配置页面上找到的唯一十六进制值)。

And

指定必须满足两个条件。

type: entity-filter
entities:
- sensor.outside_temperature
- sensor.living_room_temperature
- sensor.bed_room_temperature
conditions:
- condition: and
conditions:
- condition: numeric_state
above: 0
- condition: user
users:
- 581fca7fdc014b8b894519cc531f9a04

配置变量

condition 字符串 必填

and

conditions 列表 (可选)

要检查的条件列表。查看可用条件

Or

指定必须满足至少一个条件。

type: entity-filter
entities:
- sensor.outside_temperature
- sensor.living_room_temperature
- sensor.bed_room_temperature
conditions:
- condition: or
conditions:
- condition: numeric_state
above: 0
- condition: user
users:
- 581fca7fdc014b8b894519cc531f9a04

配置变量

condition 字符串 必填

or

conditions 列表 (可选)

要检查的条件列表。查看可用条件

遗留状态过滤器

字符串过滤器

只显示房子里处于活动状态的开关或灯光。

type: entity-filter
entities:
- entity: light.bed_light
name: Bed
- light.kitchen_lights
- light.ceiling_lights
state_filter:
- "on"

你还可以指定多个 state_filter 条件,在这种情况下,如果实体满足任何条件,它将被显示。

如果你将 state_filter 定义为对象而不是字符串,你可以向过滤器添加更多自定义,如下所述。

运算符过滤器

测试实体状态是否符合应用的 operator

配置变量

value 字符串 必填

表示状态的字符串。

operator 字符串 必填

用于比较的运算符。可以是 ==<=<>=>!=innot inregex

attribute 字符串 (可选)

代替状态使用的实体属性。

示例

显示所有在家或在工作的人。

type: entity-filter
entities:
- device_tracker.demo_paulus
- device_tracker.demo_anne_therese
- device_tracker.demo_home_boy
state_filter:
- operator: "=="
value: home
- operator: "=="
value: work

为单个实体指定过滤器。

type: entity-filter
state_filter:
- "on"
- operator: ">"
value: 90
entities:
- sensor.water_leak
- sensor.outside_temp
- entity: sensor.humidity_and_temp
state_filter:
- operator: ">"
value: 50
attribute: humidity

对实体属性使用正则表达式过滤器。以下正则表达式过滤器查找长度为 1 位且数字在 0-7 之间的表达式(显示今天或未来 7 天内的假期),并将这些假期作为实体显示在实体过滤器徽章中。

type: entity-filter
state_filter:
- operator: regex
value: "^([0-7]{1})$"
attribute: eta
entities:
- entity: sensor.upcoming_ical_holidays_0
- entity: sensor.upcoming_ical_holidays_1
- entity: sensor.upcoming_ical_holidays_2
- entity: sensor.upcoming_ical_holidays_3
- entity: sensor.upcoming_ical_holidays_4
show_empty: false