🔔 Notifications - Actionable Mobile Notifications Script, with optional Timeout Feature and Camera Snapshots [works with iOS/Android]

This is very nice and very clean!

Only feature I would like to see is the ability to notify a group of mobile devices instead of one individual. It’s not a big deal to set up 2 scripts for myself and my wife, but it would be slightly easier to be able to use a notify group.

Thanks! I love the timeout feature.

Edit: I modified and created my own version based off of this. I added the ability to choose a notify service in order to send the same notification to my notifcation groups. I also added a notification icon and icon color (Android only)

blueprint:
  name: My Notifications
  description: Forked from v1.1 of https://github.com/samuelthng/t-house-blueprints/blob/main/notifications.yaml
  domain: script
  input:
    notify_device:
      name: "Notify service (use 'notify.*'. Create a group for multiple)"
      description: Device needs to run the official Home Assistant app to receive
        notifications.
      selector:
        text:
            type: search
    title:
      name: "Title"
      description: The notification title.
      default: ''
      selector:
        text: {}
    message:
      name: "Message"
      description: The notification message body
      selector:
        text: {}
    icon:
      name: "Icon (Android Only)"
      selector:
        icon: {}
    icon_color:
      name: "Icon Color (Android Only, hex or color name)"
      selector:
        text: {}
    confirm_text:
      name: Confirmation Text
      description: Text to show on the confirmation button
      default: Confirm
      selector:
        text: {}
    confirm_action:
      name: Confirmation Action
      description: Action to run when notification is confirmed
      default: []
      selector:
        action: {}
    dismiss_text:
      name: Dismiss Text
      description: Text to show on the dismiss button
      default: Dismiss
      selector:
        text: {}
    dismiss_action:
      name: Dismiss Action
      description: Action to run when notification is dismissed
      default: []
      selector:
        action: {}
    timeout:
      name: Timeout Duration
      description: Amount of time to wait for a confirm/dismiss response before firing
        timeout action.
      selector:
        duration:
          enable_day: false
    timeout_action:
      name: Timeout Action
      description: Action to run when notification response is timed out.
      default: []
      selector:
        action: {}
    tag:
      name: Tag
      description: Used for unique identification of the notification. Must not use underscores.
      selector:
        text: {}
    clear_on_timeout:
      name: "Clear notification on timeout - ⚠️ Tag Required"
      description: Dismiss the notification after action selection times out.
      default: leave_notification
      selector:
        boolean: {}
    persist:
      name: "(Android Only) Persistent Notification - ⚠️ Tag Required"
      description: Ensures that notification cannot be dismissed by swiping away.
      default: false
      selector:
        boolean: {}
    channel:
      name: (Android Only) Notification Channel
      description: Defines the channel, to be used with Importance. Relates to the
        importance of the notification.
      default: General
      selector:
        select:
          options:
          - label: General
            value: General
          - label: Alarm
            value: Alarm
          - label: Brewery
            value: Brewery
          - label: Door
            value: Door
          multiple: false
          custom_value: true
    importance:
      name: (Android Only) Notification Channel Importance
      description: https://companion.home-assistant.io/docs/notifications/notifications-basic/#notification-channel-importance
      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
          multiple: false
          custom_value: false
    interruption_level:
      name: (IOS Only) Interruption Level
      description: https://companion.home-assistant.io/docs/notifications/notifications-basic/#interruption-level
      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
          multiple: false
          custom_value: false
mode: restart
sequence:
- alias: Set up variables
  variables:
    action_confirm: '{{ ''CONFIRM_'' ~ context.id }}'
    action_dismiss: '{{ ''DISMISS_'' ~ context.id }}'
    clear_on_timeout: !input clear_on_timeout
    persist: !input persist
- alias: Send notification
  service: !input notify_device
  data:
    title: !input title
    message: !input message
    data:
      actions:
      - action: '{{ action_confirm }}'
        title: !input confirm_text
      - action: '{{ action_dismiss }}'
        title: !input dismiss_text
      tag: !input tag
      notification_icon: !input icon
      color: !input icon_color
      persistent: !input persist
      timeout: !input timeout
      channel: !input channel
      importance: !input importance
      push:
        interruption-level: !input interruption_level
- alias: Awaiting response
  wait_for_trigger:
  - platform: event
    event_type: mobile_app_notification_action
    event_data:
      action: '{{ action_confirm }}'
  - platform: event
    event_type: mobile_app_notification_action
    event_data:
      action: '{{ action_dismiss }}'
  timeout: !input timeout
  continue_on_timeout: true
- 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
  - conditions: '{{ wait.trigger == none }}'
    sequence: !input timeout_action
- if:
  - alias: Clear Notification Enabled
    condition: template
    value_template: '{{ clear_on_timeout == true }}'
  then:
  - alias: Send notification
    service: !input notify_device
    data:
      message: "clear_notification"
      data:
        tag: !input tag
2 Likes