confirmable_notification.yaml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. blueprint:
  2. name: Confirmable Notification
  3. description: >-
  4. A script that sends an actionable notification with a confirmation before
  5. running the specified action.
  6. domain: script
  7. source_url: https://github.com/home-assistant/core/blob/master/homeassistant/components/script/blueprints/confirmable_notification.yaml
  8. input:
  9. notify_device:
  10. name: Device to notify
  11. description: Device needs to run the official Home Assistant app to receive notifications.
  12. selector:
  13. device:
  14. integration: mobile_app
  15. title:
  16. name: "Title"
  17. description: "The title of the button shown in the notification."
  18. default: ""
  19. selector:
  20. text:
  21. message:
  22. name: "Message"
  23. description: "The message body"
  24. selector:
  25. text:
  26. confirm_text:
  27. name: "Confirmation Text"
  28. description: "Text to show on the confirmation button"
  29. default: "Confirm"
  30. selector:
  31. text:
  32. confirm_action:
  33. name: "Confirmation Action"
  34. description: "Action to run when notification is confirmed"
  35. default: []
  36. selector:
  37. action:
  38. dismiss_text:
  39. name: "Dismiss Text"
  40. description: "Text to show on the dismiss button"
  41. default: "Dismiss"
  42. selector:
  43. text:
  44. dismiss_action:
  45. name: "Dismiss Action"
  46. description: "Action to run when notification is dismissed"
  47. default: []
  48. selector:
  49. action:
  50. mode: restart
  51. sequence:
  52. - alias: "Set up variables"
  53. variables:
  54. action_confirm: "{{ 'CONFIRM_' ~ context.id }}"
  55. action_dismiss: "{{ 'DISMISS_' ~ context.id }}"
  56. - alias: "Send notification"
  57. domain: mobile_app
  58. type: notify
  59. device_id: !input notify_device
  60. title: !input title
  61. message: !input message
  62. data:
  63. actions:
  64. - action: "{{ action_confirm }}"
  65. title: !input confirm_text
  66. - action: "{{ action_dismiss }}"
  67. title: !input dismiss_text
  68. - alias: "Awaiting response"
  69. wait_for_trigger:
  70. - platform: event
  71. event_type: mobile_app_notification_action
  72. event_data:
  73. action: "{{ action_confirm }}"
  74. - platform: event
  75. event_type: mobile_app_notification_action
  76. event_data:
  77. action: "{{ action_dismiss }}"
  78. - choose:
  79. - conditions: "{{ wait.trigger.event.data.action == action_confirm }}"
  80. sequence: !input confirm_action
  81. - conditions: "{{ wait.trigger.event.data.action == action_dismiss }}"
  82. sequence: !input dismiss_action