I am trying to create a fan template that not only controls my Insteon fanlinc, but also updates the connected keypad with the correct light sequence.
I copied the template from the integrations page and it was able to properly control the fan. I then tried to add a service to the set_preset_mode
configuration variable. This is what I have:
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 %}
- service: script.turn_on
data: {}
target:
entity_id: >-
{% if preset_mode == 'high' %}
script.office_keypad_hi
{% elif preset_mode == 'medium' %}
script.office_keypad_med
{% elif preset_mode == 'low' %}
script.office_keypad_low
{% else %}
script.office_keypad_off
{% endif %}
The service call fan.set_percentage
works. The service call to script.turn_on
does not appear to be called at all. I have tested the scripts individually through the webUI and they also work. For completeness, my full package is below. Any help on this would be appreciated.
fan:
- platform: template
fans:
office:
friendly_name: "office"
value_template: "{{ states('fan.office_fanlinc_fan') }}"
percentage_template: "{{ state_attr('fan.office_fanlinc_fan', 'percentage') }}"
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 %}
turn_on:
- service: fan.turn_on
target:
entity_id: fan.office_fanlinc_fan
turn_off:
- service: fan.turn_off
target:
entity_id: fan.office_fanlinc_fan
set_percentage:
- service: fan.set_percentage
target:
entity_id: fan.office_fanlinc_fan
data:
percentage: "{{ percentage }}"
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 %}
- service: script.turn_on
data: {}
target:
entity_id: >-
{% if preset_mode == 'high' %}
script.office_keypad_hi
{% elif preset_mode == 'medium' %}
script.office_keypad_med
{% elif preset_mode == 'low' %}
script.office_keypad_low
{% else %}
script.office_keypad_off
{% endif %}
preset_modes:
- "off"
- "low"
- "medium"
- "high"
speed_count: 3
script:
office_keypad_off:
sequence:
- service: switch.turn_off
entity_id: switch.office_keypadlinc_btn_3
- delay: 0.5
- service: switch.turn_off
entity_id: switch.office_keypadlinc_btn_4
- delay: 0.5
- service: switch.turn_off
entity_id: switch.office_keypadlinc_btn_5
- delay: 0.5
- service: switch.turn_on
entity_id: switch.office_keypadlinc_btn_6
office_keypad_low:
sequence:
- service: switch.turn_off
entity_id: switch.office_keypadlinc_btn_3
- delay: 0.5
- service: switch.turn_off
entity_id: switch.office_keypadlinc_btn_4
- delay: 0.5
- service: switch.turn_on
entity_id: switch.office_keypadlinc_btn_5
- delay: 0.5
- service: switch.turn_off
entity_id: switch.office_keypadlinc_btn_6
office_keypad_med:
sequence:
- service: switch.turn_off
entity_id: switch.office_keypadlinc_btn_3
- delay: 0.5
- service: switch.turn_on
entity_id: switch.office_keypadlinc_btn_4
- delay: 0.5
- service: switch.turn_off
entity_id: switch.office_keypadlinc_btn_5
- delay: 0.5
- service: switch.turn_off
entity_id: switch.office_keypadlinc_btn_6
office_keypad_hi:
sequence:
- service: switch.turn_on
entity_id: switch.office_keypadlinc_btn_3
- delay: 0.5
- service: switch.turn_off
entity_id: switch.office_keypadlinc_btn_4
- delay: 0.5
- service: switch.turn_off
entity_id: switch.office_keypadlinc_btn_5
- delay: 0.5
- service: switch.turn_off
entity_id: switch.office_keypadlinc_btn_6