[HELP] New Template Fan integration - percentage

Hi!
I’ve used and tested using code from here and there and it is done. Thank you all for your help.

Here is my code:

###########################
# Ventilador Teto Quarto
###########################

input_boolean:
  quarto_fan_direction:
    name: Direcao ventilador quarto
  ventteto_quarto:
    name: Ventilador Teto Quarto

input_number:
  ventteto_quarto_percent:
    name: Vent Teto Quarto Percentage
    min: 0
    max: 100
    step: 1
    

###########################
# Ventilador Teto Quarto
###########################

fan:
  - platform: template
    fans:
      vent_teto_quarto:
        friendly_name: "Ventilador Quarto"
        value_template: "{{ states('input_boolean.ventteto_quarto') }}"
        percentage_template: "{{ states('input_number.ventteto_quarto_percent') | float }}"
        # Uses a fake switch from an input_boolean as the fan has no way of reporting direction back to HA
        direction_template: "{{ 'forward' if is_state('input_boolean.quarto_fan_direction', 'on') else 'reverse' }}"
        turn_on:
          service: script.ventteto_quarto_on
        turn_off:
          service: script.ventteto_quarto_off
        set_percentage:
          - service: script.ventteto_quarto_velocidade
            data:
              percentage: "{{ percentage }}"
        set_direction:
          - service: remote.send_command
            data:
              entity_id: remote.rmpro_remote
              command:
                - b64:sgYwABQvFA02DTYvFC+UHyQfJB8kHyQfJB8kHyMfIy8ULxMvFA02DTYvFC8TDTYNNg02LwAAAAAAAAAA
          - service: input_boolean.toggle
            entity_id: input_boolean.quarto_fan_direction
        speed_count: 5
        

script:

  ventteto_quarto_on:
    alias: Ligar ventteto_quarto
    sequence:
      - service: input_boolean.turn_on
        data:
          entity_id: input_boolean.ventteto_quarto
      - delay:
          milliseconds: 500
      - service: >
          {% if states("input_number.ventteto_quarto_percent") | int == 20 %}
            script.ventteto_quarto1
          {% elif states("input_number.ventteto_quarto_percent") | int == 40 %}
            script.ventteto_quarto2
          {% elif states("input_number.ventteto_quarto_percent") | int == 60 %}
            script.ventteto_quarto3
          {% elif states("input_number.ventteto_quarto_percent") | int == 80 %}
            script.ventteto_quarto4
          {% elif states("input_number.ventteto_quarto_percent") | int == 100 %}
            script.ventteto_quarto5
          {% else %}
            script.ventteto_quarto_off
          {% endif %}
      - service: >
          {% if states("input_number.ventteto_quarto_percent") | int == 20 %}
            input_boolean.turn_on
          {% elif states("input_number.ventteto_quarto_percent") | int == 40 %}
            input_boolean.turn_on
          {% elif states("input_number.ventteto_quarto_percent") | int == 60 %}
            input_boolean.turn_on
          {% elif states("input_number.ventteto_quarto_percent") | int == 80 %}
            input_boolean.turn_on
          {% elif states("input_number.ventteto_quarto_percent") | int == 100 %}
            input_boolean.turn_on
          {% else %}
            input_boolean.turn_off
          {% endif %}
        entity_id: input_boolean.ventteto_quarto


  ventteto_quarto_velocidade:
    alias: ventteto_quarto seta velocidade
    sequence:
      - service: input_number.set_value
        data:
          entity_id: input_number.ventteto_quarto_percent
          value: "{{ percentage }}"
      - delay:
          milliseconds: 600
      - service: script.turn_on
        entity_id: script.ventteto_quarto_on

1 Like

Fan toggle missing percentage has been fixed: