Making percentage-based control more ergonomic for the HomeSeer HS-FC200+ Z-Fave fan controller (4 speeds)

UPDATE: This technique is largely obsolete as of 2021.12, because it’s now built right into HA with the following PRs:

ORIGINAL:
I found the percentage-based fan control from the 2021.3 release to be a bit of a usability regression with my Z-Wave fan controller (HS-FC200+, 4 speed, using the original Z-Wave integration), since the old dropdown with specific speeds was replaced with a 0-100 percentage slider with no information about where each speed starts and stops.

I’ve hacked together a template fan wrapper that addresses this issue, providing useful stop points for each of the 4 available speeds:

  mbr_fan_4sp:
      friendly_name: "Ceiling Fan"
      value_template: >-
        {{ states('fan.mbr_fan') }}
      percentage_template: >-
        {% if state_attr('fan.mbr_fan', 'percentage') >= 75 %}
          100
        {% elif state_attr('fan.mbr_fan', 'percentage') >= 50 %}
          75
        {% elif state_attr('fan.mbr_fan', 'percentage') >= 25 %}
          50
        {% elif state_attr('fan.mbr_fan', 'percentage') > 0 %}
          25
        {% else %}
          0
        {% endif %}  
      availability_template: >-
        {{ not is_state('fan.mbr_fan', 'unavailable') }}
      turn_on:
        - service: fan.turn_on
          data:
            entity_id: fan.mbr_fan
      turn_off:        
        service: fan.turn_off
        data:
          entity_id: fan.mbr_fan
      set_percentage:
        - service: fan.set_percentage
          data_template:  
            entity_id: fan.mbr_fan
            percentage: >-
              {% if percentage > 75 %}
                100
              {% elif percentage > 50 %}  
                74
              {% elif percentage > 25 %}
                49
              {% elif percentage > 0 %}
                24
              {% else %}
                0
              {% endif %}  
      speed_count: 4

I haven’t figured out how to make this more generic, so I’ve got a few instances of this copied/pasted with different raw entity IDs.

Here’s a quick explanation:

In 4 speed mode, the HS-FC200+ has the following mapping from percentages to speeds:
0 = Off
1-24 = 1
25-49 = 2
50-74 = 3
75-100 = 4

This template that combines two things:

  1. Specifies [speed_count: 4] – which results in stops on the percentage slider at [0, 25, 50, 75, 100]
  2. Re-maps the percentage values so that those stops actually map to the right speeds on the HomeSeer HS-FC200+ (see the above table).

What Z-Wave integration are you using?

I think you can simulate the old fan speeds using presets, have you tried that, or are the percentage stops good enough?

I’m using the legacy Z-Wave integration, though I think the Z-Wave JS integration would have the same issue (it also just uses 1-100 - see source).

I haven’t tried using presets - I’ve been pretty happy with the percentage stops.

Yeah, all zwave integrations would have the same issue. Just wasn’t sure if you were using some other hub.

Despite the extra work, the percentage change actually makes the fan more useful for you doesn’t it? Prior to that, you were restricted to 3 speeds, now you can use all 4.

Despite the extra work, the percentage change actually makes the fan more useful for you doesn’t it? Prior to that, you were restricted to 3 speeds, now you can use all 4.

In general, yeah, I think it’s a safer default.

I’d previously been using another approach to get 4 speeds, where I’d kept a local fork of the zwave component with Allow using all 4 speeds with the HomeSeer HS-FC200+ fan controller by mkowalchuk · Pull Request #19179 · home-assistant/core · GitHub patched in. I’m definitely happy that I don’t have to keep that fork around anymore, since it made upgrading HA a little more risky.

That said, I’m a little tempted to rebase & try to upstream the speed-detection logic from that PR again, now that the architectural arguments about new fan speeds are done with.