Brilliant as always, got the new plugin and copied the examples at the top and now have working fans for the future - I was dreading this breaking change but it was nice and easy, thanks Finity!
For anyone using Node-Red on their Fans (I use it to cycle speeds/off from RF switches) there’s also one breaking change in that the fan no longer reports a speed, but a preset as the current ‘state’. So you’ll need to use data.attributes.preset_mode to detect where in the speed range the fan is.
Hopefully they won’t change anything else to prevent us from using speeds as preset modes.
One of the devs said that we weren’t supposed to use speeds as presets but I could never get any clarification (or even any response at all) as to why.
Just as an FYI I realized that the new fan config codes using presets and percentages don’t work using voice commands via Alexa even tho they work fine in HA.
For anyone who wants the old speed list functionality reinstated…
I’ve requested that the old speed list options should be kept and I’ve had a suggestion from a dev that if a FR gets enough votes they would implement it.
I have an IFAN02 with Tasmota on it for my main office ceiling fan. I also have a Nextion-based “Office Controller” mounted on the wall to be able to turn on the lights and fan, as well as set fan speeds. I’d have to go through some machinations to make that work under this system… so I’m not super thrilled with this new percentage- or preset-based setup and would love to have the option to keep the old style.
Thank you as always for leading the pack. I’m stuck. Recently upgraded to latest 2021.5 and cannot get HA to recognize that fan is on. I’ve pared pack your very helpful yaml to below, but HA obstinately refuses to read the state topic as anything other than off. I have even put in a simple switch in lovelace and it sends the correct payload of “3” but then turns right off without acknowledging the state
I hope someone can give me a sanity check. I’ve been looking at it for so long I’m sure I must be overlooking an error.
Which version are you using - preset or percentage?
Also you should probably just post all the code for what you are trying right now. that way I can see where you might be off if it’s somewhere else in the code.
you should just be able to literally copy my code from above and replace your entities and topics and it should work.
@finity
Your mere reply solved it. I was using image: homeassistant/raspberrypi3-homeassistant:latest
It was one of the 3 2021.5.x versions (I tried a few). I went back to 2021.4.3 and your yaml works perfectly.
Just needed a finite intervention
edit: It also could have been the payload_on tweak I tried. I’d like it to turn on to 3 whenever it goes from off to on (for some existing automations) but maybe that isn’t possible.
But yes the speed selected by going to on is always “low” speed and I think that is hard-coded into the integration.
I have a template test fan that I set up to make it go back to the last speed it was on before turning off but I had to do that via scripts. I doubt it’s worth it to create another fan entity along with all of the other stuff that needs done to make it work just to get the fan to jump to speed 3 immediately.
after 2 hours of playing with the code I found that this works best for me specially I’m using Homekit
the reason that I had to play with it is that when using “preset modes” it shows as a group of 4 switches and when using Siri will not understand something like " Set the kitchen fan to 50%" or " Set the fan to medium " it will just gonna replay with " this function is not available " or can’t do that.
The percentage mode is work best with HomeKit and Siri but you have to specifically ask for 0%, 33%, 66% or 100% even when manually change it from the HomeKit app you will have to fit it exactly to same percentage otherwise it will not work at all.
so my work around it is any thing between 1-33% will be low or level 1 any value 34-66% will be medium or level 2 and from 67-100% that is Max, High or level 3.
and it works perfect with Siri on my HomePod
- platform: mqtt
name: KC Testing Fan
command_topic: "cmnd/kc_fan/FanSpeed"
state_topic: "stat/kc_fan/RESULT"
state_value_template: >
{% if value_json.FanSpeed is defined %}
{% if value_json.FanSpeed == 0 -%}off{%- elif value_json.FanSpeed > 0 -%}on{%- endif %}
{% else %}
{% if states.fan.kc_fan.state == 'off' -%}off{%- elif states.fan.kc_fan.state == 'on' -%}on{%- endif %}
{% endif %}
availability_topic: tele/kc_fan/LWT
payload_off: "off"
payload_on: "on"
payload_available: Online
payload_not_available: Offline
percentage_command_template: >
{% if value >= 1 %}
{% if value <= 33 %}
1
{% elif value >= 34 %}
{% if value <= 66 %}
2
{% elif value >= 67 %}
{% if value <= 100 %}
3
{% endif %}
{% endif %}
{% endif %}
{% else %}
0
{% endif %}
percentage_command_topic: "cmnd/kc_fan/FanSpeed"
percentage_state_topic: "stat/kc_fan/RESULT"
percentage_value_template: >
{% if value_json.FanSpeed == 1 %}
33
{% elif value_json.FanSpeed == 2 %}
66
{% elif value_json.FanSpeed == 3 %}
100
{% else %}
0
{% endif %}
I realise this is outside of the card itself, but I suspect we have the best collection of relative experience and expertise here.
I’m seeing this oddity on my ‘new’ fans (since the changes to presets). The card is showing off instead of low, medium, high when the fan is going and I’ve tracked it down to this. The state is on, but the preset moves back to ‘off’. How can the preset be changing on it’s own?
I removed the ‘off’ preset and this has now resolved the issue. The last preset shows in the device state attributes, the but the state is off, then it moves to on and whichever preset has been selected.
Not sure if that’s a bug in the new HA code or the way it’s designed to work?