-
Notifications
You must be signed in to change notification settings - Fork 14
/
toggles.yaml
93 lines (88 loc) · 2.99 KB
/
toggles.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
- alias: Toggle - Game Room Lights
id: toggle_game_room_lights
trigger:
- platform: state
entity_id: switch.game_room_switch
variables:
continue: >
{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }}
to_state: >
{{ trigger.to_state.state | default('') if continue else '' }}
condition:
- condition: template
value_template: "{{ continue and to_state in ['on','off'] }}"
action:
- service: switch.turn_{{ to_state }}
target:
entity_id:
- switch.game_room_bookcase_outlet
- switch.game_room_buffet_outlet
- alias: Toggle - Basement Lights
id: toggle_basement_lights
trigger:
- platform: state
entity_id: switch.basement_stairs
variables:
continue: >
{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }}
to_state: >
{{ trigger.to_state.state | default('') if continue else '' }}
condition:
- condition: template
value_template: "{{ continue and to_state in ['on','off'] }}"
action:
- service: switch.turn_{{ to_state }}
target:
entity_id:
- switch.basement_cans
- alias: Toggle - Deck String Lights
id: toggle_deck_string_lights
trigger:
- platform: state
entity_id: &deck_string_entities
- switch.deck_mood_lighting
- switch.patio_string_light
variables:
entities: *deck_string_entities
state_list:
- 'on'
- 'off'
continue: >
{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }}
to_state: >
{{ trigger.to_state.state | default(none) if continue else none }}
targets: >
{{ expand(entities) | rejectattr('entity_id', 'eq', trigger.entity_id) | rejectattr('state', 'eq', to_state) | map(attribute='entity_id') | list if continue else [] }}
condition:
- condition: template
value_template: "{{ continue and to_state in state_list and targets | count > 0 }}"
action:
- service: switch.turn_{{ to_state }}
target:
entity_id: "{{ targets }}"
- alias: Toggle - Cabinet String Lights
id: toggle_cabinet_string_lights
mode: parallel
trigger:
- platform: state
entity_id: &cabinet_string_entities
- switch.kitchen_cabinet
- switch.wled_all_cabinets
variables:
entities: *cabinet_string_entities
state_list:
- 'on'
- 'off'
continue: >
{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }}
to_state: >
{{ trigger.to_state.state | default(none) if continue else none }}
targets: >
{{ expand(entities) | rejectattr('entity_id', 'eq', trigger.entity_id) | rejectattr('state', 'eq', to_state) | map(attribute='entity_id') | list if continue else [] }}
condition:
- condition: template
value_template: "{{ continue and to_state in state_list and targets | count > 0 }}"
action:
- service: switch.turn_{{ to_state }}
target:
entity_id: "{{ targets }}"