Changing domain from light. to fan

hey just create a file called fan.yaml in ur config dir and in ur configuration.yaml put:
fan: !include fan.yaml

Hi @pedzp14 Thanks for the quick reply! It’s working now.
Keep up the good work!

Hi guys,

please help me.

I have Qubino dimmer 0-10V. I dont know, how to edit code.
The switch ON / OFF works correct.
But speed of fan doesnt work.

I am using qubino as controler Zehnder Q350 with Option box.

When i am using as light speed of fan works correct, but in homekit show dimmer light.

2 Likes

Im lost! I have tried this I feel like a million ways. I’m sure its something simple i am over looking here.

I have a Leviton wifi fan controller that shows up as a light and not a fan. so i tried to wrap fan config around it but I can only turn on/off the fan I cannot set any speed using the brightness. If I change the brightness of the light it does work but trying to change it on the fan entity fails.

this is my current config:

fan:
  - platform: template
    fans:
      bedroom:
        friendly_name: "Bedroom Fan"
        value_template: "{{ states('light.bedroom_fan') }}"
        speed_template: >
          {% set output = {0: 'off', 50: 'low', 128: 'medium', 255: 'high'} %}
          {% set idx = state_attr('light.bedroom_fan', 'brightness') %}
          {{ output[idx] }}
        turn_on:
          service: homeassistant.turn_on
          entity_id: light.bedroom_fan
        turn_off:
          service: homeassistant.turn_off
          entity_id: light.bedroom_fan
        set_speed:
          service: light.turn_on
          entity_id: light.bedroom_fan
          data_template:
            brightness: >
              {% set mapper = {'off' : 0, 'low': 50, 'medium': 128, 'high': 255} %}
              {{ mapper[speed] }}
        speeds:
          - 'off'
          - 'low'
          - 'medium'
          - 'high'

You’re lost because this thread is 2 years old and there have been changes to template fan. set_speed and speeds has been deprecated. You should use the examples in the documentation page.

You have a choice, use set_preset_modes with a list of presets or set_percentage with percentages 0, 33, 66, 100 mapped to light brightness.

Hi Petro, documentation page for what? Fans??

I was replying to the guy who was using a template, so it would be the template fan docs

1 Like

Thank you !

did you get this figured out? i am looking at the fan template page and see the changes from set_speed to set_percentage… tried changing the word speed to percentage in my config… it did not work… there is mroe to change i dunno what.

fan:
  -  platform: template
     fans:
      bath_fan_2:
        friendly_name: "Bath Fan"
        unique_id: 3dkhfk644vdg
        value_template: "{{ states('light.bath_fan') }}"
        percentage_template: >
          {% set output = {0: 'off', 50: 'low', 128: 'medium', 255: 'high'} %}
          {% set idx = state_attr('light.bath_fan', 'brightness') %}
          {{ output[idx] }}
        turn_on:
          service: homeassistant.turn_on
          entity_id: light.bath_fan
        turn_off:
          service: homeassistant.turn_off
          entity_id: light.bath_fan
        set_percentage:
          service: light.turn_on
          entity_id: light.bath_fan
          data_template:
            brightness: >
              {% set mapper = {'off' : 0, 'low': 50, 'medium': 128, 'high': 255} %}
              {{ mapper[speed] }}
        speed_count: 3

sorry man, I did not have any success, seems like it should be easier but I am lost

I am also here from the year 2022 trying to use the latest version of HA and not having much luck. It looks like low/med/high speeds are automatically calculated but I’m not even messing with that, I just want to convert to/from the number values. I think my fan entity is converting from the switch’s 255 value to the fan’s percentage correctly but when I set the percentage on the fan it doesn’t update my switch.

Edit: This works!

fan:
  - platform: template
    fans:
      living_room_fan:
        friendly_name: "Living Room Fan"
        value_template: "{{ states('light.living_room_fan_switch') }}"
        percentage_template: >
          {{ (state_attr('light.living_room_fan_switch', 'brightness') / 255 * 100) | int }}
        turn_on:
          service: homeassistant.turn_on
          entity_id: light.living_room_fan_switch
        turn_off:
          service: homeassistant.turn_off
          entity_id: light.living_room_fan_switch
        set_percentage:
          service: light.turn_on
          entity_id: light.living_room_fan_switch
          data_template:
            brightness: >
              {{ ( percentage / 100 * 255) | int }} 
        speed_count: 3 
1 Like

data_template is deprecated, set percentage passes a percentage variable when used. And 255 is already an int. You need to apply int to the entire expression.

        set_percentage:
          service: light.turn_on
          entity_id: light.living_room_fan_switch
          data:
            brightness: >
              {{ (percentage / 100 * 255) | int }} 
1 Like

That did the trick, thank you! Edited my post to have the final working yaml.

This works great for me using the mushroom card, thanks.
image

i got this to work, it works fine for cards but i want to use this now to make an automation to increase the fan speed to 100% when the humidity in the bathroom is increasing. I only seem to be able to select on/off and not the states