So i have a fan setup based on switches. switch.sonoff_100092da4f_2 is fan on and low speed. This switch is on no matter the speed of the fan.
switch.sonoff_100092da4f_3 is fan med speed
switch.sonoff_100092da4f_4 is fan high speed.
configuration.yaml
fan:
- platform: template
fans:
living_room_fan:
friendly_name: "Livingroom fan"
value_template: "{{ states('input_boolean.livingroom_fan_state') }}"
speed_template: "{{ states('input_select.livingroom_fan_speed') }}"
turn_on:
service: script.living_fan_on
turn_off:
service: script.living_fan_off
set_speed:
service: script.livingroom_fan_set_speed
data_template:
speed: "{{ speed }}"
speeds:
- '1'
- '2'
- '3'
scripts:
livingroom_fan_set_speed:
alias: Livingroom Fan Set Speed
sequence:
- service: input_select.select_option
data_template:
entity_id: input_select.livingroom_fan_speed
option: '{{speed}}'
- service: script.turn_on
data_template:
entity_id: script.livingroom_fan_speed_{{ speed }}
living_fan_off:
alias: Livingroom Fan Off
sequence:
- service: switch.turn_off
data:
entity_id:
- service: input_boolean.turn_off
data:
entity_id: input_boolean.livingroom_fan_state
living_fan_on:
alias: Livingroom Fan Off
sequence:
- service: input_boolean.turn_on
data:
entity_id: input_boolean.livingroom_fan_state
- delay:
seconds: 1
- service_template: >
{% if is_state("input_select.livingroom_fan_speed", "1") %}
script.living_fan_1
{% elif is_state("input_select.bedroom_fan_speed", "2") %}
script.living_fan_2
{% elif is_state("input_select.bedroom_fan_speed", "3") %}
script.living_fan_3
{% endif %}
living_fan_1:
alias: Living Fan Speed 1
sequence:
- service: switch.turn_on
data:
entity_id: switch.sonoff_100092da4f_2
living_fan_2:
alias: Living Fan Speed 2
sequence:
- service: switch.turn_on
data:
entity_id: switch.sonoff_100092da4f_3
living_fan_3:
alias: Living Fan speed 3
sequence:
- service: switch.turn_off
data:
entity_id: switch.sonoff_100092da4f_3
- service: switch.turn_on
data:
entity_id: switch.sonoff_100092da4f_4