Add support for named speed lists in the fan integration

Yup, put off doing anything with this until it finally broke. Here I am 1 hour in trying to figure out the new way to get my dumb fan to work. I hacked the remote with a d1mini and relays and it worked flawlessly before… I honestly do not get this change.

2 Likes

I attempted to submit a PR for ISY994 and was told named speeds would not be supported. I ended up hiding the original and creating a template that provides named speeds. This lets me use Alexa to control fan speed by name.

You can tweak this based on your fan implementation. I have only been using this a couple days, but so far, it works.

- platform: template
  fans:
    living_room_fan:
      unique_id: living_room_fan
      friendly_name: "Living Room Fan"
      value_template: >
        {{ states('fan.isy_living_room_fan') }}
      preset_mode_template: >
        {%- set v = state_attr('fan.isy_living_room_fan', 'percentage') | int(0) -%}
        {%- set vals = { 0: 'off', 25: 'low', 74: 'medium', 100: 'high' } -%}
        {{ vals[v] }}
      turn_on:
        service: fan.turn_on
        target:
          entity_id: fan.isy_living_room_fan
      turn_off:
        service: fan.turn_off
        target:
          entity_id: fan.isy_living_room_fan
      set_preset_mode:
        service: fan.set_percentage
        data:
          percentage: >
            {%- set vals = { 'off': 0, 'low': 25, 'medium': 74, 'high': 100 } -%}
            {{ vals[preset_mode]}}
        target:
          entity_id: fan.isy_living_room_fan
      speed_count: 3
      preset_modes:
        - "off"
        - "low"
        - "medium"
        - "high"

4 Likes

That’s a good work around and I had something like that using preset modes originally but in the discussions I was seeing (and instigated) it was said that the HA alexa plugin wouldn’t be able to use the words of named speeds either. I was told it was a limitation of the alexa api or some such. Which didn’t make sense since alexa was already working for named speeds as they were saying it wouldn’t work.

apparently that wasn’t the case or maybe they are waiting until all the fan integrations are fully switched away from named speeds until they block their use in the HA alexa skill.

I guess we will need to wait to see which is the case.

I don’t understand their insistence on preventing preset modes from supporting named speeds.

I do understand the original idea going away from low/medium/high. To me, the preset modes presenting the supported fan speeds is no different than a climate device presenting their arbitrary presets.

Alexa.RangeController Interface | Alexa Skills Kit (amazon.com)

“Use the presetResources object to provide a set of friendly names that users can use to interact with preset values. The first friendly name is the name that appears in the Alexa app.”

So a fan can provide HA its named speeds as presets and register them as a presetResource for each user defined friendly name. It even looks like it is locale aware.

In summary, I understand deprecating speed list in favor a more generic preset list, but not I do not understand why the named speed hate. If they actively code to prevent something like my workaround from working with Alexa, then I’ll drop Nabu Casa and go back to rolling my own Alexa integration like I had before Nabu Casa was around. I will lose all the extra functionality NC provides I know.

1 Like

I hope I was wrong in my understanding of the results of the discussions I’ve seen about this and the preset mode voice controls do continue to work.

And if that’s the case I’ll need to try to figure out how to get my iFan03’s integrated via ESPHome to supply preset modes to HA.

preset modes have been supported by alexa. I’m not sure if it works the way you set it up, but the code has been there a while. I never bothered trying to implement this… however I would expect your utterances to work.

Thanks for confirming.

I can also confirm that my template fan wrapper works with Alexa with turn on, turn off and using one of the preset names.

1 Like

Thanks for sharing the template with preset modes. Up until 2022.4 the button card would still show the old speed names for a fan. For a wall dashboard displaying the percent is not great, this works perfect.

@rhodges THANK YOU!!!

I implemented your template wrapper tonight and finally got “high / medium / low” back with Google Assistant. I did run into a weird Google behavior using this method though. I hid the non-wrapper device, put the wrapper device into the correct room (Master Bedroom for example) just like I originally had the non-wrapper device, however google doesn’t seem to understand the device room assignment when using the preset speeds, only for off. So if I say “Hey Google, set the fan to High” while in the master bedroom it responds “Ok, setting the kitchen exhaust fan to high”. If I say “Hey Google, turn off the fan” it tries to turn off the Master Bedroom wrapper fan as expected… If I say “Hey Google, set the Master Bedroom Fan to High” it works as expected.
Anyone have any thoughts as to what might cause this?

Sorry, no clue. I use Alexa but I don’t do the room level stuff with it, I just use the full room name.

Maybe Google is still linked to the base or wrapped device? Try checking your exposed entities and clearing/re-syncing them?

Hi all – I see this thread has been dead for over a year despite having a high number of votes. Just checking in with a bit of an update. I’m running 2023.7.3 and one of the new features I found was when I’m using the custom mushroom fan card and long press it, that it now gives me the ability to select a fan speed of ‘off’, ‘low’, ‘medium’, or ‘high’. Just wanted to point this out in case it’s helpful to anyone else that is following this thread or stumbles across this. Not sure if it’s an actual HA Core update or Mushroom card update that improved this though, OR if it’ll allow for voice control, but thought it was worth calling out.

1 Like

You can select OFF, LOW, MED, HIGH when you double tap the mushroom fan card… but on the mushroom card itself it still shows percentage… is there a way to convert this so that it will show the state LOW, MED, HIGH or OFF?
IMG_20240405_213617