-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathSyncStates-2.yaml
48 lines (47 loc) · 1.36 KB
/
SyncStates-2.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
#
# Home Assistant Automation Blueprint
#
# Synchronize on/off states on three devices
#
# Revision 1.3 - Added condition to handle unavailable states
# Modified by Johan Schelin, Apr. 2021
#
blueprint:
name: Synchronization status - 2
description: Bind two 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: First entity
description: Mandatory - The first entity to keep in sync.
selector:
entity: {}
switch_2:
name: Second entity
description: Mandatory - The second entity to keep in sync.
selector:
entity: {}
source_url: https://github.com/johanschelin/ha_blueprints/edit/main/SyncStates-2
mode: restart
max_exceeded: silent
variables:
switch_1: !input 'switch_1'
switch_2: !input 'switch_2'
trigger:
- platform: state
entity_id:
- !input 'switch_1'
- !input 'switch_2'
from:
- 'on'
- 'off'
condition:
- condition: template
value_template: '{{ states(switch_1) != ''unavailable'' }}'
- condition: template
value_template: '{{ states(switch_2) != ''unavailable'' }}'
action:
- service: homeassistant.turn_{{ trigger.to_state.state }}
data:
entity_id: '{% if trigger.from_state.entity_id == switch_1 %} {{ switch_2 }} {% else %} {{ switch_1 }} {% endif %}'