King Of Fans MR101Z missing MAX setting

I’m new to Home Assistant (started migrating from SmartThings last week) and I just wrote the following template fan.
It creates a new template fan that has four speeds (25, 50, 75, 100) and two preset modes (auto, smart).
The original fan has 3 speeds (33, 66, 100) and three preset modes (on, auto, smart).
The code maps (33, 66, 100, on, auto, smart) to (25, 50, 75, 100, auto, smart).
Advantages of this template fan compared to the one @flyize provided in 15 are:

  • simpler and easier to setup. No scripts and input helpers are needed
  • most importantly the states of the template and real fans are synced

Add the following to /config/configuration.yaml and replace foo with your fan name.

fan:
  - platform: template
    fans:
      foo_fan:
        friendly_name: "foo fan"
        unique_id: "foo_fan"
        value_template: "{{ states('fan.foo') }}"
        percentage_template: >
          {% if is_state_attr('fan.foo', 'preset_mode', 'on') %}
            100
          {% else %}
            {{ (state_attr('fan.foo', 'percentage') * 3 / 4) | round}}
          {% endif %}
        preset_mode_template: >
          {% if is_state_attr('fan.foo', 'preset_mode', 'on') %}
            None
          {% else %}
            {{state_attr('fan.foo', 'preset_mode')}}
          {% endif %}
        turn_on:
          service: fan.turn_on
          entity_id: fan.foo
        turn_off:
          service: fan.turn_off
          entity_id: fan.foo
        set_percentage:
          if:
            condition: template
            value_template: "{{ percentage == 100 }}"
          then:
            service: fan.set_preset_mode
            target:
              entity_id: fan.foo
            data:
              preset_mode: 'on'
          else:
            service: fan.set_percentage
            target:
              entity_id: fan.foo
            data_template:
              percentage: "{{ (percentage * 4 / 3) | int }}"
        set_preset_mode:
          service: fan.set_preset_mode
          target:
            entity_id: fan.foo
          data_template:
            preset_mode: "{{ preset_mode }}"
        speed_count: 4
        preset_modes:
          - 'auto'
          - 'smart'
3 Likes