Hi!!!
I just upgrade hassbian to 0.69 and I found a new template call Fan Template https://www.home-assistant.io/components/fan.template/
I’m trying to config this with my fan but I don’t know how to create a script for speed services. does anyone using this template, can you share a sample code for me…
Thanks!!!
petro
(Petro)
May 14, 2018, 11:54am
2
That depends on your fan. Every fan will be different. Do you have a fan that has adjustable fan speeds that does not come through as a fan in HA?
Does anyone have more detailed examples of the template fan component. I currently control my fans with scripts for each speed and one for off.
petro
(Petro)
May 25, 2018, 3:12am
4
I’d be taking a guess at how it works, but If you post your scripts I can piece it together how I think it works.
Let me explain that better I use scripts with an input selector. I have a pilight switch with the raw protocol setup for each fan speed and I trigger the switch with the input selector which calls a script.
An example switch:
platform: pilight
switches:
patio_fan_lights:
on_code:
protocol: raw
code: 350 665 385 315 735 315 700 315 700 665 350 350 700 350 700 350 700 350 700 700 350 700 350 350 700 12110
off_code:
protocol: raw
code: 350 665 385 315 735 315 700 315 700 665 350 350 700 350 700 350 700 350 700 700 350 700 350 350 700 12110
If the template fan component requires a python script I could probably figure that out.
petro
(Petro)
May 26, 2018, 12:48am
6
for you i think it would work like this:
fan:
- platform: template
fans:
bedroom_fan:
friendly_name: "Bedroom fan"
value_template: "{{ states('switch.patio_fan_lights') }}"
turn_on:
service: switch.turn_on
entity_id: switch.patio_fan_lights
turn_off:
service: switch.turn_off
entity_id: switch.patio_fan_lights
set_speed:
service: switch.turn_on
data_template: >
entity_id:
{% if speed == '1' %}
switch.patio_fan_slow
{% elif speed == '2' %}
switch.patio_fan_medium
{% elif speed == '3' %}
switch.patio_fan_fast
{% else %}
switch.dummy
{% endif %}
speeds:
- '1'
- '2'
- '3'
I mean, without seeing your full setup, i can only guess. But this is how i would expect it to work. I’d also need to create it myself to verify that set_speed can access the list of speeds defined in the lower section of the template.
Hope this points you in the right direction.
This is what I get.
Invalid config for [fan.template]: expected a dictionary for dictionary value @ data[‘fans’][‘my_fan’][‘set_speed’][0][‘data_template’]. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/fan.template/
My config looks like this:
indent preformatted text by 4 spaces
fan:
- platform: template
fans:
my_fan:
friendly_name: "My Bedroom fan"
value_template: "{{ states('switch.bedroom_fan_high') }}"
speed_template: "{{ states('input_select.bedroom_ceiling_fan') }}"
turn_on:
service: script.bedroom_fan_high
turn_off:
service: script.bedroom_fan_off
set_speed:
service: switch.turn_on
data_template: >
entity_id:
{% if speed == 'High' %}
switch.patio_fan_high
{% elif speed == 'Med' %}
switch.patio_fan_med
{% elif speed == 'Low' %}
switch.patio_fan_low
{% else %}
switch.dummy
{% endif %}
speeds:
- 'High'
- 'Med'
- 'Low'
petro
(Petro)
May 27, 2018, 11:06am
8
thats my bad, swap the arrow spot to entity_id:
fan:
- platform: template
fans:
my_fan:
friendly_name: "My Bedroom fan"
value_template: "{{ states('switch.bedroom_fan_high') }}"
speed_template: "{{ states('input_select.bedroom_ceiling_fan') }}"
turn_on:
service: script.bedroom_fan_high
turn_off:
service: script.bedroom_fan_off
set_speed:
service: switch.turn_on
data_template:
entity_id: >
{% if speed == 'High' %}
switch.patio_fan_high
{% elif speed == 'Med' %}
switch.patio_fan_med
{% elif speed == 'Low' %}
switch.patio_fan_low
{% else %}
switch.dummy
{% endif %}
speeds:
- 'High'
- 'Med'
- 'Low'