实体过滤卡片
实体过滤卡片允许您定义一个实体列表,当它们处于某种状态时,您希望仅跟踪这些实体。非常适合显示您忘记关闭的灯,或当某些人回家时显示他们的列表。
实体过滤卡片的屏幕截图。
这种类型的卡片还可以与其他允许多个实体的卡片一起使用,使您能够使用 glance 或 picture-glance。默认情况下,它使用 entities 卡片模型。
要将 实体过滤卡片 添加到您的用户界面:
- 在屏幕右上角,选择编辑
按钮。 - 如果这是您第一次编辑仪表板,将会出现 编辑仪表板 对话框。
- 通过编辑仪表板,您将接管此仪表板的控制。
- 这意味着当新的仪表板元素可用时,它将不再自动更新。
- 一旦您接管控制,就无法将此特定仪表板恢复为自动更新状态。但是,您可以创建一个新的默认仪表板。
- 要继续,请在对话框中选择三点菜单
,然后选择 接管控制。
- 如果这是您第一次编辑仪表板,将会出现 编辑仪表板 对话框。
- 添加卡片并自定义操作和功能 到您的仪表板。
YAML 配置
此卡片只能在 YAML 中配置。
*必须有一个(conditions
或 state_filter
)
实体选项
如果您将实体定义为对象而不是字符串(在实体 ID 前添加 entity:
),您可以添加更多自定义和配置:
Configuration Variables
重写图标或实体图片。您可以使用来自 Material Design Iconsmdi:
,例如 mdi:home
。
要检查的条件列表。见 可用条件.*
(遗留) 代表状态或待检查的过滤器的字符串列表。见 可用遗留过滤器.*
*只会应用一个过滤器:conditions
或 state_filter
(如果 conditions
不存在)
条件选项
您可以指定多个 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
*必须有一个(state
或 state_not
)
数值状态
测试实体状态是否符合阈值。
type: entity-filter
entities:
- sensor.outside_temperature
- sensor.living_room_temperature
- sensor.bed_room_temperature
conditions:
- condition: numeric_state
above: 10
below: 20
*至少需要一个(above
或 below
),也可以使用两个来表示在值之间。
屏幕
按屏幕大小指定实体的可见性。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)"
用户
按用户指定实体的可见性。
type: entity-filter
entities:
- sensor.outside_temperature
- sensor.living_room_temperature
- sensor.bed_room_temperature
conditions:
- condition: user
users:
- 581fca7fdc014b8b894519cc531f9a04
并且
指定两个条件都必须满足。
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
Configuration Variables
要检查的条件列表。见 可用条件。
或者
指定至少一个条件必须满足。
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
Configuration Variables
要检查的条件列表。见 可用条件。
遗留状态过滤器
字符串过滤器
仅显示房屋内的活动开关或灯。
type: entity-filter
entities:
- entity: light.bed_light
name: 床
- light.kitchen_lights
- light.ceiling_lights
state_filter:
- "on"
使用 glance 仅显示在家的人:
type: entity-filter
entities:
- device_tracker.demo_paulus
- device_tracker.demo_anne_therese
- device_tracker.demo_home_boy
state_filter:
- home
card:
type: glance
title: 在家的人
实体过滤结合了摘要卡。
您还可以指定多个 state_filter
条件,在这种情况下,如果实体匹配任何条件,则会显示该实体。
如果您将 state_filter
定义为对象而不是字符串,您可以为您的过滤器添加更多自定义,如下所述。
操作符过滤器
测试实体状态是否与应用的 operator
相符。
示例
显示所有在家或在工作的人。
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
card:
type: glance
title: 谁在工作或家中
为单个实体指定过滤器。
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
card:
title: "未来 7 天的假期"
show_header_toggle: false
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