-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtwo-way-Switch-synchronization.yaml
More file actions
62 lines (54 loc) · 1.48 KB
/
two-way-Switch-synchronization.yaml
File metadata and controls
62 lines (54 loc) · 1.48 KB
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
blueprint:
name: Two-Way Switch Synchronization
description: >
## Bind two switches together to operate in unison
**Version**: v1.1
domain: automation
input:
switch_1:
name: Switch 1
selector:
entity:
domain: switch
switch_2:
name: Switch 2
selector:
entity:
domain: switch
variables:
switch_1: !input switch_1
switch_2: !input switch_2
trigger:
- platform: state
entity_id:
- !input switch_1
- !input switch_2
to:
- 'on'
- 'off'
# Using 'restart' mode to avoid missing rapid triggers
mode: restart
# Avoids reacting if the state has not actually changed
condition:
'{{ trigger.to_state.state != trigger.from_state.state }}'
action:
# Synchronization from Switch 1 to Switch 2
- choose:
- conditions:
- '{{ trigger.entity_id != switch_1 }}'
- '{{ trigger.to_state.state != states(switch_1) }}'
sequence:
- service: 'switch.turn_{{ trigger.to_state.state }}'
target:
entity_id: !input switch_1
# Synchronization from Switch 2 to Switch 1
- choose:
- conditions:
- '{{ trigger.entity_id != switch_2 }}'
- '{{ trigger.to_state.state != states(switch_2) }}'
sequence:
- service: 'switch.turn_{{ trigger.to_state.state }}'
target:
entity_id: !input switch_2
# Optional: Slight delay to prevent bouncing
- delay: '00:00:03'