-
Notifications
You must be signed in to change notification settings - Fork 0
/
synchronize_2_entities_states.yaml
42 lines (42 loc) · 1.14 KB
/
synchronize_2_entities_states.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
blueprint:
name: Synchronize entities states
description: Synchronize 2 entities states
domain: automation
input:
entity_1:
name: First entity
selector:
entity: {}
entity_2:
name: Second entity
selector:
entity: {}
feature_switch:
name: Validation boolean
description: Boolean helper specifying if the the automation is on or off
selector:
entity:
domain: input_boolean
multiple: false
source_url: https://github.com/Highjack77/homeassistant/blob/main/synchronize_2_entities_states.yaml
variables:
entity_1: !input entity_1
entity_2: !input entity_2
trigger:
- platform: state
entity_id: !input entity_1
- platform: state
entity_id: !input entity_2
condition:
- condition: state
entity_id: !input feature_switch
state: 'on'
- condition: template
value_template: "{{ trigger.to_state.state != 'unavailable' }}"
action:
- service: homeassistant.turn_{{ trigger.to_state.state }}
data:
entity_id: '{% if trigger.from_state.entity_id == entity_1 %} {{ entity_2 }} {%
else %} {{ entity_1 }} {% endif %}'
mode: restart
max_exceeded: silent