forked from panhans/HomeAssistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththeatre_mode.yaml
167 lines (143 loc) · 3.61 KB
/
theatre_mode.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
blueprint:
name: Theatre Mode
description: >
**Features**
- activates playing or paused scene depending on the media player state
- stores the states of the entities of the playing scene before it gets activated and restores states after you finish the movie
- transition time for switching scenes
**Help & FAQ**: [Scene based theatre mode](https://community.home-assistant.io/t/scene-based-theatre-mode/525457)
**Version**: 1.0
source_url: "https://github.com/panhans/homeassistant/blob/main/blueprints/automation/panhans/theatre_mode.yaml"
domain: automation
input:
media_player:
name: Media Player
description: Media player which triggers automation.
selector:
entity:
filter:
domain: media_player
scene_playing:
name: Play Scene
description: Activated when playing
selector:
entity:
filter:
domain: scene
scene_paused:
name: Pause Scene
description: Activated when paused
selector:
entity:
filter:
domain: scene
reaction_time:
name: Reaction time
description: Time (seconds) the player must be in the state before the scenes get triggered.
default: 2
selector:
number:
min: 1
max: 10
step: 1
mode: slider
transition:
name: Transition
description: Transition time for scenes in seconds.
default: 1
selector:
number:
min: 1
max: 10
step: 1
mode: slider
variables:
scene_uuid_dim: 'ebe235c62de111eda2610242ac120002'
scene_playing: !input scene_playing
scene_entities: "{{ state_attr(scene_playing,'entity_id') }}"
media_player: !input media_player
trigger:
- platform: state
entity_id: !input media_player
from:
- "idle"
- "off"
- "stopped"
- "standby"
- "unknown"
- "unavailable"
to: "playing"
id: create_scene
for:
seconds: !input reaction_time
- platform: state
entity_id: !input media_player
from: "playing"
to: "paused"
id: paused
for:
seconds: !input reaction_time
- platform: state
entity_id: !input media_player
to: "playing"
from: "paused"
id: playing
for:
seconds: !input reaction_time
- platform: state
entity_id: !input media_player
to:
- "idle"
- "off"
- "stopped"
- "standby"
- "unknown"
- "unavailable"
id: stopped
for:
seconds: !input reaction_time
action:
- if:
- condition: trigger
id: create_scene
then:
- service: scene.create
data:
scene_id: "{{ scene_uuid_dim }}"
snapshot_entities: "{{ scene_entities }}"
- delay:
seconds: 2
- service: scene.turn_on
data:
transition: !input transition
target:
entity_id: !input scene_playing
# play form paused -> scene aktivieren
- if:
- condition: trigger
id: playing
then:
- service: scene.turn_on
data:
transition: !input transition
target:
entity_id: !input scene_playing
- if:
- condition: trigger
id: paused
then:
- service: scene.turn_on
data:
transition: !input transition
target:
entity_id: !input scene_paused
- if:
- condition: trigger
id: stopped
then:
- service: scene.turn_on
data:
transition: !input transition
target:
entity_id: "scene.{{ scene_uuid_dim }}"
mode: queued