ESPHome 1.17.0 Speed Fan Changes

With the recent changes to Speed Fan in 1.17.0 I’ve been updating my configuration from Low/Medium/High to 33/66/100.

I’ve found when using the new configuration speed fan seems to be expecting a float value rather than the required int value.

Triggering:

fan.turn_on:
  id: fan1
  speed: 33

results in:

Setting speed: 1.00

being logged and set, rather than

Setting speed: 0.33

The fan component only accepts int as valid speeds, so having:

fan.turn_on:
  id: fan1
  speed: 0.33

doesn’t validate and compile.

Am I missing something here or is this potentially an issue with the 1.17.0 changes?

What is your configuration for fan1?

In particular the speed_count variable.

It is:

fan:
  - platform: speed
    output: fanoutput
    id: fan1
    name: "Bedroom Fan"
    speed_count: 3

That looks ok.

The fan.turn_on action docs say this:

speed (Optional, int, templatable): Set the speed level of the fan. Can be a number between 1 and the maximum speed level of the fan.

Does that mean you have speed settings of 1, 2 and 3?

Try it:

fan.turn_on:
  id: fan1
  speed: 3

Should be full speed, if my understanding of that is correct. And,

fan.turn_on:
  id: fan1
  speed: 1

Should be 33% speed.

Thanks @tom_l !
That makes sense and now works.

I couldn’t get out of my head speed_count was dividing the range into percentages and using those.

In HA it displays as a slider that snaps to 0, 33, 66 and 100% rather than the dropdown with presets.

Appreciate your help!

nothing about the changes to the way fans work now makes sense.

If a fan needs a percent to work and get all of the speeds I agree that percents could be useful. but why force everyone to use percentages for simple three speed fans.

Give us the options to set speeds or percentages directly instead of us needing to jump thru hoops to do “higher level math” :wink: to figure out what the system is actually doing behind the scenes.

If I need a fan to run at 10%, 20%, …etc or low, med-low, med,…etc just let me put those speeds in directly into a speed list.

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.

Here is the FR. Please go there and vote it up.

My question is somewhat related, I actually want to set my fan speed to any arbitrary percentage, not just the three fixed levels (low, medium, high) that are supported for me today.

I have a simple PWM fan out out and my config looks like this:

# Expose fan
output:
  - platform: esp8266_pwm
    pin: D5
    frequency: 20000 Hz
    id: 'fan_pwm_output'
fan:
  - platform: speed
    output: fan_pwm_output
    name: "Controller Fan"

The MQTT topic for setting the fan speed is:

remote_watchdog/fan/controller_fan/speed/command 

but sending anything other than one of three fixed speed strings does nothing useful.

Since HA made a big change in fan support a while back, is there something I can do in ESPHome 1.17.2 to support setting variable percentage speeds?

You may need to add speed_count: 100 to fan:
Although the docs seem to suggest it defaults to 100 anyway.

Assume you have MQTT Fan configured to use percentage_ rather than preset_ variables.

Interesting.

And I don’t have MQTT Fan configured at all. Which is curious since the fan works just fine (caveats around fixed speed labels notwithstanding).

So, am I to assume, that the the current three speed settings, which have not been defined by me, are somehow defaults because I haven’t explicitly configured MQTT fan, or do they come from ESPHome? or is it both?

I’m beginning to think that fans in HA are more mysterious and require more config magic than meets the eye.

Might need to track down which integration your fan is using. In Integrations is it listed under ESPHome or MQTT?
If using the ESPHome integration HA doesn’t communicate with the fan using MQTT at all.

Either way, I’d be explicitly defining speed_count: 100 in ESPHome to see if that makes a difference. You could always manually define a MQTT Fan using the percentage_ variables to see what that does too.

The three speed settings you’re seeing may be defaults but could depend on the ESPHome version the device is currently running and the HA version. Unfortunately I don’t have a good feel for exactly where all this changed as I migrated fan hardware and from Tasmota to ESPHome right in the midst of it all.

Are you seeing a slider that snaps to 33%, 66%, 100% or a drop down menu with three options?