Hi,
So I recently had some zigbee light and fan switches installed in my walls, and they are working fantastically (basically they are just relays replacing the normal switches that are networked via zigbee), the fan switches however are three separate entities (when integrating with HA, I changed the switch device type to fan, but the switch entities exist in HA too).
- One for low - fan.bedroom_fan_low
- One for medium - fan.bedroom_fan_medium
- One for high - fan.bedroom_fan_high
I want to somehow make a new “parent fan” that groups these together, so I can leverage things like increasing speed and decreasing speed through automation.
After doing some research, I found the template fan docs,
which triggered a thought, I need almost a “virtual fan”, that has multiple speed presets, that when updated, passees the changes across to the real-world counterpart.
and from that, created this
fan:
- platform: template
fans:
bedroom_fan_master:
friendly_name: "Bedroom Fan Master"
value_template: "{{ states('fan.percentage_fan') }}"
turn_on:
- service: fan.turn_on
target:
entity_id: fan.percentage_fan
turn_off:
- service: fan.turn_off
target:
entity_id: fan.percentage_fan
percentage_template: >
{{ state_attr('fan.percentage_fan', 'percentage') }}
speed_count: 3
set_percentage:
- service: fan.set_percentage
target:
entity_id: fan.percentage_fan
data:
percentage: "{{ percentage }}"
preset_modes:
- "off"
- "low"
- "medium"
- "high"
preset_mode_template: >
{% if is_state('fan.percentage_fan', 'on') %}
{% if state_attr('fan.percentage_fan', 'percentage') == 100 %}
high
{% elif state_attr('fan.percentage_fan', 'percentage') == 66 %}
medium
{% else %}
low
{% endif %}
{% else %}
off
{% endif %}
set_preset_mode:
- service: fan.set_percentage
target:
entity_id: fan.percentage_fan
data:
percentage: >-
{% if preset_mode == 'high' %}
100
{% elif preset_mode == 'medium' %}
66
{% elif preset_mode == 'low' %}
33
{% else %}
0
{% endif %}
And then created an automation that looks for a state change on bedroom_master_fan entity, which in turn, calls a script that checks the speed being set on bedroom_master_fan and turns on or off the appropriate switch for the physical fan. But the state of the bedroom_master_fan never seems to actually update when I include it in a dashboard with a fan card and interact with it, therefore, the automation is never being triggered.
Does anyone see where I am going wrong? or have any idea how to make a “multi-switch” fan entity? I believe reading other forum posts, in older versions of HA, before fan percentages were the default, speeds were… so I am sure I am just missing something super obvious.