UPDATE: This technique is largely obsolete as of 2021.12, because it’s now built right into HA with the following PRs:
- Use configured speed ranges for HomeSeer FC200+ fan controllers in zwave_js by mkowalchuk · Pull Request #59697 · home-assistant/core · GitHub
- Add zwave_js speed configurations for GE/Jasco 12730 and 14287 fans by mkowalchuk · Pull Request #60517 · home-assistant/core · GitHub.
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:
- Specifies [speed_count: 4] – which results in stops on the percentage slider at [0, 25, 50, 75, 100]
- Re-maps the percentage values so that those stops actually map to the right speeds on the HomeSeer HS-FC200+ (see the above table).