@jbouwh I see you recently had some PRs merged around fans and Alexa. Any chance you could shed some light on what I’m doing wrong with my presets?
There was an issue where legacy speeds still were needed that was solved, have a look at the PR. I also got google Assistant working with fans. The type of the fan does not matter. Speed percentage, preset modes and legacy speeds (at least for a while) should work fine now.
Then my template must be wrong. Any chance you might take a look at it? It’s a couple posts up.
Do not use speed_count
and speeds. Use percentage based speeds.
As expected, you’re a genius! That worked!
Now I just need to figure out why when I tell Alexa to set it to ‘breeze’ it starts asking me about my Ecobee thermostat.
I ended up using Node red and seting the fan to 1% on Alexa activates breeze mode. It relies on zigbee2mqtt and a node red Alexa skill though.
Zigbee2mqtt has a pending PR that should fix this template and have all 4 speeds and breeze mode working on the next release for this fan too.
I posted the Node red flow here Unable to get Home Decorator / Hampton Bay Zigbee fan to pair - #18 by mwav3
@flyize sorry for the dumb question but I just made the move to HA and after moving over my KoF’s I also noticed the high fan speed was missing. How do I setup the template and the script for the fan? I currently have 5 KoF’s so I assume I need to do this for each fan?
I don’t know about zha, but in zigbee2mqtt you can control all 4 speeds and smart mode of the fan directly through Home Assistant now. This fan and getting full control was one of the reasons I opted for zigbee2mqtt over zha:
The PR was done recently in zigbee2mqtt to fix this - https://github.com/Koenkk/zigbee2mqtt/pull/7359
There are still some minor warnings in Home Assistant though for templating issues - I filed an issue with zigbee2mqtt to hopefully fix it. If not, you can do an MQTT template yourself to clear all the errors. More info on that here - https://github.com/Koenkk/zigbee2mqtt/issues/8617
Welcome! I’d just move this project down your list for right now. While you get up to speed, its going to be like trying to drink from a firehose. Templates took me quite a while to wrap my head around. Hopefully you’ll pick it up quicker. Either way, the docs are here:
@mwav3 thanks for the info but unfortunately my zigbee dongle is not support so that isn’t an option for me.
Thanks @flyize. Sadly I’m not very good with this stuff so its a bit challenging at the moment. Where I’m stuck is where to put the code you have posted above? I assume they need to be pasted into one of the *.yaml files. I’ve tried pasting the code in a couple different yaml files (scripts.yaml, configuration.yaml) and changed the values to match my device but either I put in the wrong place or changed the wrong value or missed something else.
I was able to get this working somewhat. The problem i’m facing is with the fan speed slider. It doesn’t seem to do anything. Looks like this may be the problem as the results are unknown in the template editor. Any ideas on what needs to be changed?
` percentage_template: "{{ states('input_number.office_fan_percentage') }}" `
` preset_mode_template: "{{ states('input_select.office_fan_preset_mode') }}" `
Configuration > Helpers
Add some new input_numbers.
Are the low, medium, high options totally gone now? Alexa doesn’t seem to know what I’m asking anymore.
(I seem to recall there was a PR for this somewhere…)
Yes, they were removed in the September release. Look on breaking changes under mqtt
That says for MQTT though. I’m not using MQTT.
Looks like this PR took it away from everything else for the rest of the fan platform beyond just MQTT
You should be able to setup Three Alexa routines to control the fan, so when you say “Alexa, set bedroom fan to low” - Alexa will recognize that command and translate it to turning the fan on at 33%. Then you do one for medium at 66, high at 100, etc. This is the way I used to do it for an old fan I had so you don’t have to say - “Alexa set fan to 33%”.
Oh, that’s not a bad idea. Thanks!
I also noticed that presets for my fan template, like breeze, aren’t working via Alexa. Any ideas on that one?
Maybe you can create an “input boolean” called “smart mode” or something like that, and an automation that activates the breeze mode when the boolean is turned on, and switches back to “normal mode” when the boolean is turned off.
Then you can do an Alexa routine that says “Alexa, set bedroom fan to breeze” that will turn that boolean on.
I’m not 100% sure though if you create an input boolean (which is basically a “virtual switch”) if that would feed through from Home Assistant to Alexa directly. I use a Node Red palette to create Alexa devices which gives me a bit more control on how the things come over into Alexa then Haaska or Nabu Casa does, so if it doesn’t come in, you should be able to give that a try.
Also, if the boolean doesn’t come over, creating a “template switch” might work too
It’s actually something wrong in my template, because presets (like ‘smart’ or ‘on’) work with the default template. I just don’t know what it is.
Try adding a float to the percentage template, and setting a speed count to 4
- platform: template
fans:
zha_fan:
friendly_name: "ZHA Fan"
unique_id: "jdfskl435475"
value_template: "{{ states('fan.bedroomzha') }}"
percentage_template: "{{ states('input_number.bedroomzha_percentage') | float }}"
preset_mode_template: "{{ states('input_select.bedroomzha_preset_mode') }}"
turn_on:
service: fan.turn_on
entity_id: fan.bedroomzha
turn_off:
- service: fan.turn_off
entity_id: fan.bedroomzha
- service: input_number.set_value
data_template:
entity_id: input_number.bedroomzha_percentage
value: 0
set_percentage:
service: script.zha_fan_set_percentage
data:
percentage: "{{ percentage }}"
speed_count: 4
set_preset_mode:
service: script.zha_fan_set_preset_mode
data_template:
preset_mode: "{{ preset_mode }}"
preset_modes:
- 'max'
- 'breeze'