Upgrade SpeedFan from 3 speeds to n speeds

I have previously created a fan with a pushbutton to alternate between 3 speeds (low, medium, high). Now with the new update I need to change this in order to modify the code, because individual speeds are deprecated.

This is my project:

And here:

This is my current configuration/code. I need to change speed to speed_count and remove low, medium, high. But as I understand I will only be able to define how many steps there will be between off and maximum, so 3 will mean 33%, 66%, 100%.

How should I modify: call.set_speed(FAN_SPEED_LOW); according to the new features?
Also this: if (id(${hostid}_fan).speed == FAN_SPEED_LOW)

Thanks for support!

# Pinning
# D1 - Button
# D2 - RPM meeter
# D3 - PWM pulse

substitutions:
  hostid: fireplace_fan
  hostname: Fireplace Fan
  comment: Fireplace fan controller
  node_platform: ESP8266
  node_board: d1_mini

packages:
  core: !include common/core.yaml
  basic_sensors: !include common/basic_sensors.yaml

sensor:
  - platform: pulse_counter
    pin: 
      number: D2
      mode: INPUT_PULLUP
    unit_of_measurement: 'RPM'
    accuracy_decimals: 0 
    id: ${hostid}_speed
    name: ${hostname} Speed
    filters:
      - multiply: 0.5

fan:
  - platform: speed
    id: ${hostid}_fan
    name: ${hostname}
    output: ${hostid}_fan_speed
    speed:
      low: 0.35
      medium: 0.6
      high: 1

output:
  - platform: esp8266_pwm
    pin: D3
    frequency: 25000 Hz
    id: ${hostid}_fan_speed

binary_sensor:
  - platform: gpio
    pin: 
      number: D1
      mode: INPUT_PULLUP
      inverted: True
    id: ${hostid}_button
    name: ${hostname} Button
    on_multi_click:
    - timing:
        - ON for at most 0.2s
        - OFF for at most 0.2s
        - ON for at most 0.2s
        - OFF for at least 0.2s
      then:
        - logger.log: "Double Clicked"
        - lambda: |-
            auto call = id(${hostid}_fan).make_call();
            if (!id(${hostid}_fan).state) {
              call.set_state(true);
              call.set_speed(FAN_SPEED_HIGH);
            } else if (id(${hostid}_fan).speed == FAN_SPEED_LOW) {
              call.set_state(false);
            } else if (id(${hostid}_fan).speed == FAN_SPEED_MEDIUM) {
              call.set_speed(FAN_SPEED_LOW);
            } else if (id(${hostid}_fan).speed == FAN_SPEED_HIGH) {
              call.set_speed(FAN_SPEED_MEDIUM);
            }
            call.perform();
        - script.execute: ${hostid}_auto_off
    - timing:
        - ON for at least 1s
      then:
        - logger.log: "Single Long Clicked"
        - lambda: |-
            auto call = id(${hostid}_fan).make_call();
            call.set_state(false);
            call.set_speed(FAN_SPEED_LOW);
            call.perform();
        - script.stop : ${hostid}_auto_off
    - timing:
        - ON for at most 0.4s
        - OFF for at least 0.4s
      then:
        - logger.log: "Single Short Clicked"
        - lambda: |-
            auto call = id(${hostid}_fan).make_call();
            if (!id(${hostid}_fan).state) {
              call.set_state(true);
              call.set_speed(FAN_SPEED_LOW);
            } else if (id(${hostid}_fan).speed == FAN_SPEED_LOW) {
              call.set_speed(FAN_SPEED_MEDIUM);
            } else if (id(${hostid}_fan).speed == FAN_SPEED_MEDIUM) {
              call.set_speed(FAN_SPEED_HIGH);
            } else if (id(${hostid}_fan).speed == FAN_SPEED_HIGH) {
              call.set_state(false);
            }
            call.perform();
        - script.execute: ${hostid}_auto_off

script:
  - id: ${hostid}_auto_off
    mode: restart
    then:
      - delay: 18000s # 5h
      - fan.turn_off: ${hostid}_fan# Pinning
# D1 - Button
# D2 - RPM meeter
# D3 - PWM pulse

substitutions:
  hostid: fireplace_fan
  hostname: Fireplace Fan
  comment: Fireplace fan controller
  node_platform: ESP8266
  node_board: d1_mini

packages:
  core: !include common/core.yaml
  basic_sensors: !include common/basic_sensors.yaml

sensor:
  - platform: pulse_counter
    pin: 
      number: D2
      mode: INPUT_PULLUP
    unit_of_measurement: 'RPM'
    accuracy_decimals: 0 
    id: ${hostid}_speed
    name: ${hostname} Speed
    filters:
      - multiply: 0.5

fan:
  - platform: speed
    id: ${hostid}_fan
    name: ${hostname}
    output: ${hostid}_fan_speed
    speed:
      low: 0.35
      medium: 0.6
      high: 1

output:
  - platform: esp8266_pwm
    pin: D3
    frequency: 25000 Hz
    id: ${hostid}_fan_speed

binary_sensor:
  - platform: gpio
    pin: 
      number: D1
      mode: INPUT_PULLUP
      inverted: True
    id: ${hostid}_button
    name: ${hostname} Button
    on_multi_click:
    - timing:
        - ON for at most 0.2s
        - OFF for at most 0.2s
        - ON for at most 0.2s
        - OFF for at least 0.2s
      then:
        - logger.log: "Double Clicked"
        - lambda: |-
            auto call = id(${hostid}_fan).make_call();
            if (!id(${hostid}_fan).state) {
              call.set_state(true);
              call.set_speed(FAN_SPEED_HIGH);
            } else if (id(${hostid}_fan).speed == FAN_SPEED_LOW) {
              call.set_state(false);
            } else if (id(${hostid}_fan).speed == FAN_SPEED_MEDIUM) {
              call.set_speed(FAN_SPEED_LOW);
            } else if (id(${hostid}_fan).speed == FAN_SPEED_HIGH) {
              call.set_speed(FAN_SPEED_MEDIUM);
            }
            call.perform();
        - script.execute: ${hostid}_auto_off
    - timing:
        - ON for at least 1s
      then:
        - logger.log: "Single Long Clicked"
        - lambda: |-
            auto call = id(${hostid}_fan).make_call();
            call.set_state(false);
            call.set_speed(FAN_SPEED_LOW);
            call.perform();
        - script.stop : ${hostid}_auto_off
    - timing:
        - ON for at most 0.4s
        - OFF for at least 0.4s
      then:
        - logger.log: "Single Short Clicked"
        - lambda: |-
            auto call = id(${hostid}_fan).make_call();
            if (!id(${hostid}_fan).state) {
              call.set_state(true);
              call.set_speed(FAN_SPEED_LOW);
            } else if (id(${hostid}_fan).speed == FAN_SPEED_LOW) {
              call.set_speed(FAN_SPEED_MEDIUM);
            } else if (id(${hostid}_fan).speed == FAN_SPEED_MEDIUM) {
              call.set_speed(FAN_SPEED_HIGH);
            } else if (id(${hostid}_fan).speed == FAN_SPEED_HIGH) {
              call.set_state(false);
            }
            call.perform();
        - script.execute: ${hostid}_auto_off

script:
  - id: ${hostid}_auto_off
    mode: restart
    then:
      - delay: 18000s # 5h
      - fan.turn_off: ${hostid}_fan

Bump! Anyone?

The speeds are numbered (starting from zero for LOW), so replace FAN_SPEED_LOW with 0, FAN_SPEED_MEDIUM with 1 etc.