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.
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"
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.
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.
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.
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?
@rhodges I’ve been successfully using your fan template code above for a couple of years. I recently had to replace one of my fan controllers ( GE/Jasco 14314/ZW4002) and discovered the new controller can be set from 0-100% where as the old one was a three step switch. Thus using the above code I set it for low=33, med=67, high=100. With the new controller I’m trying to add two additional speeds, “extra-low” and “medium-high”. So my new code looks like:
- platform: template
fans:
bedroom_fan:
unique_id: bedroom_fan
friendly_name: "Bedroom Fan"
value_template: >
{{ states('fan.bedroom_fan_real') }}
preset_mode_template: >
{%- set v = state_attr('fan.bedroom_fan_real', 'percentage') | int(0) -%}
{%- set vals = { 0: 'off', 22: 'extra-low', 33: 'low', 50: 'medium', 75: 'medium-high', 100: 'high' } -%}
{{ vals[v] }}
turn_on:
service: fan.turn_on
target:
entity_id: fan.bedroom_fan_real
turn_off:
service: fan.turn_off
target:
entity_id: fan.bedroom_fan_real
set_preset_mode:
service: fan.set_percentage
data:
percentage: >
{%- set vals = { 'off': 0, 'extra-low': 22, 'low': 33, 'medium': 50, 'medium-high': 75, 'high': 100 } -%}
{{ vals[preset_mode]}}
target:
entity_id: fan.bedroom_fan_real
speed_count: 5
preset_modes:
- "off"
- "extra-low"
- "low"
- "medium"
- "medium-high"
- "high"
Unfortunately this isn’t working for me. When I tell Alexa to set the fan to “extra-low” it sets to “low” and “medium-high” sets it to “medium”. Thus I’m not sure what I’m doing wrong, but can’t seem to figure it out either!
No idea. I’m guessing it is Amazon not dealing with “extra-” or “-high” when it parses your request.
For giggles, change those to something completely different. “Bob” and “Larry” and see if it works. If it does, then I’m guessing it is just Amazon not parsing the request correctly.
@rhodges , I tried changing them to other random names because I thought it might be confusing them. Unfortunately that didn’t seem to work so I agree it’s a parsing problem on Amazon’s end. Grrr! Thanks anyway.
Yeah, I forgot to follow up. I did some quick reading about what words/names are supported by Alexa and it seems that you have to do some extra work to present non-standard names when registering with Alexa.
I couldn’t find all the standard words and the Alexa skill would need to have support for reading and presenting those, so you’re probably out of luck unfortunately.
How do we add this template at global level or make it generic so that all fans inherit these speeds instead of creating template sensor for each fan separately?
Any help ?
Unless something has changed recently (I don’t follow HA close anymore) there isn’t a way.
You could write a python script to generate a yaml file and use includes, but unless you are a master with python and/or your environment changes often, it would probably be quicker to just copy/paste and adjust for each fan.
It is really unfortunate HA won’t support this natively.
I agree it is a standard feature of a device and there should be 1-1 mapping in HA. I hope it will be added one day in HA but thanks again for your template script.