本帖最后由 gmshiwoge 于 2021-5-4 13:17 编辑
sensor:
- platform: template
sensors:
fan_speeds:
value_template: >
{% if states('switch.fanlow') == 'unavailable' %}
unavailable
{% elif states('switch.fanfast') == 'on' %}
高速
{% elif states('switch.fanmid') == 'on' %}
中速
{% elif states('switch.fanlow') == 'on' %}
低速
{% else %}
关闭
{% endif %}
fan: #建立一个fan元件
- platform: template
fans:
fan_speed:
value_template: >
{% if is_state("sensor.fan_speeds", "unavailable") %}
off
{% elif states('sensor.fan_speeds') == '关闭' %}
off
{% else %}
on
{% endif %}
speed_template: '{{ states("sensor.fan_speeds") }}'
turn_on:
- service: switch.turn_on
entity_id: switch.fanlow
turn_off:
- service: switch.turn_off
entity_id: switch.fanlow
- service: switch.turn_off
entity_id: switch.fanmid
- service: switch.turn_off
entity_id: switch.fanfast
set_speed:
- service: switch.turn_on
data_template:
entity_id: >
{% if speed == '低速' %}
switch.fanlow
{% elif speed == '中速' %}
switch.fanmid
{% elif speed == '高速' %}
switch.fanfast
{% elif speed == '关闭' %}
switch.off
{% endif %}
speeds:
- '关闭'
- '低速'
- '中速'
- '高速'
上面是原本的设置,更新ha后 这个实体没有了 关闭 低俗 中速 高速等选项调节了
|