-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswitch_turn_on_script.yaml
35 lines (35 loc) · 1.15 KB
/
switch_turn_on_script.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
alias: SwitchTurnOn
sequence:
- if:
- condition: template
value_template: "{{ states(switch_entity_id) == 'off' }}"
then:
- if:
- condition: template
value_template: |
{{ switch_entity_id.startswith('light') }}
then:
- service: light.turn_on
target:
device_id: "{{ device_id(switch_entity_id) }}"
else:
- service: switch.turn_on
target:
device_id: "{{ device_id(switch_entity_id) }}"
- if:
- condition: template
value_template: |
{{ offset is defined and
switch_entity_id.startswith('light') and
((offset > 0 and (state_attr(switch_entity_id, 'brightness') or 40) < 255) or
(offset < 0 and (state_attr(switch_entity_id, 'brightness') or 40) > 40)) }}
then:
- service: light.turn_on
data_template:
brightness: >-
{{[[(state_attr(switch_entity_id, 'brightness') or 40) + offset,
40]|max, 255]|min}}
target:
device_id: "{{ device_id(switch_entity_id) }}"
mode: single
icon: mdi:light-switch