/
scripts.yaml
262 lines (249 loc) · 7.29 KB
/
scripts.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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
'1549758477586':
alias: "Hue gaming scene"
sequence:
- service: hue.hue_activate_scene
data:
group_name: "Woonkamer"
scene_name: "Colorfull"
'1549758920504':
alias: "Hue watch TV scene"
sequence:
- service: hue.hue_activate_scene
data:
group_name: "Woonkamer"
scene_name: "TV kijken"
'1549758951085':
alias: "Hue full light scene"
sequence:
- service: hue.hue_activate_scene
data:
group_name: "Woonkamer"
scene_name: "Veel licht"
dimmer:
sequence:
- service: light.turn_on
data_template:
entity_id: '{{ light_id }}'
brightness: >-
{% set domain, name = light_id.split('.') %}
{% set current = states[domain][name].attributes.brightness | int %}
{% set step = states('input_number.light_step') | int %}
{% set action = swipe_action %}
{% if action == 'swipe_up' %}
{% set next = current + step | int %}
{% elif action == 'swipe_down' %}
{% set next = current - step | int %}
{% endif %}
{% if next > states('input_number.light_maximum') | int %}
{% set next = states('input_number.light_maximum') | int %}
{% elif next < states('input_number.light_minimum') | int %}
{% set next = states('input_number.light_minimum') | int %}
{% endif %}
{{ next }}
sonos_say:
alias: "Sonos TTS script"
sequence:
- service: sonos.snapshot
data_template:
entity_id: "{{ sonos_entity }}"
- service: sonos.unjoin
data_template:
entity_id: "{{ sonos_entity }}"
- service: media_player.volume_set
data_template:
entity_id: "{{ sonos_entity }}"
volume_level: "{{ volume }}"
- service: tts.google_translate_say
data_template:
entity_id: "{{ sonos_entity }}"
message: "{{ message }}"
- delay: "{{ delay }}"
- service: sonos.restore
data_template:
entity_id: "{{ sonos_entity }}"
read_weatherforecast:
alias: "Gesproken weerbericht"
sequence:
- service: script.sonos_say
data_template:
sonos_entity: media_player.speakers
volume: 0.2
delay: 8
message: >
{% if now().strftime("%H")|int < 12 %}
Goedemorgen het is {{now().strftime("%A")}}.
{% elif now().strftime("%H")|int < 18 %}
Goedemiddag.
{% else %}
Goedenavond.
{% endif %}
Het is momenteel {{states.sensor.br_symbol_2.state}} en {{states.sensor.br_temperature_2.state|round}} graden buiten.
turn_on_light:
sequence:
- service: homeassistant.toggle
data_template:
entity_id: light.hue_lightstrip_plus_1
- service: homeassistant.turn_off
data_template:
entity_id: input_boolean.visitor_ring
turn_off_downstair_lights:
sequence:
- service: light.turn_off
data_template:
entity_id: light.woonkamer
- service: light.turn_off
data_template:
entity_id: light.eetkamer
- service: light.turn_off
data_template:
entity_id: light.keuken
turn_off_indoor_lights:
sequence:
- service: light.turn_off
data_template:
entity_id: light.hal
- service: light.turn_off
data_template:
entity_id: light.woonkamer
- service: light.turn_off
data_template:
entity_id: light.eetkamer
- service: light.turn_off
data_template:
entity_id: light.keuken
- service: light.turn_off
data_template:
entity_id: light.kamer_rens
- service: light.turn_off
data_template:
entity_id: light.kamer_maxime
open_and_disarm:
sequence:
- service: alarm_control_panel.alarm_disarm
data_template:
entity_id: alarm_control_panel.home_alarm
code: !secret alarm_code
- service: lock.unlock
data_template:
entity_id: lock.poly_control_danalock_v3_btze_locked
goodnight:
sequence:
#Turn off lights
- service: light.turn_off
data_template:
entity_id: light.woonkamer
- service: light.turn_off
data_template:
entity_id: light.eetkamer
- service: light.turn_off
data_template:
entity_id: light.keuken
- service: light.turn_off
data_template:
entity_id: light.terras
# Condition
- condition: and
conditions:
- condition: time
after: '22:45:00'
before: '06:00:00'
- condition: or
conditions:
- condition: state
entity_id: device_tracker.iphone_x_alexander_2
state: 'home'
- condition: state
entity_id: device_tracker.iphone
state: 'home'
# Lock frontdoor
- service: lock.lock
data:
entity_id: lock.poly_control_danalock_v3_btze_locked
# Wish you goodnight
- service: script.sonos_say
data:
sonos_entity: media_player.speakers
volume: 0.2
message: 'Weltrusten'
# Alarm arm for night
- service: alarm_control_panel.alarm_arm_night
data:
entity_id: alarm_control_panel.home_alarm
code: !secret alarm_code
# Turn off stairs light after 1 minute
- delay: '00:01:00'
- service: light.turn_off
data_template:
entity_id: light.hal
goodmorning:
sequence:
# Turn on television for kids
- service: media_player.turn_on
data:
entity_id: media_player.mybraviatv
# Send notification with weather forecast
- service: notify.mobile_app_iphone_x_alexander
data:
title: Weerbericht van {{now().strftime("%A")}}
message: >
{% if now().strftime("%H")|int < 12 %}
Goedemorgen.
{% elif now().strftime("%H")|int < 18 %}
Goedemiddag.
{% else %}
Goedenavond.
{% endif %}
Het is momenteel {{states.sensor.br_symbol_2.state}} en {{states.sensor.br_temperature_2.state|round}} graden buiten.
# Wait for television and change the source to NPO 3 HD
- delay:
seconds: 30
- service: media_player.select_source
data:
entity_id: media_player.mybraviatv
source: 'NPO 3 HD'
# Read weather forecast
- service: script.read_weatherforecast
- condition: sun
before: sunrise
before_offset: '+00:30:00' # Everything after this condition will only be executed up until 1 hour after sunset
# Turn on lights
- service: light.turn_on
data:
entity_id: light.hal
- service: hue.hue_activate_scene
data:
group_name: 'Woonkamer'
scene_name: 'TV kijken'
- service: light.turn_on
data:
entity_id: light.keuken
open_veraluxe_roof_half:
sequence:
- service: cover.open_cover
data_template:
entity_id: cover.lamellendak
- delay:
seconds: 12
- service: cover.stop_cover
data_template:
entity_id: cover.lamellendak
open_somfy_curtain_half:
sequence:
- service: cover.open_cover
data_template:
entity_id: cover.rolgordijn_voorraam
- delay:
seconds: 23
- service: cover.stop_cover
data_template:
entity_id: cover.rolgordijn_voorraam
close_somfy_curtain_half:
sequence:
- service: cover.close_cover
data_template:
entity_id: cover.rolgordijn_voorraam
- delay:
seconds: 23
- service: cover.stop_cover
data_template:
entity_id: cover.rolgordijn_voorraam