├── README.md ├── ad_hoc_scheduled_interval.yaml └── notifications.yaml /README.md: -------------------------------------------------------------------------------- 1 | # T-House Blueprints 2 | Repository for blueprints that is polished enough for public sharing. 3 | 4 | | Name | Domain | Version | Import Blueprint | Github Link | 5 | | --- | --- | --- | --- | --- | 6 | | 🔔 Notifications | Script | 2.0.1 | [![Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.](https://my.home-assistant.io/badges/blueprint_import.svg)](https://my.home-assistant.io/redirect/blueprint_import/?blueprint_url=https%3A%2F%2Fgithub.com%2Fsamuelthng%2Ft-house-blueprints%2Fblob%2Fmain%2Fnotifications.yaml) | [🔗](https://github.com/samuelthng/t-house-blueprints/blob/main/notifications.yaml) | 7 | | ⏱️ Scheduled Interval | Automation | 1.0.0 | [![Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.](https://my.home-assistant.io/badges/blueprint_import.svg)](https://my.home-assistant.io/redirect/blueprint_import/?blueprint_url=https%3A%2F%2Fgithub.com%2Fsamuelthng%2Ft-house-blueprints%2Fblob%2Fmain%2Fad_hoc_scheduled_interval.yaml) | [🔗](https://github.com/samuelthng/t-house-blueprints/blob/main/ad_hoc_scheduled_interval.yaml) | 8 | -------------------------------------------------------------------------------- /ad_hoc_scheduled_interval.yaml: -------------------------------------------------------------------------------- 1 | blueprint: 2 | name: "⏱️ Scheduled Interval" 3 | domain: automation 4 | description: > 5 | A simple automation that runs within a time window and performs actions between intervals. 6 | 7 | Ad-hoc blueprint for [🔗 this community post](https://community.home-assistant.io/t/repeat-until-time-in-automation-stops-earlier-than-the-scheduled-time/661967). 8 | input: 9 | start_time: 10 | name: Start Time 11 | description: When do you want to start the automation? 12 | selector: 13 | time: 14 | start_action: 15 | name: Start Actions 16 | description: What do you want to do when the automation starts? 17 | selector: 18 | action: 19 | end_time: 20 | name: End Time 21 | description: What do you want to end the automation? 22 | selector: 23 | time: 24 | end_action: 25 | name: End Actions 26 | description: What do you want to do when the automation ends? 27 | selector: 28 | action: 29 | interval_entity: 30 | name: Entity to watch for changes 31 | description: > 32 | Which entities to watch? 33 | 34 | Consider adding all entities involved. For example, the light you intend to turn on, and the color vector selector. 35 | selector: 36 | entity: 37 | multiple: true 38 | interval_duration: 39 | name: Duration before next cycle action 40 | description: How long to wait between any state changes in the entities selected above? 41 | default: 42 | hours: 0 43 | minutes: 0 44 | seconds: 5 45 | selector: 46 | duration: 47 | interval_action: 48 | name: Interval Action 49 | description: What to do on each interval? 50 | selector: 51 | action: 52 | 53 | mode: single 54 | 55 | 56 | trigger: 57 | - platform: time 58 | at: !input start_time 59 | id: Start Time 60 | - platform: time 61 | at: !input end_time 62 | id: End Time 63 | - platform: state 64 | entity_id: !input interval_entity 65 | for: !input interval_duration 66 | id: Change Interval 67 | 68 | condition: [] 69 | 70 | action: 71 | - if: 72 | - condition: trigger 73 | id: 74 | - Start Time 75 | then: !input start_action 76 | - if: 77 | - condition: trigger 78 | id: 79 | - End Time 80 | then: !input end_action 81 | - if: 82 | - condition: trigger 83 | id: 84 | - Change Interval 85 | - Start Time 86 | - condition: time 87 | after: input_datetime.test_start_time 88 | before: input_datetime.test_end_time 89 | then: !input interval_action -------------------------------------------------------------------------------- /notifications.yaml: -------------------------------------------------------------------------------- 1 | mode: restart 2 | blueprint: 3 | name: 🔔 Notifications (Version 2.0.2 Beta) 4 | source_url: https://github.com/samuelthng/t-house-blueprints/blob/main/notifications.yaml 5 | homeassistant: 6 | min_version: 2023.11.0 7 | domain: script 8 | author: samuelthng/t-house-blueprints 9 | description: >- 10 |
11 |

🔔 Notifications

12 | Version 2.0.2 Beta | 🔗 Github Link | 💬 Community Post 13 |
14 |
15 | 16 | --- 17 | 18 | ### Features: 19 | 20 | > 📲 Sends notification to [Home Assistant Companion](https://companion.home-assistant.io/) 21 | 22 | > 3️⃣ Up to 3 customisable, action buttons (Previously: ✅ Confirm and ❌ Dismiss Button) 23 | 24 | > ⌛️ Timeout actions with custom duration, fired if no option response received 25 | 26 | > 🧹 Clear notification after timeout 27 | 28 | > 📸 Camera Snapshots 29 | 30 | > 🔗 Custom Notification Link 31 | 32 | > 📜 Flexible [script fields](https://www.home-assistant.io/integrations/script/#fields) 33 | 34 | > 🍎 Supports iOS 35 | 36 | > 🤖 Supports Android 37 | 38 | Examples can be found [here](https://community.home-assistant.io/t/notification-with-confirm-dismiss-and-timeout/551552#example-usage-6) 39 | 40 | ### Changelog 41 | 42 |
43 | Expand/collapse changelog 44 | 45 | ### Version 2.0.2 Beta Multiple Device - *19 Jan 2023* 46 | - Added: Field for `notification_link`. [#26](https://github.com/samuelthng/t-house-blueprints/pull/26) (Thanks to [HNKNTA](https://github.com/HNKNTA)) 47 | - Fixed: Field `enable_timeout`. 48 | - Added: `response_variable` with payload and response. 49 | 50 | ### Version 2.0.1 - *20 Dec 2023* [🔗](https://community.home-assistant.io/t/notifications-actionable-mobile-notifications-script-with-optional-timeout-feature-and-camera-snapshots-works-with-ios-android/551552/111?u=samuelthng) 51 | 52 | ### Version 2 - *12 Dec 2023* [🔗](https://community.home-assistant.io/t/notifications-actionable-mobile-notifications-script-with-optional-timeout-feature-and-camera-snapshots-works-with-ios-android/551552/109) 53 | 54 | ### Version 1.6.1 - *26 Oct 2023* [🔗](https://community.home-assistant.io/t/notifications-actionable-mobile-notifications-script-with-optional-timeout-feature-and-camera-snapshots-works-with-ios-android/551552/66) 55 | 56 | ### Version 1.6 - *26 Oct 2023* [🔗](https://community.home-assistant.io/t/notifications-actionable-mobile-notifications-script-with-optional-timeout-feature-and-camera-snapshots-works-with-ios-android/551552/62) 57 | 58 | ### Version 1.5 - *11 Oct 2023* [🔗](https://community.home-assistant.io/t/notifications-actionable-mobile-notifications-script-with-optional-timeout-feature-and-camera-snapshots-works-with-ios-android/551552#version-14-7-jul-2023-8) 59 | 60 | ### Version 1.4 - *7 Jul 2023* [🔗](https://community.home-assistant.io/t/notification-with-confirm-dismiss-and-timeout/551552#version-14-7-jul-2023-8) 61 | 62 | ### Version 1.3.2 - *28 Jun 2023*[🔗](https://community.home-assistant.io/t/notification-with-confirm-dismiss-and-timeout/551552#version-132-28-jun-2023-9) 63 | 64 | ### Version 1.3.1 - *10 Jun 2023* [🔗](https://community.home-assistant.io/t/notification-with-confirm-dismiss-and-timeout/551552#version-131-10-jun-2023-10) 65 | 66 | ### Version 1.3 - *9 Jun 2023* [🔗](https://community.home-assistant.io/t/notification-with-confirm-dismiss-and-timeout/551552#version-13-9-jun-2023-9) 67 | 68 | ### Version 1.2 - *30 May 2023* [🔗](https://community.home-assistant.io/t/notification-with-confirm-dismiss-and-timeout/551552#version-12-30-may-2023-10) 69 | 70 | ### Version 1.1 - *25 March 2023* [🔗](https://community.home-assistant.io/t/notification-with-confirm-dismiss-and-timeout/551552#version-11-25-march-2023-11) 71 | 72 |
73 | 74 | ### Known Issues 75 | 76 |
77 | Expand/collapse known issues 78 | 79 | - In some cases, iOS does not seem to play well with newer features. 80 | If that happens to you, you can [check out older releases here](https://github.com/samuelthng/t-house-blueprints/releases). 81 | 82 | - In some cases, some setups have difficulty receiving events from the device. 83 | When this happens, no actions will be performed by Home Assistant. 84 | 85 | You can test this: 86 | - Navigate to Developer Tools → Events 87 | - Listen to event: `mobile_app_notification_action` 88 | - Trigger a notification to your device by running the script 89 | - Select an action option 90 | 91 | If you do not see an event appearing in the Events page, this could be the issue. 92 | You might want to check the [troubleshooting documents](https://companion.home-assistant.io/docs/troubleshooting/faqs), or check your network configuration to resolve the issue. 93 | 94 |
95 | 96 | ### FAQ 97 | 98 |
99 | Expand/collapse FAQ 100 | 101 | - **_Will you add sending notifications to multiple devices?_** 102 | Sadly, no. It is possible to send notifications to multiple devices, however, it will not work as well with the timeout feature and notifications clearing at this time. 103 | 104 | I might revisit it in future, but not at this time. 105 | 106 | - **_Why can't I see my devices or notify service?_** 107 | You might want to check if troubleshooting steps provided by the [Home Assistant Companion app documentation](https://companion.home-assistant.io/docs/troubleshooting/faqs) may be able to help. 108 | 109 | - **_Why do I keep receiving notifications incessantly?_** 110 | Check your scripts and automation, there might be a logical loop going on that's triggering the notification over and over again. If you need further help, feel free to drop by the [main post](https://community.home-assistant.io/t/notifications-actionable-mobile-notifications-script-with-optional-timeout-feature-and-camera-snapshots-works-with-ios-android/) and share your automation and scripts yamls. 111 | 112 |
113 |
114 | 115 | input: 116 | ############################## 117 | # Input: Notification Strategy 118 | ############################## 119 | notify_device: 120 | name: "📲 Device to notify" 121 | description: >- 122 | Device needs to run the official [Home Assistant Companion](https://companion.home-assistant.io/) app to receive notifications.

123 | ❔ Only used with `📲 Notification Strategy: Device`
124 | 👍🏻 `Device` is the preferred and default option. 125 | default: "" 126 | selector: 127 | device: 128 | filter: 129 | - integration: mobile_app 130 | 131 | ############################## 132 | # Input: Notification Content 133 | ############################## 134 | title: 135 | name: "🏷️ Title" 136 | description: "The title of the notification. \n\n`Optional`\n" 137 | default: "" 138 | selector: 139 | text: 140 | subtitle: 141 | name: "🏷️ Subtitle" 142 | description: "The subtitle of the notification. \n\n`Optional`\n" 143 | default: "" 144 | selector: 145 | text: 146 | message: 147 | name: "💬 Message" 148 | description: "The message body to display on the notification. \n\n`🤖 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." 149 | selector: 150 | text: 151 | icon: 152 | name: "🙂 Icon" 153 | description: "Custom icon for this notification. \n\n`🤖 Android Only`, `Optional`" 154 | default: "" 155 | selector: 156 | icon: 157 | enable_icon_color: 158 | name: "🎨 Use Icon Color" 159 | description: "If disabled, uses default icon color. \n\n`🤖 Android Only`, `Optional`" 160 | default: false 161 | selector: 162 | boolean: 163 | icon_color: 164 | name: "🎨 Icon Color" 165 | description: "Custom icon color for this notification. \n\n`🤖 Android Only`, `Optional`" 166 | default: [102, 186, 240] 167 | selector: 168 | color_rgb: 169 | 170 | ############################## 171 | # Input: Response Options 172 | ############################## 173 | 174 | ## Option 1 175 | confirm_enabled: 176 | name: "1️⃣ Option 1" 177 | description: "Show or hide this option." 178 | default: True 179 | selector: 180 | boolean: 181 | 182 | confirm_text: 183 | name: "1️⃣ Option 1 - Title" 184 | description: "Title to show on the first option." 185 | default: "Option 1" 186 | selector: 187 | text: 188 | 189 | confirm_option_mode: 190 | name: "1️⃣ Option 1 - Mode" 191 | description: >- 192 | Action mode for this option.

193 | If you need this option to do nothing, pick `Mode: Action(s)` here and leave the `Action(s)` input empty for this option.

194 | 195 |
196 | ❔ What is this? 197 | 198 | This option is only applicable to Android due to technical limitations. 199 | 200 | The android app can't sending events and open links on the device at the same time, using the same option. 201 | 202 | As such, options on the android app can only be either a link, or an action on Home Assistant. Not both. 203 | 204 | This is due to: 205 | 206 | - The lack of events being sent when URI options are fired. 207 | - The requirement to set the `action` parameter to `"URI"`. 208 | 209 |
210 | 211 |  iOS: Ignore this, iOS will run both actions and links if they are set.

212 | `🤖 Android Only`, `Optional` 213 | default: "" 214 | selector: 215 | select: 216 | mode: dropdown 217 | options: 218 | - label: "" 219 | value: "" 220 | - label: Action(s) 221 | value: action 222 | - label: "Link (🤖 Android Only)" 223 | value: uri 224 | 225 | confirm_action: 226 | name: "1️⃣ Option 1 - Action(s)" 227 | description: "Action(s) to run when this option is selected.\n\n❔ Used with `Mode: Action(s)` option\n❔ Script stops after actions are run\n❔ Leave empty to do nothing\n\n`Optional`" 228 | default: [] 229 | selector: 230 | action: 231 | 232 | confirm_uri: 233 | name: "1️⃣ Option 1 - Link" 234 | description: >- 235 | Navigate to a link or app when this option is selected.
236 | 237 |
238 | 🔗 Show Common Examples 239 | 240 | - To **open a Home Assistant view**, use relative links like these: 241 | `/lovelace/my-dashboard` 242 | `/config/dashboard` 243 | `/developer-tools/template` 244 | 245 | - Use **launch a page in your default browser**, 246 | select the appropriate `Link` option in modes and enter a URL here: 247 | `https://example.com` 248 | 249 |

250 | 251 |
252 | 🤖 Show Android Specific Examples 253 | 254 | - To **open an Application** on your device, for example: 255 | `app://` 256 | `app://io.homeassistant.companion.android` 257 | 258 | - To **view an Entity** on your Home Assistant setup: 259 | `entityId:` 260 | `entityId:sun.sun` 261 | 262 | - To use [**Intent scheme URIs**](https://developer.chrome.com/docs/multidevice/android/intents/#syntax): 263 | `intent://scan/#Intent;scheme=zxing;package=com.my.pkg;end` 264 | 265 | - To use [**Deep links**](https://developer.android.com/training/app-links#deep-links): 266 | `deep-link://` 267 | `deep-link://example://link/to/content` 268 | 269 | - To **see notification history**: 270 | `settings://notification_history` 271 | 272 |

273 | 274 |
275 |  Show iOS Specific Examples 276 | 277 | - Use **application-launching URLs** on your device 278 | `tel:123456789` 279 | `mailto:my@email.com` 280 | 281 |

282 | 283 | ❔ Android: Used with `Mode: Link` options
284 | ❔ iOS: Leave empty to disable
285 | ⚠️ Android: Using this option **WILL NOT STOP** timeout countdown. Please triple check actions that will be run in `Timeout Action(s)`.

286 | `Optional` 287 | default: "" 288 | selector: 289 | text: 290 | type: url 291 | 292 | confirm_icon: 293 | name: "1️⃣ Option 1 - Icon" 294 | description: "Custom icon to show on this option. \n\nPlease refer to the [documentation here](https://companion.home-assistant.io/docs/notifications/actionable-notifications#icon-values). \nThere are many reference pages out there, feel use a [search engine](https://www.google.com/search?q=sfsymbols+reference+list)! \n\n` iOS Only`, `Optional`" 295 | default: "" 296 | selector: 297 | text: 298 | prefix: "sfsymbols:" 299 | 300 | confirm_is_destructive: 301 | name: "1️⃣ Option 1 - Destructive" 302 | description: "Set the action's title to be red, indicating a destructive action. \n\n` iOS Only`, `Optional`" 303 | default: false 304 | selector: 305 | boolean: 306 | 307 | confirm_authentication_required: 308 | name: "1️⃣ Option 1 - Authentication Required" 309 | description: "Require device to be unlocked to use this option. \n\n` iOS Only`, `Optional`" 310 | default: false 311 | selector: 312 | boolean: 313 | 314 | ## Option 2 315 | dismiss_enabled: 316 | name: "2️⃣ Option 2" 317 | description: "Show or hide this option." 318 | default: True 319 | selector: 320 | boolean: 321 | 322 | dismiss_text: 323 | name: "2️⃣ Option 2 - Title" 324 | description: "Title to show on the first option." 325 | default: "Option 2" 326 | selector: 327 | text: 328 | 329 | dismiss_option_mode: 330 | name: "2️⃣ Option 2 - Mode" 331 | description: >- 332 | Action mode for this option.

333 | If you need this option to do nothing, pick `Mode: Action(s)` here and leave the `Action(s)` input empty for this option.

334 | 335 |
336 | ❔ What is this? 337 | 338 | This option is only applicable to Android due to technical limitations. 339 | 340 | The android app can't sending events and open links on the device at the same time, using the same option. 341 | 342 | As such, options on the android app can only be either a link, or an action on Home Assistant. Not both. 343 | 344 | This is due to: 345 | 346 | - The lack of events being sent when URI options are fired. 347 | - The requirement to set the `action` parameter to `"URI"`. 348 | 349 |
350 | 351 |  iOS: Ignore this, iOS will run both actions and links if they are set.

352 | `🤖 Android Only`, `Optional` 353 | default: "" 354 | selector: 355 | select: 356 | mode: dropdown 357 | options: 358 | - label: "" 359 | value: "" 360 | - label: Action(s) 361 | value: action 362 | - label: "Link (🤖 Android Only)" 363 | value: uri 364 | 365 | dismiss_action: 366 | name: "2️⃣ Option 2 - Action(s)" 367 | description: "Action(s) to run when this option is selected.\n\n❔ Used with `Mode: Action(s)` option\n❔ Script stops after actions are run\n❔ Leave empty to do nothing\n\n`Optional`" 368 | default: [] 369 | selector: 370 | action: 371 | 372 | dismiss_uri: 373 | name: "2️⃣ Option 2 - Link" 374 | description: >- 375 | Navigate to a link or app when this option is selected.
376 | 377 |
378 | 🔗 Show Common Examples 379 | 380 | - To **open a Home Assistant view**, use relative links like these: 381 | `/lovelace/my-dashboard` 382 | `/config/dashboard` 383 | `/developer-tools/template` 384 | 385 | - Use **launch a page in your default browser**, 386 | select the appropriate `Link` option in modes and enter a URL here: 387 | `https://example.com` 388 | 389 |

390 | 391 |
392 | 🤖 Show Android Specific Examples 393 | 394 | - To **open an Application** on your device, for example: 395 | `app://` 396 | `app://io.homeassistant.companion.android` 397 | 398 | - To **view an Entity** on your Home Assistant setup: 399 | `entityId:` 400 | `entityId:sun.sun` 401 | 402 | - To use [**Intent scheme URIs**](https://developer.chrome.com/docs/multidevice/android/intents/#syntax): 403 | `intent://scan/#Intent;scheme=zxing;package=com.my.pkg;end` 404 | 405 | - To use [**Deep links**](https://developer.android.com/training/app-links#deep-links): 406 | `deep-link://` 407 | `deep-link://example://link/to/content` 408 | 409 | - To **see notification history**: 410 | `settings://notification_history` 411 | 412 |

413 | 414 |
415 |  Show iOS Specific Examples 416 | 417 | - Use **application-launching URLs** on your device 418 | `tel:123456789` 419 | `mailto:my@email.com` 420 | 421 |

422 | 423 | ❔ Android: Used with `Mode: Link` options
424 | ❔ iOS: Leave empty to disable
425 | ⚠️ Android: Using this option **WILL NOT STOP** timeout countdown. Please triple check actions that will be run in `Timeout Action(s)`.

426 | `Optional` 427 | default: "" 428 | selector: 429 | text: 430 | type: url 431 | 432 | dismiss_icon: 433 | name: "2️⃣ Option 2 - Icon" 434 | description: "Custom icon to show on this option. \n\nPlease refer to the [documentation here](https://companion.home-assistant.io/docs/notifications/actionable-notifications#icon-values). \nThere are many reference pages out there, feel use a [search engine](https://www.google.com/search?q=sfsymbols+reference+list)! \n\n` iOS Only`, `Optional`" 435 | default: "" 436 | selector: 437 | text: 438 | prefix: "sfsymbols:" 439 | 440 | dismiss_is_destructive: 441 | name: "2️⃣ Option 2 - Destructive" 442 | description: "Set the action's title to be red, indicating a destructive action. \n\n` iOS Only`, `Optional`" 443 | default: false 444 | selector: 445 | boolean: 446 | 447 | dismiss_authentication_required: 448 | name: "2️⃣ Option 2 - Authentication Required" 449 | description: "Require device to be unlocked to use this option. \n\n` iOS Only`, `Optional`" 450 | default: false 451 | selector: 452 | boolean: 453 | 454 | ## Option 3 455 | option_three_enabled: 456 | name: "3️⃣ Option 3" 457 | description: "Show or hide this option." 458 | default: false 459 | selector: 460 | boolean: 461 | 462 | option_three_text: 463 | name: "3️⃣ Option 3 - Title" 464 | description: "Title to show on the first option." 465 | default: "Option 3" 466 | selector: 467 | text: 468 | 469 | option_three_option_mode: 470 | name: "3️⃣ Option 3 - Mode" 471 | description: >- 472 | Action mode for this option.

473 | If you need this option to do nothing, pick `Mode: Action(s)` here and leave the `Action(s)` input empty for this option.

474 | 475 |
476 | ❔ What is this? 477 | 478 | This option is only applicable to Android due to technical limitations. 479 | 480 | The android app can't sending events and open links on the device at the same time, using the same option. 481 | 482 | As such, options on the android app can only be either a link, or an action on Home Assistant. Not both. 483 | 484 | This is due to: 485 | 486 | - The lack of events being sent when URI options are fired. 487 | - The requirement to set the `action` parameter to `"URI"`. 488 | 489 |
490 | 491 |  iOS: Ignore this, iOS will run both actions and links if they are set.

492 | `🤖 Android Only`, `Optional` 493 | default: "" 494 | selector: 495 | select: 496 | mode: dropdown 497 | options: 498 | - label: "" 499 | value: "" 500 | - label: Action(s) 501 | value: action 502 | - label: "Link (🤖 Android Only)" 503 | value: uri 504 | 505 | option_three_action: 506 | name: "3️⃣ Option 3 - Action(s)" 507 | description: "Action(s) to run when this option is selected.\n\n❔ Used with `Mode: Action(s)` option\n❔ Script stops after actions are run\n❔ Leave empty to do nothing\n\n`Optional`" 508 | default: [] 509 | selector: 510 | action: 511 | 512 | option_three_uri: 513 | name: "3️⃣ Option 3 - Link" 514 | description: >- 515 | Navigate to a link or app when this option is selected.
516 | 517 |
518 | 🔗 Show Common Examples 519 | 520 | - To **open a Home Assistant view**, use relative links like these: 521 | `/lovelace/my-dashboard` 522 | `/config/dashboard` 523 | `/developer-tools/template` 524 | 525 | - Use **launch a page in your default browser**, 526 | select the appropriate `Link` option in modes and enter a URL here: 527 | `https://example.com` 528 | 529 |

530 | 531 |
532 | 🤖 Show Android Specific Examples 533 | 534 | - To **open an Application** on your device, for example: 535 | `app://` 536 | `app://io.homeassistant.companion.android` 537 | 538 | - To **view an Entity** on your Home Assistant setup: 539 | `entityId:` 540 | `entityId:sun.sun` 541 | 542 | - To use [**Intent scheme URIs**](https://developer.chrome.com/docs/multidevice/android/intents/#syntax): 543 | `intent://scan/#Intent;scheme=zxing;package=com.my.pkg;end` 544 | 545 | - To use [**Deep links**](https://developer.android.com/training/app-links#deep-links): 546 | `deep-link://` 547 | `deep-link://example://link/to/content` 548 | 549 | - To **see notification history**: 550 | `settings://notification_history` 551 | 552 |

553 | 554 |
555 |  Show iOS Specific Examples 556 | 557 | - Use **application-launching URLs** on your device 558 | `tel:123456789` 559 | `mailto:my@email.com` 560 | 561 |

562 | 563 | ❔ Android: Used with `Mode: Link` options
564 | ❔ iOS: Leave empty to disable
565 | ⚠️ Android: Using this option **WILL NOT STOP** timeout countdown. Please triple check actions that will be run in `Timeout Action(s)`.

566 | `Optional` 567 | default: "" 568 | selector: 569 | text: 570 | type: url 571 | 572 | option_three_icon: 573 | name: "3️⃣ Option 3 - Icon" 574 | description: "Custom icon to show on this option. \n\nPlease refer to the [documentation here](https://companion.home-assistant.io/docs/notifications/actionable-notifications#icon-values). \nThere are many reference pages out there, feel use a [search engine](https://www.google.com/search?q=sfsymbols+reference+list)! \n\n` iOS Only`, `Optional`" 575 | default: "" 576 | selector: 577 | text: 578 | prefix: "sfsymbols:" 579 | 580 | option_three_is_destructive: 581 | name: "3️⃣ Option 3 - Destructive" 582 | description: "Set the action's title to be red, indicating a destructive action. \n\n` iOS Only`, `Optional`" 583 | default: false 584 | selector: 585 | boolean: 586 | 587 | option_three_authentication_required: 588 | name: "3️⃣ Option 3 - Authentication Required" 589 | description: "Require device to be unlocked to use this option. \n\n` iOS Only`, `Optional`" 590 | default: false 591 | selector: 592 | boolean: 593 | 594 | ############################## 595 | # Input: Timeout Options 596 | ############################## 597 | enable_timeout: 598 | name: "⌛️ Enable Timeout" 599 | description: "Require script to stop listening after the set duration.

👍🏻 Recommended to enable.
⚠️ If disabled, script will wait for response indefinitely until the next time it is triggered." 600 | default: true # Default `true` for backward compatibility. 601 | selector: 602 | boolean: 603 | timeout: 604 | name: "⌛️ Timeout Duration" 605 | description: "Amount of time to wait for an action response before firing timeout action. \n\n👍🏻 Recommended: ≥1 minute, to allow notifications to be sent. \nDefault: 15 minutes. \n" 606 | default: 607 | hours: 0 608 | minutes: 15 609 | seconds: 0 610 | selector: 611 | duration: 612 | enable_day: false 613 | run_timeout_actions: 614 | name: "⌛️ Enable Timeout Action(s)" 615 | description: "Run timeout actions upon a timeout event.

👍🏻 Recommended to enable.
⚠️ If disabled, script will timeout without executing any timeout actions." 616 | default: true # Default `true` for backward compatibility. 617 | selector: 618 | boolean: 619 | timeout_action: 620 | name: "⌛️ Timeout Action(s)" 621 | description: "Action to run when notification response is timed out. \n\n❔ Leave empty if no actions should be run \n\n⚠️ Android Users: Note, URI options do not stop the timeout countdown. This action could be run after pressing the URI option.\n❔ Android Users: Workaround for the above, you may disable `⌛️ Run timeout action(s) when notification cleared` and manually clear the notification after selecting your URI option. \n\n`Optional`" 622 | default: [] 623 | selector: 624 | action: 625 | swipe_away_as_timeout: 626 | name: "⌛️ Run timeout action(s) when notification cleared" 627 | description: "If enabled, swiping the notification away will immediately trigger timeout actions. \n\n`🤖 Android Only`" 628 | default: false 629 | selector: 630 | boolean: 631 | clear_on_timeout: 632 | name: "🧹 Clear notification on timeout" 633 | description: "Dismiss the notification after action selection times out." 634 | default: false 635 | selector: 636 | boolean: 637 | persist: 638 | name: "🚩 Persistent Notification" 639 | description: "Prevents notifications from being swiped away by accident. \n\n❔ This option blocks `⌛️ Run timeout action(s) when notification cleared` \n\n`🤖 Android Only`" 640 | default: false 641 | selector: 642 | boolean: 643 | 644 | ############################## 645 | # Input: Notification Link 646 | ############################## 647 | notification_link: 648 | name: "🔗 Notification Link" 649 | 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://` \n - Entity `More Info` Panel: `entityId:` \n - Deep links: `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`" 650 | default: "" 651 | selector: 652 | text: 653 | 654 | ############################## 655 | # Input: Attachments 656 | ############################## 657 | attachment_type: 658 | name: "📸 Attachment Type" 659 | description: > 660 | Choose to send an attachment along with the notification.
661 | 662 | `Optional` 663 | default: "none" 664 | selector: 665 | select: 666 | options: 667 | - label: "None" 668 | value: "none" 669 | - label: "Camera" 670 | value: "camera_entity" 671 | attachment_camera_entity: 672 | name: "📸 Attachment: Camera Entity" 673 | description: >- 674 | Camera Entity to display snapshots of on the notification.
675 | 676 | Please note, iOS and Android have differing vehaviours, as specified in the documentation. 677 | See the links below for more information. 678 | 679 |
 Camera Stream🤖 Automatic Snapshots

680 | 681 | ❔ Only used with `Attachment Type: Camera` 682 | default: "" 683 | selector: 684 | entity: 685 | filter: 686 | - domain: "camera" 687 | 688 | ############################## 689 | # Input: Misc Inputs 690 | ############################## 691 | car_ui: 692 | name: "🚘 Show on Android Auto" 693 | description: "Display notification on Android Auto interface. \n\n`🤖 Android Only`" 694 | default: false 695 | selector: 696 | boolean: 697 | tag: 698 | name: "🔖 Tag" 699 | 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👍🏻 Recommended to leave empty\n\n`Optional`" 700 | default: "" 701 | selector: 702 | text: 703 | group: 704 | name: "📣 Notification Group ID" 705 | 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`" 706 | default: "" 707 | selector: 708 | text: 709 | channel: 710 | name: "📣 Notification Channel" 711 | description: "Defines the channel, to be used with Importance. \nRelates to the importance of the notification. \n\n`🤖 Android Only`, `Optional`" 712 | default: "General" 713 | selector: 714 | text: 715 | importance: 716 | name: "❕ Notification Channel Importance" 717 | description: "See [documentation](https://companion.home-assistant.io/docs/notifications/notifications-basic/#notification-channel-importance) for more information. \n\n`🤖 Android Only`" 718 | default: default 719 | selector: 720 | select: 721 | options: 722 | - label: "Urgent (Makes a sound with heads-up notification)" 723 | value: high 724 | - label: "Default (Makes a sound)" 725 | value: default 726 | - label: "Silent (Makes no sound)" 727 | value: low 728 | - label: "Low (Makes no sound, doesn't appear in status bar)" 729 | value: min 730 | android_high_priority: 731 | name: "❕ High Priority Mode" 732 | description: "Workaround to ensure notifications are delivered in timely fashion. This will override the Notification Channel Importance with `importance: high`, and set `ttl: 0`. \n\n`🤖 Android Only`" 733 | default: true 734 | selector: 735 | boolean: 736 | interruption_level: 737 | name: "❕ Interruption Level" 738 | description: "See [documentation](https://companion.home-assistant.io/docs/notifications/notifications-basic/#interruption-level) for more information. \n\n` iOS Only`" 739 | default: active 740 | selector: 741 | select: 742 | options: 743 | - label: "Silent (Makes no sound, does not wake screen)" 744 | value: passive 745 | - label: "Default" 746 | value: active 747 | - label: "Important (Overrides Focus)" 748 | value: time-sensitive 749 | - label: "Critical (Overrides Focus and Mute, restricted features)" 750 | value: critical 751 | visibility: 752 | name: "🔏 Notification Lockscreen Visibility" 753 | 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`🤖 Android Only`" 754 | default: "private" 755 | selector: 756 | select: 757 | options: 758 | - label: "Public: Always show content." 759 | value: public 760 | - label: "Private: Show content based on phone settings." 761 | value: private 762 | - label: "Secret: Always hide content on the lockscreen." 763 | value: secret 764 | 765 | ############################## 766 | # Fields 767 | ############################## 768 | fields: 769 | field_notify_device: 770 | name: "📲 Device to notify" 771 | description: Override device to be notified. 772 | default: !input notify_device 773 | selector: 774 | device: 775 | filter: 776 | - integration: mobile_app 777 | field_title: 778 | name: "🏷️ Title" 779 | description: "Override title of the notification." 780 | example: !input title 781 | default: !input title 782 | selector: 783 | text: 784 | field_message: 785 | name: "💬 Message" 786 | description: "Override message body to display on the notification." 787 | example: !input message 788 | default: !input message 789 | selector: 790 | text: 791 | field_subtitle: 792 | name: "🏷️ Subtitle" 793 | description: "Override subtitle of the notification." 794 | example: !input subtitle 795 | default: !input subtitle 796 | selector: 797 | text: 798 | field_attachment_type: 799 | name: "📸 Attachment Type" 800 | description: "Override the Attachment Type of the notification." 801 | example: !input attachment_type 802 | default: !input attachment_type 803 | selector: 804 | select: 805 | options: 806 | - label: "None" 807 | value: "none" 808 | - label: "Camera" 809 | value: "camera_entity" 810 | field_attachment_camera_entity: 811 | name: "📸 Attachment: Camera Entity" 812 | description: "Override camera entity if your script has attachment type set to Camera." 813 | example: !input attachment_camera_entity 814 | default: !input attachment_camera_entity 815 | selector: 816 | entity: 817 | filter: 818 | - domain: "camera" 819 | 820 | field_option_one_enabled: 821 | name: "1️⃣ Option 1" 822 | description: "Override showing or hiding this option." 823 | example: !input confirm_enabled 824 | selector: 825 | boolean: 826 | # [Unsupported due to `choose.sequence`] - Can't pass variables to choose.sequence. 827 | # field_option_one_action: 828 | # name: "1️⃣ Option 1 - Action(s)" 829 | # description: "Override actions for this option." 830 | # example: >- 831 | # - alias: This is an example action 832 | # service: homeassistant.check_config 833 | # default: !input confirm_action 834 | # selector: 835 | # action: 836 | field_option_two_enabled: 837 | name: "2️⃣ Option 2" 838 | description: "Override showing or hiding this option." 839 | example: !input dismiss_enabled 840 | selector: 841 | boolean: 842 | # [Unsupported due to `choose.sequence`] - Can't pass variables to choose.sequence. 843 | # field_option_two_action: 844 | # name: "1️⃣ Option 2 - Action(s)" 845 | # description: "Override actions for this option." 846 | # example: >- 847 | # - alias: This is an example action 848 | # service: homeassistant.check_config 849 | # default: !input dismiss_action 850 | # selector: 851 | # action: 852 | field_option_three_enabled: 853 | name: "3️⃣ Option 3" 854 | description: "Override showing or hiding this option." 855 | example: !input dismiss_enabled 856 | selector: 857 | boolean: 858 | # [Unsupported due to `choose.sequence`] - Can't pass variables to choose.sequence. 859 | # field_option_three_action: 860 | # name: "1️⃣ Option 3 - Action(s)" 861 | # description: "Override actions for this option." 862 | # example: >- 863 | # - alias: This is an example action 864 | # service: homeassistant.check_config 865 | # default: !input option_three_action 866 | # selector: 867 | # action: 868 | field_enable_timeout: 869 | name: "⌛️ Enable Timeout" 870 | description: "Override timeout feature." 871 | example: !input enable_timeout 872 | selector: 873 | boolean: 874 | 875 | field_timeout: 876 | name: "⌛️ Timeout Duration" 877 | description: "Override timeout duration" 878 | default: !input timeout 879 | selector: 880 | duration: 881 | enable_day: false 882 | 883 | field_run_timeout_actions: 884 | name: "⌛️ Enable Timeout Action(s)" 885 | description: "Override running timeout actions" 886 | example: !input run_timeout_actions 887 | selector: 888 | boolean: 889 | 890 | field_notification_link: 891 | name: "🔗 Notification Link" 892 | description: "Override notification link" 893 | example: !input notification_link 894 | default: !input notification_link 895 | selector: 896 | text: 897 | 898 | # [Unsupported due to `choose.sequence`] - Can't pass variables to choose.sequence. 899 | # field_timeout_action: 900 | # name: "⌛️ Timeout Action(s)" 901 | # description: "Override timeout action." 902 | # example: >- 903 | # - alias: This is an example action 904 | # service: homeassistant.check_config 905 | # default: !input timeout_action 906 | # selector: 907 | # action: 908 | 909 | sequence: 910 | ############################## 911 | # Setup Variables 912 | ############################## 913 | - alias: Basic Notification Content 914 | variables: 915 | # Title 916 | script_title: !input title 917 | title: "{{ iif(field_title is defined, field_title, script_title) }}" 918 | 919 | # Subtitle 920 | script_subtitle: !input subtitle 921 | subtitle: "{{ iif(field_subtitle is defined, field_subtitle, script_subtitle) }}" 922 | 923 | # Message 924 | script_message: !input message 925 | message: "{{ iif(field_message is defined and (field_message|length), field_message, script_message) }}" 926 | 927 | - alias: Common Configuration Options 928 | variables: 929 | # [Opening a URL] - https://companion.home-assistant.io/docs/notifications/notifications-basic/#opening-a-url 930 | script_notification_link: !input notification_link 931 | notification_link: "{{ iif(field_notification_link is defined, field_notification_link, script_notification_link) }}" 932 | 933 | # [Tag] 934 | custom_tag: !input tag # No need for manual definition anymore, treat existing definitions as custom tags. 935 | tag: "{{ iif(custom_tag|length, custom_tag, this.entity_id ~ '-' ~ context.id) }}" 936 | 937 | # [Grouping] 938 | group: !input group 939 | 940 | - alias: Android Configuration Options 941 | variables: 942 | # sticky: !input sticky # Unlikely to support due to potential for users thinking that notifications are stuck. 943 | channel: !input channel 944 | visibility: !input visibility 945 | importance: !input importance 946 | persist: !input persist 947 | # chronometer: !input chronometer # Unlikely to support, depends on template flexibility 948 | # alert_once: !input alert_once 949 | car_ui: !input car_ui 950 | 951 | # [Notification Banner Icon] 952 | notification_icon: !input icon 953 | enable_icon_color: !input enable_icon_color 954 | icon_color_selector: !input icon_color 955 | icon_color_hex: '{{ "#{:02x}{:02x}{:02x}".format(icon_color_selector[0], icon_color_selector[1], icon_color_selector[2]) }}' 956 | android_high_priority: !input android_high_priority 957 | 958 | - alias: iOS Configuration Options 959 | variables: 960 | interruption_level: !input interruption_level 961 | # presentation_options: !input presentation_options 962 | # shortcut: !input shortcut # Unlikely to be supported due to complexity. 963 | # [Critical Notifications] - https://companion.home-assistant.io/docs/notifications/critical-notifications 964 | # critical: !input critical 965 | # volume: !input volume 966 | 967 | - alias: Timeout 968 | variables: 969 | script_enable_timeout: !input enable_timeout 970 | enable_timeout: "{{ iif(field_enable_timeout is defined, field_enable_timeout, script_enable_timeout) }}" 971 | clear_on_timeout: !input clear_on_timeout 972 | script_timeout: !input timeout # Load timeout into variable for use with templates. 973 | timeout: "{{ iif(field_timeout is defined, field_timeout, script_timeout) }}" 974 | timeout_seconds: "{{ (timeout.hours * 60 + timeout.minutes) * 60 + timeout.seconds }}" 975 | script_run_timeout_actions: !input run_timeout_actions 976 | run_timeout_actions: "{{ iif(field_run_timeout_actions is defined, field_run_timeout_actions, script_run_timeout_actions) }}" 977 | swipe_away_as_timeout: !input swipe_away_as_timeout 978 | 979 | - alias: Attachments 980 | variables: 981 | script_attachment_type: !input attachment_type 982 | attachment_type: "{{ iif(field_attachment_type is defined, field_attachment_type, script_attachment_type) }}" 983 | script_attachment_camera_entity: !input attachment_camera_entity 984 | attachment_camera_entity: "{{ iif(field_attachment_camera_entity is defined, field_attachment_camera_entity, script_attachment_camera_entity) }}" 985 | camera_image_url: >- 986 | {% if (attachment_camera_entity|length) %} 987 | {% if (state_attr(attachment_camera_entity,'entity_picture')|length) %} 988 | {{state_attr(attachment_camera_entity,'entity_picture')}} 989 | {% else %} 990 | {{"/api/camera_proxy/{id}".format(id=attachment_camera_entity)}} 991 | {%- endif %} 992 | {%- endif %} 993 | media_url: >- 994 | {{ 995 | { 996 | 'none': '', 997 | 'camera_entity': iif(camera_image_url | length, camera_image_url) 998 | }.get(attachment_type) 999 | }} 1000 | 1001 | - alias: Device Configuration 1002 | variables: 1003 | script_notify_device: !input notify_device 1004 | notify_device: "{{ iif(field_notify_device is defined, field_notify_device, script_notify_device) }}" 1005 | notify_service: >- 1006 | {{ "notify.mobile_app_{id}".format(id=device_attr(notify_device,'name')|slugify) }} 1007 | 1008 | - alias: Option 1 1009 | variables: 1010 | first_option: "{{ 'FIRST_' ~ context.id }}" 1011 | script_option_one_enabled: !input confirm_enabled 1012 | option_one_enabled: "{{ iif(field_option_one_enabled is defined, field_option_one_enabled, script_option_one_enabled) }}" 1013 | script_option_one_title: !input confirm_text 1014 | option_one_title: "{{ iif(field_option_one_text is defined, field_option_one_text, script_option_one_title) }}" 1015 | option_one_mode: !input confirm_option_mode 1016 | script_option_one_actions: !input confirm_action 1017 | option_one_actions: "{{ iif(field_option_one_action is defined, field_option_one_action, script_option_one_actions) }}" 1018 | option_one_uri: !input confirm_uri 1019 | option_one_icon_value: !input confirm_icon 1020 | option_one_icon: >- 1021 | {% if 'sfsymbols:' in option_one_icon_value %} 1022 | {{ option_one_icon_value }} 1023 | {% elif option_one_icon_value | length %} 1024 | {{ "sfsymbols:{icon}".format(icon=option_one_icon_value) }} 1025 | {%- endif %} 1026 | option_one_is_destructive: !input confirm_is_destructive 1027 | option_one_auth_required: !input confirm_authentication_required 1028 | option_one_action: >- 1029 | {% if option_one_mode == 'uri' %} 1030 | {{ 'URI' }} 1031 | {% else %} 1032 | {{ first_option }} 1033 | {% endif %} 1034 | option_one: >- 1035 | {{ { 1036 | 'enabled': option_one_enabled, 1037 | 'action': option_one_action, 1038 | 'title': option_one_title, 1039 | 'actions': option_one_actions, 1040 | 'icon': option_one_icon, 1041 | 'destructive': option_one_is_destructive, 1042 | 'authenticationRequired': option_one_auth_required, 1043 | "{}".format('uri' if option_one_uri|length else ''): option_one_uri, 1044 | } }} 1045 | 1046 | - alias: Option 2 1047 | variables: 1048 | second_option: "{{ 'SECOND_' ~ context.id }}" 1049 | script_option_two_enabled: !input dismiss_enabled 1050 | option_two_enabled: "{{ iif(field_option_two_enabled is defined, field_option_two_enabled, script_option_two_enabled) }}" 1051 | option_two_title: !input dismiss_text 1052 | option_two_mode: !input dismiss_option_mode 1053 | script_option_two_actions: !input dismiss_action 1054 | option_two_actions: "{{ iif(field_option_two_action is defined, field_option_two_action, script_option_two_actions) }}" 1055 | option_two_uri: !input dismiss_uri 1056 | option_two_icon_value: !input dismiss_icon 1057 | option_two_icon: >- 1058 | {% if 'sfsymbols:' in option_two_icon_value %} 1059 | {{ option_two_icon_value }} 1060 | {% elif option_two_icon_value | length %} 1061 | {{ "sfsymbols:{icon}".format(icon=option_two_icon_value) }} 1062 | {%- endif %} 1063 | option_two_is_destructive: !input dismiss_is_destructive 1064 | option_two_auth_required: !input dismiss_authentication_required 1065 | option_two_action: >- 1066 | {% if option_two_mode == 'uri' %} 1067 | {{ 'URI' }} 1068 | {% else %} 1069 | {{ second_option }} 1070 | {% endif %} 1071 | option_two: >- 1072 | {{{ 1073 | 'enabled': option_two_enabled, 1074 | 'action': option_two_action, 1075 | 'title': option_two_title, 1076 | 'actions': option_two_actions, 1077 | 'icon': option_two_icon, 1078 | 'destructive': option_two_is_destructive, 1079 | 'authenticationRequired': option_two_auth_required, 1080 | "{}".format('uri' if option_two_uri|length else ''): option_two_uri, 1081 | }}} 1082 | 1083 | - alias: Option 3 1084 | variables: 1085 | third_option: "{{ 'THIRD_' ~ context.id }}" 1086 | script_option_three_enabled: !input option_three_enabled 1087 | option_three_enabled: "{{ iif(field_option_three_enabled is defined, field_option_three_enabled, script_option_three_enabled) }}" 1088 | option_three_title: !input option_three_text 1089 | option_three_mode: !input option_three_option_mode 1090 | script_option_three_actions: !input option_three_action 1091 | option_three_actions: "{{ iif(field_option_three_action is defined, field_option_three_action, script_option_three_actions) }}" 1092 | option_three_uri: !input option_three_uri 1093 | option_three_icon_value: !input option_three_icon 1094 | option_three_icon: >- 1095 | {% if 'sfsymbols:' in option_three_icon_value %} 1096 | {{ option_three_icon_value }} 1097 | {% elif option_three_icon_value | length %} 1098 | {{ "sfsymbols:{icon}".format(icon=option_three_icon_value) }} 1099 | {%- endif %} 1100 | option_three_is_destructive: !input option_three_is_destructive 1101 | option_three_auth_required: !input option_three_authentication_required 1102 | option_three_action: >- 1103 | {% if option_three_mode == 'uri' %} 1104 | {{ 'URI' }} 1105 | {% else %} 1106 | {{ third_option }} 1107 | {% endif %} 1108 | option_three: >- 1109 | {{{ 1110 | 'enabled': option_three_enabled, 1111 | 'action': option_three_action, 1112 | 'title': option_three_title, 1113 | 'actions': option_three_actions, 1114 | 'icon': option_three_icon, 1115 | 'destructive': option_three_is_destructive, 1116 | 'authenticationRequired': option_three_auth_required, 1117 | "{}".format('uri' if option_three_uri|length else ''): option_three_uri, 1118 | }}} 1119 | 1120 | - alias: Setup Payload 1121 | variables: 1122 | options: >- 1123 | {{ [option_one, option_two, option_three] | selectattr('enabled') | list }} 1124 | expect_response: "{{ enable_timeout or option_one_enabled or option_two_enabled or option_three_enabled }}" # If there's no timeout nor options, then no point waiting. Stop script. 1125 | # Build OS specific notification payloads. 1126 | notification_data: >- 1127 | {% set apple_device = 'APPLE' in (device_attr(notify_device, "manufacturer")|upper) %} 1128 | {% set payload = namespace(data={ 'apple_device': apple_device }) %} 1129 | {% if payload.data.apple_device %} 1130 | {# iOS #} 1131 | {% set push = namespace(d={}) %} 1132 | {% set payload.data = dict(payload.data, **{ 'subtitle': subtitle }) %} 1133 | {% set push.d = dict(push.d, **{ 'interruption-level': interruption_level }) %} 1134 | {% if notification_link|length %}{% set payload.data = dict(payload.data, **{ 'url': notification_link }) %}{% endif %} 1135 | {% if attachment_type == 'camera_entity' %}{% set payload.data = dict(payload.data, **{ 'entity_id': attachment_camera_entity }) %}{% endif %} 1136 | {% set payload.data = dict(payload.data, **{ 'push': push.d }) %} 1137 | {% else %} 1138 | {# Android #} 1139 | {% set payload.data = dict(payload.data, **{ 'subject': subtitle }) %} 1140 | {% set payload.data = dict(payload.data, **{ 'visibility': visibility }) %} 1141 | {% set payload.data = dict(payload.data, **{ 'importance': importance }) %} 1142 | {% if android_high_priority %}{% set payload.data = dict(payload.data, **{ 'priority': 'high', 'ttl': 0 }) %}{% endif %} 1143 | {% if notification_link|length %}{% set payload.data = dict(payload.data, **{ 'clickAction': notification_link }) %}{% endif %} 1144 | {% if attachment_type == 'camera_entity' and (media_url|length) %}{% set payload.data = dict(payload.data, **{ 'image': media_url }) %}{% endif %} 1145 | {% if notification_icon|length %}{% set payload.data = dict(payload.data, **{ 'notification_icon': notification_icon }) %}{% endif %} 1146 | {% if enable_icon_color %}{% set payload.data = dict(payload.data, **{ 'color': icon_color_hex }) %}{% endif %} 1147 | {% if enable_timeout and clear_on_timeout %}{% set payload.data = dict(payload.data, **{ 'timeout': timeout_seconds }) %}{% endif %} 1148 | {% if channel|length %}{% set payload.data = dict(payload.data, **{ 'channel': channel }) %}{% endif %} 1149 | {% if persist %}{% set payload.data = dict(payload.data, **{ 'persistent': persist }) %}{% endif %} 1150 | {% if car_ui %}{% set payload.data = dict(payload.data, **{ 'car_ui': car_ui }) %}{% endif %} 1151 | {% endif %} 1152 | {# Common #} 1153 | {% set payload.data = dict(payload.data, **{ 'actions': options }) %} 1154 | {% set payload.data = dict(payload.data, **{ 'tag': tag }) %} 1155 | {% if group|length %}{% set payload.data = dict(payload.data, **{ 'group': group }) %}{% endif %} 1156 | {{ payload.data }} 1157 | 1158 | ############################## 1159 | # Send Notification 1160 | ############################## 1161 | - alias: "Send notification" 1162 | service: "{{ notify_service }}" 1163 | data: 1164 | title: "{{ title }}" 1165 | message: "{{ message }}" 1166 | data: "{{ notification_data }}" 1167 | 1168 | ############################## 1169 | # Evaluate Response 1170 | ############################## 1171 | - alias: Determine if script has to wait for response? 1172 | choose: 1173 | - alias: "No need for response" 1174 | conditions: "{{ expect_response == false }}" 1175 | sequence: [] 1176 | - alias: "Should await response with timeout?" 1177 | conditions: "{{ enable_timeout }}" 1178 | sequence: 1179 | - alias: "Awaiting response with timeout…" 1180 | wait_for_trigger: 1181 | - platform: event 1182 | event_type: mobile_app_notification_action 1183 | event_data: 1184 | action: "{{ first_option }}" 1185 | - platform: event 1186 | event_type: mobile_app_notification_action 1187 | event_data: 1188 | action: "{{ second_option }}" 1189 | - platform: event 1190 | event_type: mobile_app_notification_action 1191 | event_data: 1192 | action: "{{ third_option }}" 1193 | - platform: event 1194 | event_type: mobile_app_notification_cleared 1195 | event_data: 1196 | tag: "{{ tag }}" 1197 | timeout: "{{ timeout }}" 1198 | continue_on_timeout: true 1199 | - alias: "Should await response indefinitely?" 1200 | conditions: "{{ enable_timeout == false }}" 1201 | sequence: 1202 | - alias: "Awaiting response indefinitely…" 1203 | wait_for_trigger: 1204 | - platform: event 1205 | event_type: mobile_app_notification_action 1206 | event_data: 1207 | action: "{{ first_option }}" 1208 | - platform: event 1209 | event_type: mobile_app_notification_action 1210 | event_data: 1211 | action: "{{ second_option }}" 1212 | - platform: event 1213 | event_type: mobile_app_notification_action 1214 | event_data: 1215 | action: "{{ third_option }}" 1216 | - platform: event 1217 | event_type: mobile_app_notification_cleared 1218 | event_data: 1219 | tag: "{{ tag }}" 1220 | 1221 | ############################## 1222 | # Parse user response 1223 | ############################## 1224 | - alias: "Parse response into variable" 1225 | variables: 1226 | user_response: >- 1227 | {% set response = namespace(data={ 'payload': notification_data }) %} 1228 | {% if not expect_response %} 1229 | {% set response.data = dict(response.data, **{ 'result': "no_response" }) %} 1230 | {% elif run_timeout_actions and wait.trigger == none %} 1231 | {% set response.data = dict(response.data, **{ 'result': "timeout" }) %} 1232 | {% elif run_timeout_actions and swipe_away_as_timeout and wait.trigger.event.event_type == 'mobile_app_notification_cleared' %} 1233 | {% set response.data = dict(response.data, **{ 'result': "notification_cleared" }) %} 1234 | {% elif wait.trigger.event.data.action == option_one['action'] %} 1235 | {% set response.data = dict(response.data, **{ 'result': "option_one" }) %} 1236 | {% elif wait.trigger.event.data.action == option_two['action'] %} 1237 | {% set response.data = dict(response.data, **{ 'result': "option_two" }) %} 1238 | {% elif wait.trigger.event.data.action == option_three['action'] %} 1239 | {% set response.data = dict(response.data, **{ 'result': "option_three" }) %} 1240 | {%- endif %} 1241 | {{ response.data }} 1242 | 1243 | ############################## 1244 | # Trigger Response Actions 1245 | ############################## 1246 | - alias: "Run response actions" 1247 | default: [] 1248 | choose: 1249 | - alias: "Trigger: Timeout" 1250 | conditions: "{{ user_response.result == 'timeout' }}" 1251 | sequence: !input timeout_action # "{{ timeout_actions }}" 1252 | - alias: "Trigger: Notification Cleared" 1253 | conditions: "{{ user_response.result == 'notification_cleared' }}" 1254 | sequence: !input timeout_action # "{{ timeout_actions }}" 1255 | - alias: "Trigger: first_option" 1256 | conditions: "{{ user_response.result == 'option_one' }}" 1257 | sequence: !input confirm_action # "{{ option_one_actions }}" 1258 | - alias: "Trigger: second_option" 1259 | conditions: "{{ user_response.result == 'option_two' }}" 1260 | sequence: !input dismiss_action # "{{ option_two_actions }}" 1261 | - alias: "Trigger: third_option" 1262 | conditions: "{{ user_response.result == 'option_three' }}" 1263 | sequence: !input option_three_action # "{{ option_three_actions }}" 1264 | 1265 | ############################## 1266 | # Compatibility: iOS Clear Notification 1267 | ############################## 1268 | - alias: "Send clear notification commands" 1269 | if: 1270 | - alias: "Should send clear notification command? (for iOS/macOS)?" 1271 | condition: template 1272 | value_template: "{{ expect_response and enable_timeout and clear_on_timeout and notification_data.apple_device }}" 1273 | then: 1274 | - alias: "Send clear notification command to iOS device" 1275 | service: "{{ notify_service }}" 1276 | data: 1277 | message: "clear_notification" 1278 | data: 1279 | tag: "{{ tag }}" 1280 | 1281 | ############################## 1282 | # Return user response 1283 | ############################## 1284 | - stop: "Script stopped." 1285 | response_variable: "user_response" 1286 | --------------------------------------------------------------------------------