Need help with fan template with the new options

If you don’t get an answer here maybe ask on the templates channel of Home Assistant Discord

Why not?

So are you saying that going forward there will be no way to get the old functionality of using “set the speed to low/medium/high” using voice assistants and we have to use only percentages or other “non-speed-name” modes?

Alright,

Here is my setup that ive been using which, was provided a way back by (finity) for use with his fan entity row integration. It still does work but gives the nagging please remove speed from template message.

My fans are all ifan03’s.

- platform: template
  fans:
    groupfan:
      friendly_name: "Group Fan"
      value_template: >
        {% set s = states('input_boolean.group_fan_state') %}
        {{ s if s in ['on', 'off'] else 'off' }}
      speed_template: "{{ states('input_select.group_fan_set_speed') }}"
      turn_on:
        service: script.group_fan_on
      turn_off:
        service: script.group_fan_off
      set_speed:
        service: script.group_fan_set_speed
        data_template:
          speed: "{{ speed }}"
      speeds:
        - "low"
        - "medium"
        - "high"

input_boolean:

group_fan_state:
  name: All Fans

input_select:

group_fan_set_speed:
  options:
    - "low"
    - "medium"
    - "high"

scripts:

group_fan_off:
  sequence:
    - service: fan.turn_off
      entity_id:
        - fan.kitchen
        - fan.living
    - service: input_boolean.turn_off
      entity_id: input_boolean.group_fan_state
group_fan_on:
  sequence:
    - service: fan.turn_on
      entity_id:
        - fan.kitchen
        - fan.living
    - service: input_boolean.turn_on
      entity_id: input_boolean.group_fan_state
group_fan_set_speed:
  sequence:
    - service: fan.turn_on
      entity_id:
        - fan.kitchen
        - fan.living
    - service: input_boolean.turn_on
      entity_id: input_boolean.group_fan_state
    - service: fan.set_speed
      data_template:
        entity_id:
          - fan.kitchen
          - fan.living
        speed: "{{speed}}"
    - service: input_select.select_option
      data_template:
        entity_id: input_select.group_fan_set_speed
        option: "{{speed}}"

Okay. Now here is what I use for the fans. This is separate from above which just makes them all work as a group.

scripts:

kitchen_fan_off:
  sequence:
    - service: fan.turn_off
      data:
        entity_id: fan.kitchen
kitchen_fan_on:
  sequence:
    - service: fan.turn_on
      data:
        entity_id: fan.kitchen
    - delay:
        seconds: 1
    - service:
        '{% if is_state("input_select.kitchen_fan_speed", "low") %} script.kitchen_fan_low
        {% elif is_state("input_select.kitchen_fan_speed", "medium") %} script.kitchen_fan_medium
        {% else %} script.kitchen_fan_high {% endif %}'
kitchen_fan_low:
  sequence:
    - service: fan.turn_on
      data:
        entity_id: fan.kitchen
    - service: fan.set_speed
      data_template:
        entity_id: fan.kitchen
        speed: low
kitchen_fan_medium:
  sequence:
    - service: fan.turn_on
      data:
        entity_id: fan.kitchen
    - service: fan.set_speed
      data_template:
        entity_id: fan.kitchen
        speed: medium
kitchen_fan_high:
  sequence:
    - service: fan.turn_on
      data:
        entity_id: fan.kitchen
    - service: fan.set_speed
      data_template:
        entity_id: fan.kitchen
        speed: high
kitchen_fan_set_speed:
  sequence:
    - service: input_select.select_option
      data_template:
        entity_id: input_select.kitchen_fan_speed
        option: "{{ speed }}"
    - service: script.turn_on
      data_template:
        entity_id: script.kitchen_fan_{{ speed }}

Now my question is will the fan scripts still be okay with the current method? They dont seem to be causing any errors as is.

And is it as easy as just changing the set speed to set_percentage and changing the off, low. medium, high to 0, 33, 66, 100 in the template group fan?

interestingly, the mqtt fans (which is what In use for my iFan03’s) still use the old speed settings according to the docs.

But they also still throw the nag error every time I change the speed.

It would be nice to get answers on how to update the fans to use a possible speed setting (using preset modes per the question above?) instead of needing to use percentages.

And any updated examples to update the mqtt fans to the new settings.

EDIT:

Oh, and as an FYI I just created a new fan entity row that uses percents to control the fans using the new method. It should be available in HACS soon but you can go to my github now to install it manunally.

Maybe that will work with your existing template fans using percents? I tested on my template fans and it works fine.

And once I fully figure out how the modes are supposed to work IOW, get some questions answered) I’ll create one for controlling fans using preset modes.

1 Like

Nice. I’ll check it out here maybe tonight. Thanks for your work. Without it, my setup would be trash. lol

As a side note, I recently moved and left my lyric thermostat at that house, but while I was there I had a pretty nice setup with node-red reading the thermostat, and motion sensors. So walking into a room would trigger the fans to turn on at a speed determined by the temperature.

I’ll have that again as soon as I figure out which motion sensors im gonna run this time (stupid wyze sensor mac address problem) screwed me there.

1 Like

So apparently I picked a bad time to get a fan switch (LZW36)… I added this to Alexa using the Alexa Smart Home Skill and can only set the fan using specific percentages just like you mention. Am I missing something or is that the only solution at the moment? I would like to be able to use, Low, Medium, and High also but she doesn’t seem to do anything. I am using the template from above:

  - platform: template
    fans:      
      bedroom_fan:
        friendly_name: "Bedroom Fan"
        value_template: "{{ states('light.bedroom_fan') }}"
        speed_count: 3
        percentage_template: "{{ (state_attr('light.bedroom_fan','brightness') | int /255*100) | int}}"
        turn_on:
          service: light.turn_on
          entity_id: light.bedroom_fan
        turn_off:
          service: light.turn_off
          entity_id: light.bedroom_fan
        set_percentage:
          service: light.turn_on
          entity_id: light.bedroom_fan
          data_template:
            brightness_pct: "{{ percentage }}"

Maybe you will get a response if you ask the dev yourself above.

I seem to be on the naughty list right now so I’m only getting coal in my stocking… :wink:

Okay, I’ll poke around for an open issue first before I make a new one, but wanted to make sure I wasn’t just missing something in my setup. Has anyone happened to debug yet to see if Alexa is sending anything to HA for the “low, medium, and high” commands?

As far as I could glean any info from the threads I think that speeds should all still work as they did before but it will throw an warning in the logs that the set_speed service is being deprecated.

However, eventually, you will be required to only use percentages to control the speeds using voice controls.

I would really like to see us be able to use either going forward tho. I think using “set speed to 33%” instead of “set speed to low” is un-natural and not normal human language.

If you have a fan that supports (requires) percentages that’s fine and I’m glad that those fans are supported but I don’t see why the speeds are being thrown away and we have to completely change to that way when speeds have been supported for years.

So I have found a few post’s regarding this (sorry didn’t realize you already dealt with this so much already)… I’m debating if I should open it as an issue with the Alexa Smart Home Skill as the docs for fans there specifically mentions using low medium high… also all these mentions of using “preset_modes” and ASHS mentions “speed_list” but I cannot figure out if Alexa is supposed to pick up on those automatically or what… this is my first fan in HA so not super familiar with any of it. I guess worse case scenario I’ll make routines for the speeds… but definitely not ideal

That’s kind of what I was thinking of doing too if I couldn’t persuade anyone to have all the options.

It’s sad to think that I’ve spent so much time and effort to get everything in HA to have to go outside of it to get this seemingly basic functionality.

@Bartem

were you able to get your fan working yet?

if not then you might want to look at this thread to see if can help you out.

if not then post back here where you’re stuck and I’ll see if I can help.

1 Like

No haven’t really looked much more into yet… I’ll try to check it out tonight. Thank you.

1 Like

So I just had a chance to try it, I’m not sure if you realized my fan was a Z-wave fan switch (light entity) with a template_fan as my means of creating the fan entity. So when I upgraded yesterday my Inovelli LZW36 no longer had the light.bedroom_fan entity (which that second switch was created as) It actually made it’s own fan entity this time. (Not sure if the previous was standard behavior or something wrong with my setup as it was my first z-wave fan switch)…

So either way, the created fan entity was exposed directly to the Alexa Smart Home Skill and is working with both percentages and off, low, medium, high commands. So I’m not sure if it was template_fan that was breaking it or if something was changed in the backend that makes it operate differently. But thanks for the help.

1 Like

good that it’s working now.

I’m not sure how long the named speeds will continue to work tho.

I believe from reading the release notes those shouldn’t be around much longer.

Unless the wording is just muddled and those will continue to work as they do now. :man_shrugging:

That will be a nice surprise if so. :slightly_smiling_face:

Once I get a bit more time I’ve got a template fan I was playing around with using presets that works fairly well. And I need to work out how to use the preset modes with the template fans too.

Once I get those worked out I’ll probably post another how-to for the template fans like the one for the mqtt fan. Hopefully they will be useful to people and help them from banging their heads against a a wall trying to figure out the new control paradigm.

Also having z-wave fan switch (light entity) that i can dim (brightness). Stil trying to figure out this shit but no luck. All i figured out so far is: speed_count: 3 but no idéa how to make my fan have speeds like 32%, 64% and 84% (its ventilation). Now all i got is 33, 66 and 100 % :confused: hoping that someone will post a good exemple soon :z

What type of switch is it? When I upgraded to 2021.4.0 suddenly the “light.bedroom_fan” became unavailable and there was new fan entity with the default name for the switch (Inovelli LZW36). I don’t know if a change was made in Zwave_JS integration that triggered that change but Zwave_js2mqtt was updated a day or two prior without causing that to happen then on the upgrade there it was. Worth peeking at your Zwave device to see if you maybe got a new entity also?

It is a qubino dimmer. I am still using the old z-wave integration, but I will try to upgrade to z-wave JS and see what happens. I am using alot zigbee2mqtt but now zwave2mqtt, maybe should try that :slight_smile: i wall come back to you with result. thx

What happens if you leave out the “speed_count: 3” from the config?

you should then end up with a step of 1 in stead of a step of 33.3333333. Then you should be able to use the slider to set the desired percentages to whatever you want.