Hi lads!
I’ve made a helper that is a dropdown / selector. to control my home ventilation system,
I can’t seem to get the terminology right but:
i’d like to transform it towards something like this:
ideally this:
this might just be the ‘default’ fan card but is there a way to change a dropdown to a fan entity?
Use a template fan:
Can probably eliminate your helper (and I assume an automation that goes with it) and do everything directly in it.
does that imply you always ‘have’ to work with percentages?
Not sure I follow. You have to set things up in terms of percentages (and that’s how things work on the backend), but if you just have 1-3 speeds it will show low, med, high as appropriate in cards, etc.
ok, and can you define the ‘actions’ for the presets?
I mean i can set ON an off which would be my ‘low and off’
but can i for medium and high still set specific actions, or does that need another automation
I tried this virtual fan
fan:
- platform: template
fans:
virtual_fan:
friendly_name: "Virtual Fan"
value_template: >
{% if is_state('switch.shellypro3ventilatie_switch_0', 'off') %}
off
{% elif is_state('switch.shellypro3ventilatie_switch_2', 'on') %}
high
{% elif is_state('switch.shellypro3ventilatie_switch_1', 'on') %}
medium
{% else %}
low
{% endif %}
turn_on:
service: switch.turn_on
data:
entity_id: switch.shellypro3ventilatie_switch_0
turn_off:
service: switch.turn_off
data:
entity_id: switch.shellypro3ventilatie_switch_0
preset_modes:
- "low"
- "medium"
- "high"
set_preset_mode:
service: script.set_virtual_fan_preset_mode
data_template:
preset_mode: "{{ preset_mode }}"
with this script for it’s logic:
alias: Set Virtual Fan Preset Mode
sequence:
- service: switch.turn_on
data:
entity_id: switch.shellypro3ventilatie_switch_0
- service: switch.turn_off
data:
entity_id: switch.shellypro3ventilatie_switch_1
- service: switch.turn_off
data:
entity_id: switch.shellypro3ventilatie_switch_2
- choose:
- conditions:
- condition: template
value_template: "{{ preset_mode == 'medium' }}"
sequence:
- service: switch.turn_on
data:
entity_id: switch.shellypro3ventilatie_switch_1
- conditions:
- condition: template
value_template: "{{ preset_mode == 'high' }}"
sequence:
- service: switch.turn_on
data:
entity_id: switch.shellypro3ventilatie_switch_1
- service: switch.turn_on
data:
entity_id: switch.shellypro3ventilatie_switch_2
mode: single
The fan is created but the modes arent present
“No compatible features available for this entity”
Here’s how I set mine up to control my attic fan with 2 speeds:
- platform: template
fans:
attic_fan:
friendly_name: "Attic fan"
unique_id: attic_fan
value_template: >
{% if ((states('switch.attic_fan_low') == "on") or (states('switch.attic_fan_high') == "on")) %}
on
{% else %}
off
{% endif %}
percentage_template: >
{{ states('input_number.attic_fan_speed') if is_state('fan.attic_fan', 'on') else 0 }}
turn_on:
if:
- condition: template
value_template: >-
{{ ((states |
selectattr('entity_id','in',state_attr('binary_sensor.screen_windows','entity_id'))
| selectattr('state','eq','on') | list | count | int) >2) }}
then:
- action: input_number.set_value
target:
entity_id: input_number.attic_fan_speed
data:
value: 100
- action: switch.turn_off
target:
entity_id: switch.attic_fan_low
- action: switch.turn_on
target:
entity_id: switch.attic_fan_high
turn_off:
- service: switch.turn_off
target:
entity_id: switch.attic_fan_low, switch.attic_fan_high
- action: input_number.set_value
target:
entity_id: input_number.attic_fan_speed
data:
value: 0
set_percentage:
if:
- condition: template
value_template: >-
{{ ((states |
selectattr('entity_id','in',state_attr('binary_sensor.screen_windows','entity_id'))
| selectattr('state','eq','on') | list | count | int) >2) }}
then:
- action: input_number.set_value
target:
entity_id: input_number.attic_fan_speed
data:
value: "{{ percentage }}"
- action: "switch.turn_{{ iif(percentage == 50, 'on' , 'off') }}"
target:
entity_id: switch.attic_fan_low
- action: "switch.turn_{{ iif(percentage == 100, 'on', 'off') }}"
target:
entity_id: switch.attic_fan_high
speed_count: 2
I originally used the states of the relays (or switches in HA) in the percentage template, but for some reason it didn’t consistently work (the fan worked correctly, but HA didn’t always show the correct speed), so I ended up setting up a helper to store the current percentage and just read that. I’m guessing you can just take mine and tweak for your setup. Also, you can ignore the if/thens: I just use that to only allow the fan to be turned on if my windows are open.
I’ve finally found it didn’t have to store any percentages,
a fan defined:
fan:
- platform: template
fans:
virtual_fan:
friendly_name: "Virtual Fan"
value_template: "{{ 'off' if states('switch.shellypro3ventilatie_switch_0') == 'off' else 'on' }}"
turn_on:
service: switch.turn_on
entity_id: switch.shellypro3ventilatie_switch_0
turn_off:
service: switch.turn_off
entity_id: switch.shellypro3ventilatie_switch_0
speed_count: 4
preset_modes:
- "off"
- "low"
- "medium"
- "high"
preset_mode_template: >-
{{
'off' if states('switch.shellypro3ventilatie_switch_0') == 'off' else
'low' if (states('switch.shellypro3ventilatie_switch_0') == 'on' and states('switch.shellypro3ventilatie_switch_1') == 'off' and states('switch.shellypro3ventilatie_switch_2') == 'off') else
'medium' if (states('switch.shellypro3ventilatie_switch_0') == 'on' and states('switch.shellypro3ventilatie_switch_1') == 'on') else
'high' if (states('switch.shellypro3ventilatie_switch_0') == 'on' and states('switch.shellypro3ventilatie_switch_2') == 'on')
}}
set_preset_mode:
service: script.set_fan_mode
data:
preset_mode: "{{ preset_mode }}"
And then a simple script that reads the preset mode data input and toggles the nescesarry switches
The only mystery left: is there anyway to couple an icon to a preset?