GE fan switch speed setting

I have the GE Enbrighten Z-wave fan speed controller operating in HA and Homekit. I have not yet upgraded to the JS integration. I have seen remarks in other threads about being able to make the percentage speed control “snap” to certain percentages to mimic a low-med-high setting. However, I have not seen any instruction for actually accomplishing this. Does anyone have instructions to get this to work?

I use a fan template. fan.family_room_ceiling is the fan entity from the zwave_js integration. You can adjust the percentage ranges based on your fan. This one is for a Homeseer, I think the GEs can be slightly different. The UI percentage speed scale will snap to 0/33/67/100.

fan:
  - platform: template
    fans:
      family_room_3_speed:
        friendly_name: "Family Room 3 Speed"
        value_template: >-
          {{ states('fan.family_room_ceiling') }}
        percentage_template: >-
          {% if state_attr('fan.family_room_ceiling', 'percentage') > 66  %}
            100
          {% elif state_attr('fan.family_room_ceiling', 'percentage') > 33 %}
            66
          {% elif state_attr('fan.family_room_ceiling', 'percentage') > 0 %}
            33
          {% else %}
            0
          {% endif %}
        availability_template: >-
          {{ not is_state('fan.family_room_ceiling', 'unavailable') }}
        turn_on:
          - service: fan.turn_on
            data:
              entity_id: fan.family_room_ceiling
        turn_off:
          service: fan.turn_off
          data:
            entity_id: fan.family_room_ceiling
        set_percentage:
          - service: fan.set_percentage
            data_template:
              entity_id: fan.family_room_ceiling
              percentage: >-
                {% if percentage > 66 %}
                  100
                {% elif percentage > 33 %}
                  50
                {% elif percentage > 0 %}
                  3
                {% else %}
                  0
                {% endif %}
        speed_count: 3

Thank you for the template. I have copied your information into the template tool and adjusted for my entity. However, I get the following error:

UndefinedError: ‘percentage’ is undefined

I’m not a programmer, I am not sure what it needs.

The YAML code I posted is not intended for the template tool, it goes into your configuration.yaml file.

The fan template docs are here.

Works like a champ! Thank you!