forked from samuelthng/t-house-blueprints
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotifications.yaml
355 lines (355 loc) · 15.7 KB
/
notifications.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
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
blueprint:
name: "\U0001F514 Actionable Notification with Confirm, Dismiss and Timeout"
description: "### Customised Version of [\U0001F517 Github Link](https://github.com/samuelthng/t-house-blueprints/blob/main/notifications.yaml)
Modified Notification Service to send a notification to a group of devices instead of just one.\n[](https://my.home-assistant.io/redirect/blueprint_import/?blueprint_url=https%3A%2F%2Fgithub.com%2FDrShivang%2Ft-house-blueprints%2Fblob%2Fa46430348713ef0551e354df093158b1a6c7e9e9%2Fnotifications.yaml)\n\n---\n###
Version: 1.4\n*Forked from Home Assistant's [Confirmable Notifications](https://github.com/home-assistant/core/blob/master/homeassistant/components/script/blueprints/confirmable_notification.yaml)*\n####
Known Issues:\n - In some cases, iOS does not seem to play well with newer features. \n If that happens to you, you can [check out older releases here](https://github.com/samuelthng/t-house-blueprints/releases).\n\n---\n##
Features:\n - \U0001F4F2 Sends a notification to a device with companion app installed.\n - ✅ Confirm button with custom label and actions\n - ❌ Dismiss
button with custom label and actions\n - ⌛️ Timeout actions with custom duration, fired if no `confirm` or `dismiss` response received.\n - \U0001F9F9 Dismiss
notification if no response received after timeout duration.\n\n#### Examples can be found [here](https://community.home-assistant.io/t/notification-with-confirm-dismiss-and-timeout/551552#example-usage-6).\n---\n##
Changelog\n### Version 1.4 - *7 Jul 2023*\n - Reverted: Send clear notification command - for iOS compatibility.\n - Added: `subtitle`, `group`, `visibility`.\n
\ - Refactor: `tag` is no longer recommended, will use `entity_id` by default.\n \ - Fixed: During a timeout, the script throws error into logs due to checking
attribs of `None` type.\n\n### Version 1.3.2 - *28 Jun 2023*\n - [Added: `Action Icons`](https://github.com/samuelthng/t-house-blueprints/pull/9) - ` iOS Only`
- Thanks [@ChrisMancini](https://github.com/ChrisMancini)\n - Fixed: Missing default values for a couple of inputs\n - Updated: Input description style\n\n###
Version 1.3.1 - *10 Jun 2023*\n - Fixed: `Enable Icon Color`\n - Updated: `Icon Color` hex template\n\n### Version 1.3 - *9 Jun 2023* [\U0001F517](https://community.home-assistant.io/t/notification-with-confirm-dismiss-and-timeout/551552#version-13-9-jun-2023-9)\n###
Version 1.2 - *30 May 2023* [\U0001F517](https://community.home-assistant.io/t/notification-with-confirm-dismiss-and-timeout/551552#version-12-30-may-2023-10)\n###
Version 1.1 - *25 March 2023* [\U0001F517](https://community.home-assistant.io/t/notification-with-confirm-dismiss-and-timeout/551552#version-11-25-march-2023-11)\n"
domain: script
source_url: https://github.com/DrShivang/t-house-blueprints/blob/a46430348713ef0551e354df093158b1a6c7e9e9/notifications.yaml
input:
notify_gpname:
name: "\U0001F4F2 Devices to notify"
description: The notify group to which to send the notification.
selector:
text: {}
title:
name: "\U0001F3F7️ Title"
description: "The title of the notification. \n\n`Optional`\n"
default: ''
selector:
text: {}
subtitle:
name: "\U0001F3F7️ Subtitle"
description: "The subtitle of the notification. \n\n`Optional`\n"
default: ''
selector:
text: {}
message:
name: "\U0001F4AC Message"
description: "The message body to display on the notification. \n\n`\U0001F916
Android`: You may add [HTML formatting](https://companion.home-assistant.io/docs/notifications/notifications-basic?_highlight=tag#notification-message-html-formatting)
to customise the look of the message."
selector:
text: {}
icon:
name: "\U0001F642 Icon"
description: "Custom icon for this notification. \n\n`\U0001F916 Android Only`,
`Optional` \n"
default: ''
selector:
icon: {}
enable_icon_color:
name: "\U0001F3A8 Use Icon Color"
description: "If disabled, uses default icon color. \n\n`\U0001F916 Android
Only`, `Optional` \n"
default: false
selector:
boolean: {}
icon_color:
name: "\U0001F3A8 Icon Color"
description: "Custom icon color for this notification. \n\n`\U0001F916 Android
Only`, `Optional` \n"
default:
- 102
- 186
- 240
selector:
color_rgb: {}
confirm_text:
name: 1️⃣ Option 1 Text
description: Text to show on the first option.
default: Confirm
selector:
text: {}
confirm_action:
name: 1️⃣ Option 1 Action(s)
description: "Action(s) to run when the first option is selected. \n\n`Optional`
\ \n"
default: []
selector:
action: {}
confirm_icon:
name: 1️⃣ Option 1 Icon
description: "Custom icon to show on the first option. \n\nPrefix: `sfsymbols:`
\ \nPlease refer to the [documentation here](https://companion.home-assistant.io/docs/notifications/actionable-notifications#icon-values).
\ \nIcon reference: https://sfsymbols.com/. \nThere are more reference pages
out there, feel free to use a search engine! \n\n` iOS Only`, `Optional`
\ \n"
default: ''
selector:
text: {}
dismiss_text:
name: 2️⃣ Option 2 Text
description: Text to show on the second option.
default: Dismiss
selector:
text: {}
dismiss_action:
name: 2️⃣ Option 2 Action(s)
description: "Action(s) to run when the second option is selected. \n\n`Optional`
\ \n"
default: []
selector:
action: {}
dismiss_icon:
name: 2️⃣ Option 2 Icon
description: "Custom icon to show on the second option. \n\nPrefix: `sfsymbols:`
\ \nPlease refer to the [documentation here](https://companion.home-assistant.io/docs/notifications/actionable-notifications#icon-values).
\ \nIcon reference: https://sfsymbols.com/. \nThere are more reference pages
out there, feel free to use a search engine! \n\n` iOS Only`, `Optional`
\ \n"
default: ''
selector:
text: {}
enable_timeout:
name: ⌛️ Enable Timeout
description: ⚠️ If disabled, script will wait for response indefinitely until
the next time it is triggered.
default: true
selector:
boolean: {}
timeout:
name: ⌛️ Timeout Duration
description: "Amount of time to wait for an action response before firing timeout
action. \n\nRecommended: ≳ 1 minute, to allow notifications to be sent. \nDefault:
15 minutes. \n"
default:
hours: 0
minutes: 15
seconds: 0
selector:
duration:
enable_day: false
timeout_action:
name: ⌛️ Timeout Action(s)
description: "Action to run when notification response is timed out. \n\n`Optional`
\ \n"
default: []
selector:
action: {}
swipe_away_as_timeout:
name: ⌛️ Run timeout action(s) when notification cleared
description: "If enabled, swiping the notification away will immediately trigger
timeout actions. \n\n`\U0001F916 Android Only` \n"
default: false
selector:
boolean: {}
clear_on_timeout:
name: "\U0001F9F9 Clear notification on timeout"
description: "Dismiss the notification after action selection times out. \n"
default: false
selector:
boolean: {}
persist:
name: "\U0001F6A9 Persistent Notification"
description: "Ensures that notification cannot be dismissed by swiping away.
\ \n\n`\U0001F916 Android Only` \n"
default: false
selector:
boolean: {}
notification_link:
name: "\U0001F517 Notification Link"
description: "Link to navigate to upon clicking the notification. \n\n Examples:
\ \n - Home Assistant relative links: `/config/updates` or `/lovelace/home`
\ \n - Apps: `app://<package name>` \n - Entity `More Info` Panel: `entityId:<entity_ID>`
\ \n - Deep links: `deep-link://<deep_link>` \n\nSee [documentation](https://companion.home-assistant.io/docs/notifications/notifications-basic/#opening-a-url)
for more information and options. \n\n`Optional` \n"
default: ''
selector:
text: {}
tag:
name: "\U0001F516 Tag"
description: "Used to uniquely identify the notification. \n\nUse tag if you
are using this script with other notification services. \nLeave empty otherwise.
\ \n\nExample: `my_awesome_notification_for_device_X` \n\n`Optional` \n"
default: ''
selector:
text: {}
group:
name: "\U0001F4E3 Notification Group ID"
description: "Used for grouping different notifications together visually. \n\n⚠️
iOS critical notifications do no support grouping. \nSee [documentation](https://companion.home-assistant.io/docs/notifications/notifications-basic?_highlight=tag#grouping)
for more information. \n\n`Optional` \n"
default: ''
selector:
text: {}
channel:
name: "\U0001F4E3 Notification Channel"
description: "Defines the channel, to be used with Importance. \nRelates to
the importance of the notification. \n\n`\U0001F916 Android Only`, `Optional`
\ \n"
default: General
selector:
text: {}
importance:
name: ❕ Notification Channel Importance
description: "See [documentation](https://companion.home-assistant.io/docs/notifications/notifications-basic/#notification-channel-importance)
for more information. \n\n`\U0001F916 Android Only` \n"
default: default
selector:
select:
options:
- label: Urgent (Makes a sound with heads-up notification)
value: high
- label: Default (Makes a sound)
value: default
- label: Silent (Makes no sound)
value: low
- label: Low (Makes no sound, doesn't appear in status bar)
value: min
custom_value: false
multiple: false
interruption_level:
name: ❕ Interruption Level
description: "See [documentation](https://companion.home-assistant.io/docs/notifications/notifications-basic/#interruption-level)
for more information. \n\n` iOS Only` \n"
default: active
selector:
select:
options:
- label: Silent (Makes no sound, does not wake screen)
value: passive
- label: Default
value: active
- label: Important (Overrides Focus)
value: time-sensitive
- label: Critical (Overrides Focus and Mute, restricted features)
value: critical
custom_value: false
multiple: false
visibility:
name: "\U0001F50F Notification Lockscreen Visibility"
description: "Show or hide notification content on the lockscreen. \nSee [documentation](https://companion.home-assistant.io/docs/notifications/notifications-basic?_highlight=tag#notification-sensitivity--lock-screen-visibility)
for more information. \n\nDefault: `Private` \n\n`\U0001F916 Android Only`
\ \n"
default: private
selector:
select:
options:
- label: 'Public: Always show content.'
value: public
- label: 'Private: Show content based on phone settings.'
value: private
- label: 'Secret: Always hide content on the lockscreen.'
value: secret
custom_value: false
multiple: false
mode: restart
sequence:
- alias: Set up variables
variables:
custom_tag: !input tag
first_option: '{{ ''FIRST_'' ~ context.id }}'
second_option: '{{ ''SECOND_'' ~ context.id }}'
enable_timeout: !input enable_timeout
clear_on_timeout: !input clear_on_timeout
persist: !input persist
timeout: !input timeout
timeout_seconds: '{{ (timeout.hours * 60 + timeout.minutes) * 60 + timeout.seconds
}}'
enable_icon_color: !input enable_icon_color
icon_color_selector: !input icon_color
icon_color_hex: '{{ "#{:02x}{:02x}{:02x}".format(icon_color_selector[0], icon_color_selector[1],
icon_color_selector[2]) }}'
swipe_away_as_timeout: !input swipe_away_as_timeout
- alias: Send notification
service: !input notify_gpname
data:
title: !input title
message: !input message
data:
subtitle: !input subtitle
subject: !input subtitle
actions:
- action: '{{ first_option }}'
title: !input confirm_text
icon: !input confirm_icon
- action: '{{ second_option }}'
title: !input dismiss_text
icon: !input dismiss_icon
visbility: !input visibility
tag: '{{ iif(custom_tag|length, tag, this.entity_id)}}'
group: '{{ iif(group|length, group, ) }}'
persistent: !input persist
channel: !input channel
importance: !input importance
push:
interruption-level: !input interruption_level
notification_icon: !input icon
color: '{{ iif(enable_icon_color, icon_color_hex, )}}'
clickAction: !input notification_link
url: !input notification_link
timeout: '{{ iif(enable_timeout and clear_on_timeout, timeout_seconds, )}}'
- if:
- alias: Should await response with timeout?
condition: template
value_template: '{{ enable_timeout == true }}'
then:
- alias: Awaiting response with timeout…
wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ first_option }}'
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ second_option }}'
- platform: event
event_type: mobile_app_notification_cleared
event_data:
action_1_key: '{{ first_option }}'
action_2_key: '{{ second_option }}'
timeout: !input timeout
continue_on_timeout: true
else:
- alias: Awaiting response indefinitely…
wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ first_option }}'
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ second_option }}'
- platform: event
event_type: mobile_app_notification_cleared
event_data:
action_1_key: '{{ first_option }}'
action_2_key: '{{ second_option }}'
- choose:
- alias: 'Trigger: Timeout'
conditions: '{{ wait.trigger == none }}'
sequence: !input timeout_action
- alias: 'Trigger: Notification Cleared'
conditions: '{{ swipe_away_as_timeout and wait.trigger.event.event_type == ''mobile_app_notification_cleared''
}}'
sequence: !input timeout_action
- alias: 'Trigger: first_option'
conditions: '{{ wait.trigger.event.data.action == first_option }}'
sequence: !input confirm_action
- alias: 'Trigger: second_option'
conditions: '{{ wait.trigger.event.data.action == second_option }}'
sequence: !input dismiss_action
- if:
- alias: Should send clear notification command? (for iOS/macOS)
condition: template
value_template: '{{ enable_timeout and clear_on_timeout }}'
then:
- alias: Send clear notification command
service: !input notify_gpname
data:
message: clear_notification
data:
tag: '{{ iif(custom_tag|length, tag, this.entity_id)}}'