Created
June 4, 2024 04:58
-
-
Save tyrm/81c49565a0f2c55d5963657a2e54574a to your computer and use it in GitHub Desktop.
shelly box fan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fan: | |
- platform: template | |
fans: | |
box_fan_1: | |
friendly_name: "box_fan_1" | |
unique_id: "box_fan_1_4pm" | |
value_template: > | |
{% if is_state('switch.box_fan_1_high', 'on') %} | |
on | |
{% elif is_state('switch.box_fan_1_medium', 'on') %} | |
on | |
{% elif is_state('switch.box_fan_1_low', 'on') %} | |
on | |
{% else %} | |
off | |
{% endif %} | |
turn_on: | |
- service: switch.turn_on | |
target: | |
entity_id: > | |
{% if is_state('input_select.box_fan_1_last_state', 'Low') %} | |
switch.box_fan_1_low | |
{% elif is_state('input_select.box_fan_1_last_state', 'Medium') %} | |
switch.box_fan_1_medium | |
{% else %} | |
switch.box_fan_1_high | |
{% endif %} | |
turn_off: | |
- service: switch.turn_off | |
target: | |
entity_id: switch.box_fan_1_low | |
- service: switch.turn_off | |
target: | |
entity_id: switch.box_fan_1_medium | |
- service: switch.turn_off | |
target: | |
entity_id: switch.box_fan_1_high | |
percentage_template: > | |
{% if is_state('switch.box_fan_1_high', 'on') %} | |
100 | |
{% elif is_state('switch.box_fan_1_medium', 'on') %} | |
66 | |
{% elif is_state('switch.box_fan_1_low', 'on') %} | |
33 | |
{% else %} | |
0 | |
{% endif %} | |
speed_count: 3 | |
set_percentage: | |
- choose: | |
# IF high | |
- conditions: | |
- condition: template | |
value_template: "{{ 100 >= percentage and percentage > 66 }}" | |
sequence: | |
- service: switch.turn_on | |
target: | |
entity_id: switch.box_fan_1_high | |
- service: input_select.select_option | |
data: | |
option: High | |
target: | |
entity_id: input_select.box_fan_1_last_state | |
# IF medium | |
- conditions: | |
- condition: template | |
value_template: "{{ 66 >= percentage and percentage > 33 }}" | |
sequence: | |
- service: switch.turn_on | |
target: | |
entity_id: switch.box_fan_1_medium | |
- service: input_select.select_option | |
data: | |
option: Medium | |
target: | |
entity_id: input_select.box_fan_1_last_state | |
# IF low | |
- conditions: | |
- condition: template | |
value_template: "{{ 33 >= percentage and percentage > 0 }}" | |
sequence: | |
- service: switch.turn_on | |
target: | |
entity_id: switch.box_fan_1_low | |
- service: input_select.select_option | |
data: | |
option: Low | |
target: | |
entity_id: input_select.box_fan_1_last_state | |
# ELSE off | |
default: | |
- service: switch.turn_off | |
target: | |
entity_id: switch.box_fan_1_high | |
- service: switch.turn_off | |
target: | |
entity_id: switch.box_fan_1_medium | |
- service: switch.turn_off | |
target: | |
entity_id: switch.box_fan_1_low |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment