Fan entities need to support number speeds and allow set_speed calls instead of percent

On some ventilations systems, like the one I am creating an ESPHome component for there is no concept of percentage speed, there are just hard steps to choose from.

For example, in the one linked above, there is a range from 0 to 6. Translating that to percentages makes no sense. It will show values like 66.67% which means nothing for the end user.

It is even worse when I include the special speeds and go into 11 values

Also, if the user wants to set the speed 2 on an automation, they again have to go thru the process of convert them to percent just for it to work. Which is cumbersome, unintuitive and a bad UX.

We need to be able to set fans as non-percent fans (step fans?) and allow to set integers as the velocity.

Funny story…that’s how HA was years ago before they went against many of us and changed to using percentage. Unfortunately I seriously doubt there is ANY chance of it going back again given we failed to have a win back in those days.

1 Like

My hope as that, now that ESPHome is also part of the Open Home Fundation, they allow to sync this. Because this is how ESPHome devices work.

Has anyone ever seen a fan with percentage control? Every single one I know has fixed speeds. Percentage is cool though, they need to fix all the fans :grinning:

Yeah, I get you.

This is what I have in my ESPhome fan code:

output:
  - platform: template
    id: custom_fan
    type: float 
    write_action:
      - if:
          condition:
            lambda: return ((state == 0));
          then:
            # action for off
            - switch.turn_off: speed1
            - switch.turn_off: speed2
            - switch.turn_off: speed3
      - if:
          condition:
            lambda: return ((state > 0) && (state < 0.4));
          then:
            # action for speed 1
            - switch.turn_off: speed2
            - switch.turn_off: speed3
            - delay: 200ms
            - switch.turn_on: speed1
            
      - if:
          condition:
            lambda: return ((state > 0.4) && (state < 0.7));
          then:
            # action for speed 2
            - switch.turn_off: speed1
            - switch.turn_off: speed3
            - delay: 200ms
            - switch.turn_on: speed2
            
      - if:
          condition:
            lambda: return ((state > 0.7));
          then:
            # action for speed 3
            - switch.turn_off: speed1
            - switch.turn_off: speed2
            - delay: 200ms
            - switch.turn_on: speed3

This basically converts the HA percentages to 3 speeds plus OFF.

(this is for a homemade fan controller using relays and a standard fan speed control dual capacitor)

They were probably thinking on voltage controlled fans, like the ones on PC fans?

That is coo. My main issue is on HA UI though. After I add the component I am working on, there is no way to specifically see the current velocity without doing mental math :grimacing:

Isn’t that what the switches are for? You can write an automation to have the switches set the right speed. Another option is to tie the speeds to fan presets. I do not think they are present in esphome but you can create a template fan in HA for it and redirect the calls.

That’s not a problem though:

image

Card code:

features:
  - type: fan-speed
type: tile
entity: fan.alfresco_fan
vertical: false

What bugs me for mechanical ventilation is that there is no off on those. While it is possible to map speed 1 to off, the numbering no longer corresponds to what the users expect and the physical buttons.

1 Like

OH, do you also get that when you enable ESPHome web server?

The component I am doing is extending a fan::Fan in c++, maybe I need to extend an SpeedFan :frowning: I will need to change a lot of stuff probably.

Or it is maybe because I have 6 speeds?

Do you also get that display when using more than 3 speeds? Because I think there is no mdi icon for an Fan with a 4.

This that was it. If I change the component to report 3 speeds I get that card

But if I change that to 4, it renders

I don’t have any fan with 4 speeds so can’t test that short of changing my ESP code.

Hello distante,

As it states in the pinned post in Feature Requests category, an ESPHome Feature Request is not in scope for the feature request category. You need to contact ESPHome for help with those.

More about Feature Requests and links to coordinator software repos.

It is not an ESPHome feature, it relates to ESPHome because ESPHome shows this info correctly.

OK. Maybe you need to adjust the request a bit, I don’t get that from what you wrote, it starts off talking about espHome. But OK, it’s your request.

If you are talking about inside HA, I do a custom template macro like this…

{% macro fanspeed(entity,speed) %}
    {# The entity is the HA entity name of the sensor calling this template.
       This is needed if the fan gets a RESULT that is not FanSpeed, like Buzzer.
       The speed is the value_json.FanSpeed from the RESULT topic.
       The return will be whatever the sensor value currently is.
       This responds immediately on command so don't have to wait for the tele.
    #}
  {% if speed | is_number %}
    {% if speed == 1 %}
      33
    {% elif speed == 2 %}
      66
    {% elif speed == 3 %}
      100
    {% else %}
      0
    {% endif %}
  {% else %}
    {{ states(entity) }}
  {% endif %}
{% endmacro %}
  - unique_id: 47058f65-ca94-4c2c-4589ec759eab 
    name: "Office FanSpeed"
    state_topic: "Office_Fan/stat/RESULT"
    unit_of_measurement: "%"
    value_template: >-
      {% from 'fan.jinja' import fanspeed %}
      {{- fanspeed('sensor.bedroom_fanspeed',value_json.FanSpeed) -}}

Hi! I do not quite understand, how or where do this render, or does the fan controller UI looks like?

I believe all Apple HomeKit fans are percentage based (At least the control interface is - I think the HomeKit Accessory Protocol control interface only supports % for fans, though I’m assuming they could do a conversion to 33%, 67%, 100% for a 3-speed fan). However, I think you can only get “true” percentage-type control if the fan motor is a DC motor which allows you to adjust speed by a simple voltage adjustment. The more typical ceiling fan uses an AC motor which uses capacitor banks to adjust speeds (this type of thing: Ceiling Fan Capacitor) - those motors typically have only a few different capacitor settings, and thus only a few speeds.