各位大佬这个fan风扇代码是不是不能用在新版HA了?求新代码,谢谢。
已参考过这帖子也是无法解决。论坛上有关FAN的帖子都已看过。
https://bbs.hassbian.com/thread-12854-1-1.html
配置无效
Invalid config for [fan.template]: [speed_template] is an invalid option for [fan.template]. Check: fan.template->fans->fan_speed->speed_template. (See ?, line ?).
sensor:
- platform: template
sensors:
fan_speeds:
value_template: >
{% if states('switch.fanlow') == 'unavailable' %}
unavailable
{% elif states('switch.fanfast') == 'on' %}
100
{% elif states('switch.fanmid') == 'on' %}
66
{% elif states('switch.fanlow') == 'on' %}
33
{% else %}
Off
{% 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") }}'
percentage_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_percentage:
service: >
{% if percentage == 33 %}
script.luodi_fan_percentage_33
{% elif percentage == 66 %}
script.luodi_fan_percentage_66
{% elif percentage == 100 %}
script.luodi_fan_percentage_100
{% else %}
script.dining_fan_off
{% endif %}
speed_count: 3
speeds:
- '关闭'
- '低速'
- '中速'
- '高速'
复制代码