本帖最后由 zgxman 于 2024-4-29 19:18 编辑
我原来自定义了时间和日期的传感器,今天我又加了一个自定义开灯数量的传感器,结果就发现,时间和日期的传感器就没有办法使用了,请各位大佬帮我看一下,是哪里出了问题?
sensor:
- platform: time_date
display_options:
- 'time'
- 'date'
- 'date_time'
- 'time_date'
- 'time_utc'
- 'beat'
- platform: template
sensors:
numb_light_on:
friendly_name: 开灯数量
value_template: >-
{% set light = [
states.light.bi_deng_2,
states.light.can_ting_deng,
states.light.unknown_channel_2_2,
states.light.b850d817dbf3_light,
states.light.ke_ting_deng,
states.light.unknown_channel_2,
states.light.ci_wo_deng_switch,
states.light.she_deng_switch,
states.light.hyd_pro_1e10_light,
] %}
{% set light_on = light | selectattr('state','eq','on') | list %}
{{ light_on | length }}
attribute_templates:
lights_on: >-
{% set light = [
states.light.bi_deng_2,
states.light.can_ting_deng,
states.light.unknown_channel_2_2,
states.light.b850d817dbf3_light,
states.light.ke_ting_deng,
states.light.unknown_channel_2,
states.light.ci_wo_deng_switch,
states.light.she_deng_switch,
states.light.hyd_pro_1e10_light,
] %}
{% set light_on = light | selectattr('state','eq','on') | map(attribute='name') | list %}
{{ light_on | join(', ') }}
|