-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZ2M - Door Open - Save light state.yaml
91 lines (91 loc) · 3.15 KB
/
Z2M - Door Open - Save light state.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
blueprint:
name: Controller - Binary sensor change light and put it back in previous state
description: 'When a door is opened, change an entity to a particular state, and remember the previous state. On door close, revert back to previous state'
source_url: https://github.com/evorgevol/hassio/blob/main/Z2M%20-%20Door%20Open%20-%20Save%20light%20state.yaml
domain: automation
input:
controller_entity:
name: (Zigbee2MQTT) Controller Entity
description: The action sensor of the controller to use for the automation.
Choose a value only if the remote is integrated with Zigbee2MQTT.
default: ''
selector:
entity:
domain:
- binary_sensor
multiple: false
action_door_open:
name: (Optional) Action to run when door opens
description: Action to run when door opens
default: []
selector:
action: {}
helper_on_delay:
name: (Optional) Helper - Delay in taking previous state
description: Delay between turning on the light and recording the previous state of the light.
default: 200
selector:
number:
min: 100.0
max: 5000.0
unit_of_measurement: milliseconds
mode: box
step: 10.0
variables:
trigger_action: '{{ trigger.event.data.new_state.state }}'
helper_on_delay: !input helper_on_delay
action_entities: !input action_door_open
controller_entity: !input controller_entity
action_target: '{{ action_entities[0].target.entity_id }}'
mode: restart
max_exceeded: silent
trigger:
- platform: event
event_type: state_changed
event_data:
entity_id: !input controller_entity
condition:
- condition: and
conditions:
- '{{ trigger.event.data.new_state.state not in ["","None"] }}'
- '{{ trigger.event.data.new_state.state != trigger.event.data.old_state.state }}'
action:
- choose:
- conditions: "{{ trigger_action == 'on' }}"
sequence:
- action: scene.create
data:
scene_id: evo_dooropen_before_pre
snapshot_entities: '{{ action_target }}'
- action: light.turn_on
target:
entity_id: '{{ action_target }}'
- delay:
milliseconds: !input helper_on_delay
- action: scene.create
data:
scene_id: evo_dooropen_before
snapshot_entities: '{{ action_target }}'
- choose:
- conditions: []
sequence: !input action_door_open
- conditions: "{{ trigger_action == 'off' }}"
sequence:
- action: scene.turn_on
target:
entity_id: scene.evo_dooropen_before
- delay:
milliseconds: !input helper_on_delay
- action: scene.turn_on
target:
entity_id: scene.evo_dooropen_before_pre
- action: scene.delete
metadata: {}
data: {}
target:
entity_id: scene.evo_dooropen_before
- action: scene.delete
metadata: {}
data: {}
target:
entity_id: scene.evo_dooropen_before_pre