-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathSyncStatesFour.yml
75 lines (74 loc) · 2.52 KB
/
SyncStatesFour.yml
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
#
# Home Assistant Automation Blueprint
#
# Synchronize on/off states on four devices
#
# Revision 1.3 - Added condition to handle unavailable states
# Modified by Johan Schelin, Apr. 2021
#
blueprint:
name: Synchronize Four States
description: Bind four entities together to act in unison (selected entites must
all support the same state values). In this version restricted to on/off
domain: automation
input:
switch_1:
name: Entity 1
selector:
entity: {}
switch_2:
name: Entity 2
selector:
entity: {}
switch_3:
name: Entity 3
default:
selector:
entity: {}
switch_4:
name: Entity 4
default:
selector:
entity: {}
source_url: https://github.com/johanschelin/ha_blueprints/blob/main/SyncStatesFour.yml
mode: single
max_exceeded: silent
variables:
switch_1: !input 'switch_1'
switch_2: !input 'switch_2'
switch_3: !input 'switch_3'
switch_4: !input 'switch_4'
trigger:
- platform: state
entity_id:
- !input 'switch_1'
- !input 'switch_2'
- !input 'switch_3'
- !input 'switch_4'
from:
- 'on'
- 'off'
condition:
- condition: template
value_template: '{{ states(switch_1) != ''unavailable'' }}'
- condition: template
value_template: '{{ states(switch_2) != ''unavailable'' }}'
- condition: template
value_template: '{{ states(switch_3) != ''unavailable'' }}'
- condition: template
value_template: '{{ states(switch_4) != ''unavailable'' }}'
action:
- service: homeassistant.turn_{{ trigger.to_state.state }}
data:
entity_id: '{% if trigger.from_state.entity_id == switch_1 %} {{ switch_2 }} {% elif trigger.from_state.entity_id == switch_2 %} {{ switch_1 }} {% elif trigger.from_state.entity_id == switch_3 %} {{ switch_1 }} {% else %} {{ switch_1 }} {% endif %}'
- service: homeassistant.turn_{{ trigger.to_state.state }}
data:
entity_id: '{% if trigger.from_state.entity_id == switch_1 %} {{ switch_3 }} {% elif trigger.from_state.entity_id == switch_2 %} {{ switch_3 }} {% elif trigger.from_state.entity_id == switch_3 %} {{ switch_2 }} {% else %} {{ switch_2 }} {% endif %}'
- service: homeassistant.turn_{{ trigger.to_state.state }}
data:
entity_id: '{% if trigger.from_state.entity_id == switch_1 %} {{ switch_4 }} {% elif trigger.from_state.entity_id == switch_2 %} {{ switch_4 }} {% elif trigger.from_state.entity_id == switch_3 %} {{ switch_4 }} {% else %} {{ switch_3 }} {% endif %}'
- delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0