Template fan not working

Hi, i’m trying to create a fan template based on a broadlink controled fan. I added this to my configuration.yaml

#Ventilador salon
fan:
  - platform: template
    fans:
      salon_fan:
        unique_id: salon_fan
        friendly_name: "Ventilador salon"
        value_template: "{{ states('input_boolean.salon_fan_state') }}"
        percentage_template: "{{ states('input_number.salon_fan_percentage') }}"
        oscillating_template: "{{ states('input_select.salon_fan_osc') }}"
        direction_template: "{{ states('input_select.salon_fan_ver') }}"
        turn_on:
          service: script.salon_fan_on
        turn_off:
          service: script.salon_fan_off
        set_percentage:
          service: script.salon_fan_set_speed
          data:
            percentage: "{{ percentage }}"
        set_oscillating:
          service: script.ventilador_salon_der_iz
          data:
            oscillating: "{{ oscillating }}"
        set_direction:
          service: script.ventilador_salon_arriba_abajo
          data:
            direction: "{{ direction }}"
        speed_count: 5

I created all the inputs and the scripts needed. The turn on one is:

alias: salon_fan_on
sequence:
  - service: remote.send_command
    data:
      command: >-
        b64:
        JgBoAAABJJITExITEhMSExIUEhMSExI4EhMSOBI4EjgSOBITEjgSOBITEhMSExITExMSExITEhMSOBI4EjgSOBI4EjgSOBI3EwAFQgABJUoSAAxYAAElShIADFgAASVKFAAMVgABJUsUAA0F
    target:
      device_id: 8fb56f4295283dfe28147434ddc6c438
  - service: input_boolean.turn_on
    target:
      entity_id: input_boolean.salon_fan_state
    data: {}
  - service: input_number.set_value
    target:
      entity_id: input_number.salon_fan_percentage
    data:
      value: 20
mode: single
icon: mdi:fan

If i run the script works great but with the fan device created i get:

“The service script.salon_fan_on has call the service fan.turn_on that has not been found”

The same with the rest of the device buttons.

if i call the service fan.turn_on of the fan device in developers tools i get:

Service script.salon_fan_on not found.

but the service exist

Any help will be appreciated

1 Like

Your YAML doesn’t look correct, see if this helps:

#Ventilador salon
fan:
  - platform: template
    fans:
      salon_fan:
        unique_id: salon_fan
        friendly_name: "Ventilador salon"
        value_template: "{{ states('input_boolean.salon_fan_state') }}"
        percentage_template: "{{ states('input_number.salon_fan_percentage') }}"
        oscillating_template: "{{ states('input_select.salon_fan_osc') }}"
        direction_template: "{{ states('input_select.salon_fan_ver') }}"
        turn_on:
          - service: script.salon_fan_on
        turn_off:
          - service: script.salon_fan_off
        set_percentage:
          - service: script.salon_fan_set_speed
            data:
              percentage: "{{ percentage }}"
        set_oscillating:
          - service: script.ventilador_salon_der_iz
            data:
             oscillating: "{{ oscillating }}"
        set_direction:
           - service: script.ventilador_salon_arriba_abajo
             data:
               direction: "{{ direction }}"
        speed_count: 5

You also don’t need scripts for that, you can issue the commands directly under the action just like a script sequence.

Thanks for your reply but the problem remains.

i was following the official info from here:

https://www.home-assistant.io/integrations/fan.template/

and this guide:
https://community.home-assistant.io/t/guide-template-fan-and-broadlink/323488

but no luck. I will continue trying

I have gotten it to work. I don’t know why but the id and name were not the same and there was no way to change them. I created the script again and it works now. Thank you

it’s complaining that it can’t find this script. did you implement it in the ui? or in scripts.yaml directly?

can you check that it’s loaded properly and that the script name is what you expect… go to your scripts page, find it, hit the 3 dots on the right and hit show settings… what does that show?

The problem was the id of the scripts. I don’t know why HA gave me numbers instead of the name I gave him. There is no way to change those numbers so delete the scripts and create them again and it works. Thanks

in that settings page, you should be able to change it to a friendly name.

Yes. I change it there but even restarting HA the service was using the old id. Very strange :sweat_smile:

that is a bit strange. but i’ve seen it happen before. if you want to solve it, what i’d do is to copy the script to notepad for temporary safe keeping. then use the ui to delete the script. so clear it uot of the system… and use the UI to do so… which updates the caches and such.

then create a new script with the UI and paste in your yaml EXCEPT for the alias: line where you specify the name.

use the ui, not the yaml, to specify the name.

1 Like