Run script based on slider percentage

Automation Basics
UI Automation Editor
Automation YAML

There are many ways to do what you want in an automation. Based on what you have posted, one way to do it would be something like the following… (make sure you insert the values for the commands in the variables section)

trigger:
  - platform: state
    entity_id: input_number.fan_slider
    for: "00:00:02"
condition: []
action:
  - variables:
      vol_level: "{{ trigger.to_state.state | float(0) }}"
      command: >
        {% if vol_level == 0 %}
        
        {% elif vol_level > 80 %}
          6
        {% elif vol_level < 40 %}
        
        {% else %}
        
        {% endif %}
  - service: remote.send_command
    data:
      device: cigar_fan
      command: "{{ command }}"
    target:
      entity_id: remote.wi_fi_universal_remote_remote