blueprint:
  description: A script that sends an actionable notification with a confirmation before running the specified action.
  domain: script
  input:
    confirm_action:
      default: []
      description: Action to run when notification is confirmed
      name: Confirmation Action
      selector:
        action:
    confirm_text:
      default: Confirm
      description: Text to show on the confirmation button
      name: Confirmation Text
      selector:
        text:
    dismiss_action:
      default: []
      description: Action to run when notification is dismissed
      name: Dismiss Action
      selector:
        action:
    dismiss_text:
      default: Dismiss
      description: Text to show on the dismiss button
      name: Dismiss Text
      selector:
        text:
    message:
      description: The message body
      name: Message
      selector:
        text:
    notify_device:
      description: Device needs to run the official Home Assistant app to receive notifications.
      name: Device to notify
      selector:
        device:
          integration: mobile_app
    title:
      default: ''
      description: The title of the button shown in the notification.
      name: Title
      selector:
        text:
  name: Confirmable Notification
  source_url: https://github.com/home-assistant/core/blob/master/homeassistant/components/script/blueprints/confirmable_notification.yaml
mode: restart
sequence:
- alias: Set up variables
  variables:
    action_confirm: '{{ ''CONFIRM_'' ~ context.id }}'
    action_dismiss: '{{ ''DISMISS_'' ~ context.id }}'
- alias: Send notification
  data:
    actions:
    - action: '{{ action_confirm }}'
      title: !input 'confirm_text'
    - action: '{{ action_dismiss }}'
      title: !input 'dismiss_text'
  device_id: !input 'notify_device'
  domain: mobile_app
  message: !input 'message'
  title: !input 'title'
  type: notify
- alias: Awaiting response
  wait_for_trigger:
  - event_data:
      action: '{{ action_confirm }}'
    event_type: mobile_app_notification_action
    platform: event
  - event_data:
      action: '{{ action_dismiss }}'
    event_type: mobile_app_notification_action
    platform: event
- choose:
  - conditions: '{{ wait.trigger.event.data.action == action_confirm }}'
    sequence: !input 'confirm_action'
  - conditions: '{{ wait.trigger.event.data.action == action_dismiss }}'
    sequence: !input 'dismiss_action'
