I have a Fibaro light dimmer that uses a 0-10V signal to dim lights, but I use it to control a central ventilation fan.
In order to benefit from the new automation syntax I want to convert the fan from the light domain to the fan domain via the configuration file, and the usage of the fan template.
Reporting the preset mode works, so when I execute my automatons that set the three brightnesses (180, 126 and 41) the new fan entity reports the correct preset.
Setting a new preset does nothing. Setting a new percentage does nothing.
If possible, I’d prefer to avoid going via a script to set the target speed, but that is mainly because I only have one fan, and it feels over-administrative to need a script as well in order manipulate it.
template:
- fan:
- name: 'Takfläkt'
unique_id: takflakten
preset_mode: >
{% if is_state('light.takflakt', 'on') %}
{% if state_attr('light.takflakt', 'brightness') == 180 %}
high
{% elif state_attr('light.takflakt', 'brightness') == 126 %}
medium
{% elif state_attr('light.takflakt', 'brightness') == 41 %}
low
{% else %}
undef
{% endif %}
{% else %}
off
{% endif %}
turn_on:
service: homeassistant.turn_on
entity_id: switch.takflakt
turn_off:
service: homeassistant.turn_off
entity_id: switch.takflakt
preset_modes:
- 'low'
- 'medium'
- 'high'
- 'undef'
percentage: >
{{ (state_attr('ligh.takflakt', 'brightness')|int * 0.4)|round(0) }}
set_percentage:
- action: fan.takflakten
target:
entity_id: fan.takflakten
data:
percentage: >-
{% if preset_mode == 'high' %}
70
{% elif preset_mode == 'medium' %}
50
{% elif preset_mode == 'low' %}
20
{% else %}
10
{% endif %}
set_preset_mode:
- action: fan.set_percentage
target:
entity_id: fan.takflakten
data:
percentage: >-
{% if preset_mode == 'high' %}
70
{% elif preset_mode == 'medium' %}
50
{% elif preset_mode == 'low' %}
20
{% else %}
10
{% endif %}