-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathpack_domofon.yaml
More file actions
330 lines (315 loc) · 13.2 KB
/
pack_domofon.yaml
File metadata and controls
330 lines (315 loc) · 13.2 KB
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
#################################################
# Package Domofon
#################################################
domofon_pack:
yandex_station_intents:
intents:
Открой домофон:
# extra_phrases:
# - Домофон открой
say_phrase: "{{ ['Окей', 'Хорошо', 'Открываю']|random }}"
automation:
- alias: Domofon - Opened by Button Notification
id: cb5e25c1-dcb7-4b75-a6c4-6b12eb84f86b
triggers:
trigger: state
entity_id: binary_sensor.domofon_button
to: "on"
conditions:
- condition: state
entity_id: binary_sensor.domofon_incoming_call
state: "on"
actions:
- action: telegram_bot.send_message
data:
chat_id: !secret tlg_group_flat_1
message: "_Домофон_: открыт кнопкой"
- alias: Domofon - Incoming Call Notification
id: 741a9858-1687-4b2d-8afd-73373e8cc8ba
triggers:
trigger: state
entity_id: binary_sensor.domofon_incoming_call
to: "on"
actions:
- parallel:
- action: telegram_bot.send_message
data:
chat_id: !secret tlg_group_flat_1
message: "_Домофон_: входящий звонок... {% if is_state('switch.domofon_automatically_open', 'on') or is_state('switch.domofon_automatically_open_once', 'on') %}(*откроется автоматически*){% endif %}"
inline_keyboard:
- "{{ '-' if is_state('switch.domofon_automatically_open', 'on') or is_state('switch.domofon_automatically_open_once', 'on') else 'Открыть:/domofon_open, Отклонить:/domofon_reject' }}"
- sequence:
- condition: "{{ is_state('switch.domofon_automatically_open_once', 'off') }}"
- action: script.domofon_alice_notify
- alias: Domofon - Alice Intent control
triggers:
- trigger: event
event_type: yandex_intent
event_data:
text: Открой домофон
id: "open"
actions:
choose:
- alias: Open Door
conditions:
- condition: trigger
id: "open"
sequence:
- action: esphome.domofon_accept_call
- alias: Domofon - Telegram Control - domofon_open
id: 99d5c580-c382-48b3-bd2d-f6eb00b62c31
triggers:
trigger: event
event_type: telegram_callback
event_data:
data: "/domofon_open"
actions:
- action: telegram_bot.answer_callback_query
data:
callback_query_id: "{{ trigger.event.data.id }}"
message: "{{ 'Открываю...' if is_state('binary_sensor.domofon_incoming_call', 'on') else 'Нет входящего звонка' }}"
- action: esphome.domofon_accept_call
- action: telegram_bot.edit_message
data:
message_id: "{{ trigger.event.data.message.message_id }}"
chat_id: "{{ trigger.event.data.chat_id }}"
message: |
_Домофон_: входящий звонок...
{{ 'Домофон *открыт*!' if is_state('binary_sensor.domofon_incoming_call', 'on') else '' }}
- alias: Domofon - Telegram Control - domofon_reject
id: a50fb75b-0083-4866-8496-bdd013332a88
triggers:
trigger: event
event_type: telegram_callback
event_data:
data: "/domofon_reject"
actions:
- action: telegram_bot.answer_callback_query
data:
callback_query_id: "{{ trigger.event.data.id }}"
message: "{{ 'Отклоняю...' if is_state('binary_sensor.domofon_incoming_call', 'on') else 'Нет входящего звонка' }}"
- action: esphome.domofon_reject_call
- action: telegram_bot.edit_message
data:
message_id: "{{ trigger.event.data.message.message_id }}"
chat_id: "{{ trigger.event.data.chat_id }}"
message: |
_Домофон_: входящий звонок...
{{ 'Звонок *сброшен*!' if is_state('binary_sensor.domofon_incoming_call', 'on') else '' }}
- alias: Domofon - Mute and UnMute by Time
id: 97a74c5f-6a9f-4af6-9f8e-2a7fcd0a5070
triggers:
- platform: time
at: "21:00:00"
- platform: time
at: "08:00:00"
actions:
- action: >-
{% if trigger.now.hour == 21 -%}
switch.turn_on
{% elif trigger.now.hour == 8 -%}
switch.turn_off
{% endif %}
data:
entity_id: switch.domofon_mute_sound
- alias: Domofon - ESP Board Lost Connection
id: 6cac01e7-945c-4f37-8b2d-d75e03107d76
triggers:
- trigger: state
entity_id: binary_sensor.domofon_status
not_to:
- unavailable
- unknown
not_from:
- unavailable
- unknown
conditions:
- condition: template
value_template: >-
{{ states('input_boolean.ha_shutdown') == 'off' }}
- condition: template
value_template: >-
{{ states('sensor.ha_uptime') > '1' }}
actions:
- action: telegram_bot.send_message
data:
chat_id: !secret tlg_group_system
message: |
*Внимание!*
{% if trigger.to_state.state == 'off' -%}
_Домофон_: потеряно подключение к HA.
{% elif trigger.to_state.state == 'on' -%}
_Домофон_: восстановлено подключение к HA
{% endif %}
- alias: Domofon - Open Once for Couriers
id: c916925d-cd33-4f30-882b-4049e52acf12
triggers:
- trigger: state
entity_id:
- sensor.kb2003_last_notification
- sensor.2109119dg_last_notification
condition:
- or:
- condition: template
value_template: >-
{{ trigger.to_state.state | regex_search('Курьер .* будет у вас в течение .*') }}
- condition: template
value_template: >-
{{ trigger.to_state.state | regex_search('В течение .* курьер .* будет у вас') }}
- condition: template
value_template: >-
{{ trigger.to_state.state | regex_search('Курьер в пути. .*') }}
- condition: template
value_template: >-
{{ trigger.to_state.state | regex_search('Курьер забрал заказ и везёт его к вам') }}
- condition: template
value_template: >-
{{ trigger.to_state.state | regex_search('Везёт заказ из Маркет Express') }}
- condition: template
value_template: >-
{{ trigger.to_state.state | regex_search('Уже спешит к вам') }}
- condition: template
value_template: >-
{{ trigger.to_state.state | regex_search('Будет через *.') }}
- condition: template
value_template: >-
{{ trigger.to_state.state | regex_search('Скоро заказ будет у вас') }}
- condition: template
value_template: >-
{{ trigger.to_state.state | regex_search('И уже спешит доставить его вам') }}
actions:
- action: switch.turn_on
target:
entity_id: switch.domofon_automatically_open_once
- action: telegram_bot.send_message
data:
chat_id: !secret tlg_group_flat_1
message: "_Домофон_: Курьер уже в пути, домофон откроется автоматически."
inline_keyboard:
- "Отключить звук:/domofon_mute_once"
- alias: Domofon - Telegram Control - domofon_mute_once
id: 97093f78-f059-4918-b451-ca50f698a49d
triggers:
trigger: event
event_type: telegram_callback
event_data:
data: "/domofon_mute_once"
actions:
- action: telegram_bot.answer_callback_query
data:
callback_query_id: "{{ trigger.event.data.id }}"
message: "Команда отправлена"
- action: switch.turn_on
target:
entity_id: switch.domofon_mute_sound_once
- action: telegram_bot.edit_message
data:
message_id: "{{ trigger.event.data.message.message_id }}"
chat_id: "{{ trigger.event.data.chat_id }}"
message: |
_Домофон_: Курьер уже в пути, домофон откроется автоматически.
Звонок домофона *отключен* (однократно).
- alias: Domofon - Open Once at Enter to Home Zone
id: 40d4a1f6-576c-438a-b20f-ba161d9bd3ee
max_exceeded: silent
triggers:
- trigger: zone
entity_id:
- person.alexander
- person.irina
zone: zone.domofon
event: enter
actions:
- action: switch.turn_on
target:
entity_id: switch.domofon_automatically_open_once
- action: switch.turn_on
target:
entity_id: switch.domofon_mute_sound_once
- action: telegram_bot.send_message
data:
chat_id: !secret tlg_group_flat_1
message: "_Домофон_: включен режим однократного авто-открытия."
- wait_for_trigger:
- trigger: state
entity_id: binary_sensor.0x158d00031c790f_contact
to: "on"
timeout: "00:10:00"
- choose:
- conditions: >-
{{ is_state('switch.domofon_automatically_open_once', 'on') }}
sequence:
- action: switch.turn_off
target:
entity_id: switch.domofon_automatically_open_once
- action: switch.turn_off
target:
entity_id: switch.domofon_mute_sound_once
- action: telegram_bot.send_message
data:
chat_id: !secret tlg_group_flat_1
message: "_Домофон_: отключен режим однократного авто-открытия."
script:
domofon_alice_notify:
sequence:
- action: media_player.volume_set
target:
entity_id: media_player.yandex_station_mini2_gostinaia
data:
volume_level: >-
{% set time = now().hour -%}
{% if time >= 21 or time < 9 -%}
0.4
{% else -%}
0.6
{% endif -%}
- action: media_player.play_media
target:
entity_id: media_player.yandex_station_mini2_gostinaia
data:
media_content_id: >-
{% set time = now().hour -%}
{% if time >= 21 or time < 9 -%}
<speaker is_whisper="true">Внимание! Звонок в домофон, открыть?
{% else -%}
Звонок в домофон, открыть?
{% endif -%}
media_content_type: dialog:Домашний Ассистент:Домофон
- wait_for_trigger:
trigger: event
event_type: yandex_intent
event_data:
session:
dialog: Домофон
timeout:
seconds: 10
continue_on_timeout: false
- choose:
- conditions: "{{ wait.trigger.event.data.text in ['да','конечно' ,'открой', 'открыть', 'открывай'] }}"
sequence:
- parallel:
- action: esphome.domofon_accept_call
- action: media_player.play_media
target:
entity_id: media_player.yandex_station_mini2_gostinaia
data:
media_content_id: "Открываю"
media_content_type: text
- action: telegram_bot.send_message
data:
chat_id: !secret tlg_group_flat_1
message: "_Домофон_: открыт Алисой."
- conditions: "{{ wait.trigger.event.data.text in ['нет'] }}"
sequence:
- parallel:
- action: esphome.domofon_reject_call
- action: media_player.play_media
target:
entity_id: media_player.yandex_station_mini2_gostinaia
data:
media_content_id: "Звонок сброшен"
media_content_type: text
- action: telegram_bot.send_message
data:
chat_id: !secret tlg_group_flat_1
message: "_Домофон_: звонок сброшен Алисой."