Combine two switches into one fan with high/low/off on dashboard

I have two switches that control a fan and its speed, one for on/off and the other for high/low. How can I combine these two switches so they will show up on a dashboard with options high/low/off instead of two separate switches?

Using fan-percent-button-row for my other fans and they look like this
image

This is how I currently have the two switches on the dashboard, with the speed on=high and off=low
image

Looks like I can use isTwoSpeedFan to remove the MED option on dashboard.

you can use a template fan. something like this:

fan:
  - platform: template
    fans:
      combined_fan: 
        preset_modes:
          - "Off"
          - "Low"
          - "High"
        preset_mode_template: >
          {% if is_state('switch.fan_power', 'off') %}
            Off
          {% elif is_state('switch.fan_speed', 'on') %}
            High
          {% else %}
            Low
          {% endif %}
        set_preset_mode:
          - choose:
              - conditions:
                  - condition: template
                    value_template: "{{ preset_mode == 'Off' }}"
                sequence:
                  - service: switch.turn_off
                    target:
                      entity_id: 
                        - switch.fan_power
                        - switch.fan_speed
              - conditions:
                  - condition: template
                    value_template: "{{ preset_mode == 'Low' }}"
                sequence:
                  - service: switch.turn_on
                    target:
                      entity_id: switch.fan_power
                  - service: switch.turn_off
                    target:
                      entity_id: switch.fan_speed
              - conditions:
                  - condition: template
                    value_template: "{{ preset_mode == 'High' }}"
                sequence:
                  - service: switch.turn_on
                    target:
                      entity_id: 
                        - switch.fan_power
                        - switch.fan_speed

goes in configuration.yaml

Looks like they changed the config options in the version of HA that I’m on

Invalid config for ‘template’ at configuration.yaml, line 429: ‘fan’ is an invalid option for ‘template’, check: fan

Template fan - Home Assistant doesn’t look to support all the same things either

Thanks for pointing me in the right direction @armedad . The below config works correctly when using the preset modes of the template fan, but not with the custom:fan-percent-button-row entity type. I think it’s because that tries to set the fan speeds, instead of using the preset modes and the speed switch doesn’t get updated. To be continued later…

fan:
  - platform: template
    fans:
        whole_house_fan_template:
          friendly_name: "Whole House Fan Template"
          turn_on:
            service: switch.turn_on
            target:
              entity_id: switch.whole_house_fan
          turn_off:
            service: switch.turn_off
            target:
              entity_id: 
                - switch.whole_house_fan
          preset_modes:
            - "Off"
            - "Low"
            - "High"
          preset_mode_template: >
            {% if is_state('switch.whole_house_fan', 'on') and is_state('switch.whole_house_fan_speed', 'on') %}
              High
            {% elif is_state('switch.whole_house_fan', 'on') and is_state('switch.whole_house_fan_speed', 'off') %}
              Low
            {% else %}
              Off
            {% endif %}
          set_preset_mode:
            - choose:
                - conditions:
                    - condition: template
                      value_template: "{{ preset_mode == 'Off' }}"
                  sequence:
                    - service: switch.turn_off
                      target:
                        entity_id: 
                          - switch.whole_house_fan
                - conditions:
                    - condition: template
                      value_template: "{{ preset_mode == 'Low' }}"
                  sequence:
                    - service: switch.turn_off
                      target:
                        entity_id: switch.whole_house_fan_speed
                    - service: switch.turn_on
                      target:
                        entity_id: switch.whole_house_fan
                - conditions:
                    - condition: template
                      value_template: "{{ preset_mode == 'High' }}"
                  sequence:
                    - service: switch.turn_on
                      target:
                        entity_id: 
                          - switch.whole_house_fan
                          - switch.whole_house_fan_speed
1 Like

Tried one last thing for the night. Created a new card like this and got a dropdown with presets that works correctly
image

features:
  - style: dropdown
    type: fan-preset-modes
type: tile
entity: fan.whole_house_fan_template
tap_action:
  action: none
icon_tap_action:
  action: none
show_entity_picture: false
vertical: false
hide_state: true

Figured it out. Had to use a different card type, fan-mode-button-row, for that fan to make it work as I wanted.

image

  - entity: fan.whole_house_fan_template
    type: **custom:fan-mode-button-row**
    twoModeFan: true
    name: Whole House Fan