Files
2026-08-24 21:55:33 +08:00

75 lines
3.2 KiB
YAML

- sensor:
# 迁移提示中的传感器
- name: "Livingroom Temp Color No RGB"
unique_id: "livingroom_temp_color_no_rgb"
state: >
{% set state = states('sensor.miaomiaoc_cn_blt_3_1ndt1bnq04c04_t1_temperature_p_2_1') | float(default=0) %}
{% if state >= 0 and state < 18 %}
blue
{% elif state >= 18 and state < 20 %}
yellow
{% elif state >= 20 and state < 23 %}
orange
{% elif state >= 23 and state < 50 %}
red
{% else %}
grey
{% endif %}
- sensor:
- name: "Lights of count"
unique_id: lights_of_count
state: >
{%- set main_group = 'light.quan_wu_zhao_ming' -%}
{%- set ns = namespace(lights=[]) -%}
{%- macro count_lights_recursive(entity_list) -%}
{%- for entity_id in entity_list -%}
{%- set entity_state = states[entity_id] -%}
{%- if entity_state -%}
{%- if 'entity_id' in entity_state.attributes -%}
{# 这是个子灯组,递归统计 #}
{%- set sub_count = count_lights_recursive(entity_state.attributes.entity_id) -%}
{%- elif entity_state.state == 'on' -%}
{# 这是单独的灯,且已打开 #}
{%- set ns.lights = ns.lights + [ entity_id ] -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- endmacro -%}
{%- set members = state_attr(main_group, 'entity_id') | default([]) -%}
{{- count_lights_recursive(members) -}}
{{ ns.lights| list | length }}
- sensor:
- name: "AirCondition of count"
unique_id: airbtns_of_count
state: >
{%- set acids = ['climate.qdhkl_cn_2113954983_b19c', 'climate.qdhkl_cn_2113955096_b19c', 'climate.qdhkl_cn_2113966364_b19c', 'climate.qdhkl_cn_2113955084_b19c'] -%}
{%- set ns = namespace(airbtns=[]) -%}
{%- for entity_id in acids -%}
{%- if states[entity_id].state != 'off' -%}
{%- set ns.airbtns = ns.airbtns + [ entity_id ] -%}
{%- endif -%}
{%- endfor -%}
{{ ns.airbtns| list | length }}
- sensor:
- name: "Water damage count"
unique_id: water_damage_count
state: >
{%- set main_group = 'binary_sensor.quan_wu_shui_jin_jian_ce' -%}
{%- set ns = namespace(waters=[]) -%}
{%- macro count_waters_recursive(entity_list) -%}
{%- for entity_id in entity_list -%}
{%- set entity_state = states[entity_id] -%}
{%- if entity_state -%}
{%- if 'entity_id' in entity_state.attributes -%}
{# 这是个子组,递归统计 #}
{%- set sub_count = count_waters_recursive(entity_state.attributes.entity_id) -%}
{%- elif entity_state.state == 'on' -%}
{# 这是单独的水浸传感器,且已预警 #}
{%- set ns.waters = ns.waters + [ entity_id ] -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- endmacro -%}
{%- set members = state_attr(main_group, 'entity_id') | default([]) -%}
{{- count_waters_recursive(members) -}}
{{ ns.waters| list | length }}