decluttering_templates:
std_room_card: #Decluttering Card 模板
default: #所有变量的默认值
- area_name: none #区域名称,用于灯具判断,灯实体的位置必须对应,隐藏的实体不计入
- area_friendly_name: 默认房间 #区域别称,即卡片标题
- cover_name: 窗帘 #窗帘别称
- cover_entity: none # 窗帘的cover实体
- climate_name: 中央空调 #空调别称
- climate_entity: none #空调的climate实体
- icon: mdi:help #显示图标
- appliance_string: none #设备列表字符串,格式为"switch.xxx,media_player.xxx,fan.xxx"
- script_entity: none #该区域对应的功能(如一键关闭该区域所有设备)脚本,长按卡片执行
- navigation_path: /lovelace/home #导航路径,单击卡片执行
card:
type: custom:mushroom-template-card
primary: '[[area_friendly_name]]'
secondary: |-
{% set light_list=
expand(states.light)
|selectattr('entity_id', 'in', area_entities('[[area_name]]'))
|map(attribute='entity_id')
|reject('is_hidden_entity')
|list
%}
{% set lights_ns=namespace(number=0) %} {% for entity in light_list %}
{% if states(entity) not in ['off', 'unknown', 'unavailable', 'None'] %}
{% set lights_ns.number=lights_ns.number+1 %}
{% endif %}
{% endfor %}
{% set appliance_string='[[appliance_string]]' %}
{% set appliances_ns=namespace(number=0) %} {% for entity in
appliance_string.split(",") %}
{% if states(entity) not in ['off', 'unknown', 'unavailable', 'None', 'standby', 'paused', 'idle', 'not_home'] %}
{% set appliances_ns.number=appliances_ns.number+1 %}
{% endif %}
{% endfor %}
{% set climate=states('[[climate_entity]]') %} {% if climate not in
['off', 'unknown', 'unavailable', 'None'] %}
{% if climate=='cool' %}{% set climate_status='制冷' %}
{% elif climate=='heat' %}{% set climate_status='制热' %}
{% elif climate=='dry' %}{% set climate_status='除湿' %}
{% elif climate=='fan_only' %}{% set climate_status='送风' %}
{% else %}{% set climate_status='打开' %}
{% endif %}
{% endif %}
{% set curtain=states('[[cover_entity]]') %} {% if curtain not in
['off', 'unknown', 'unavailable', 'None'] %}
{% if curtain=='open' %}{% set curtain_status='已打开' %}
{% elif curtain=='closed' %}{% set curtain_status='已合上' %}
{% else %}{% set curtain_status='未知' %}
{% endif %}
{% endif %}
{% if lights_ns.number==0 and appliances_ns.number==0 and
(climate_status is not defined) %} {% set all_off=true %} {% else %}{%
set all_off=false %} {% endif %}
{% set script_status=is_state('[[script_entity]]','on') %}
{% if script_status %}正在关闭中...{% else %}
{{'[[cover_name]]'+curtain_status if curtain_status is defined}}{% if
all_off %}
已关闭{% else %}{% if lights_ns.number!=0 %}
{{lights_ns.number}}盏灯亮着{% endif %}{% if appliances_ns.number!=0 %}
{{appliances_ns.number}}个设备打开{% endif %}{% endif %}
{{'[[climate_name]]'+climate_status if climate_status is defined}} {%
endif %}
icon: '[[icon]]'
icon_color: >-
{% set light_list=
expand(states.light)
|selectattr('entity_id', 'in', area_entities('[[area_name]]'))
|map(attribute='entity_id')
|reject('is_hidden_entity')
|list
%}
{% set lights_ns=namespace(number=0) %} {% for entity in light_list %}
{% if states(entity) not in ['off', 'unknown', 'unavailable', 'None'] %}
{% set lights_ns.number=lights_ns.number+1 %}
{% endif %}
{% endfor %}
{% set appliance_string='[[appliance_string]]' %}
{% set appliances_ns=namespace(number=0) %} {% for entity in
appliance_string.split(",") %}
{% if states(entity) not in ['off', 'unknown', 'unavailable', 'None', 'standby', 'paused', 'idle', 'not_home'] %}
{% set appliances_ns.number=appliances_ns.number+1 %}
{% endif %}
{% endfor %}
{% set climate=states('[[climate_entity]]') %} {% if climate not in
['off', 'unknown', 'unavailable', 'None'] %}
{% if climate=='cool' %}{% set climate_status='制冷' %}
{% elif climate=='heat' %}{% set climate_status='制热' %}
{% elif climate=='dry' %}{% set climate_status='除湿' %}
{% elif climate=='fan_only' %}{% set climate_status='送风' %}
{% else %}{% set climate_status='打开' %}
{% endif %}
{% endif %}
{% set curtain=states('[[cover_entity]]') %} {% if curtain not in
['off', 'unknown', 'unavailable', 'None'] %}
{% if curtain=='open' %}{% set curtain_status='已打开' %}
{% elif curtain=='closed' %}{% set curtain_status='已合上' %}
{% else %}{% set curtain_status='未知' %}
{% endif %}
{% endif %}
{% if lights_ns.number==0 and appliances_ns.number==0 and
(climate_status is not defined) %} {% set all_off=true %} {% else %}{%
set all_off=false %} {% endif %}
{% set script_status=is_state('[[script_entity]]','on') %}
{% if script_status %}orange {% elif climate_status is defined %}green
{% elif appliances_ns.number!=0 %}blue {% endif %}
badge_icon: |-
{% set light_list=
expand(states.light)
|selectattr('entity_id', 'in', area_entities('[[area_name]]'))
|map(attribute='entity_id')
|reject('is_hidden_entity')
|list
%}
{% set lights_ns=namespace(number=0) %} {% for entity in light_list %}
{% if states(entity) not in ['off', 'unknown', 'unavailable', 'None'] %}
{% set lights_ns.number=lights_ns.number+1 %}
{% endif %}
{% endfor %}
{{ 'mdi:ceiling-light-outline' if lights_ns.number>0 }}
badge_color: |-
{% set light_list=
expand(states.light)
|selectattr('entity_id', 'in', area_entities('[[area_name]]'))
|map(attribute='entity_id')
|reject('is_hidden_entity')
|list
%}
{% set lights_ns=namespace(number=0) %} {% for entity in light_list %}
{% if states(entity) not in ['off', 'unknown', 'unavailable', 'None'] %}
{% set lights_ns.number=lights_ns.number+1 %}
{% endif %}
{% endfor %}
{{ 'orange' if lights_ns.number>0 }}
multiline_secondary: true
fill_container: true
tap_action:
action: navigate
navigation_path: '[[navigation_path]]'
hold_action:
action: call-service
service: script.turn_on
data: {}
target:
entity_id: '[[script_entity]]'
double_tap_action:
action: none
layout: horizontal
···