This is super cool! Because the notification actions are an android standard y can click them from my SmartWatch (garmin). This will greatly reduce my usage of the phone!
Thanks to @vorion for creating this Blueprint
I have modified the one that is now built-in Home assistant (I am not sure what is different aside from being a script and the in the OP is a automation)
The changes are:
-
The target is now the name of a notify service, so you would enter: ânotify.âdevice/group nameââ.
For example: notify.mobile_app_oneplus or notify.phones_group
Please note that the input is not validated, so make sure the spelling is correct. -
Clearing the notification will trigger the Dismiss Action
-
Actioning or clearing the notification from one device will remove the notification from all other devices.
-
Added an option for timeout, after the time is done the Dismiss Action will be triggered, and the notification will be cleared.
blueprint:
name: Confirmable Notification
description: >-
A script that sends an actionable notification with a confirmation before
running the specified action.
domain: script
source_url: https://github.com/home-assistant/core/blob/919f4dd719ac2551ca63a93780852bba1aadd7b0/homeassistant/components/script/blueprints/confirmable_notification.yaml
input:
notify_device:
name: Notification service
description: Notification service name (ex. Notify.mobile_app_....). Note that device/s needs to run the official Home Assistant app to receive notifications.
selector:
text:
title:
name: "Title"
description: "The title of the button shown in the notification."
default: ""
selector:
text:
message:
name: "Message"
description: "The message body"
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:
tag:
name: "Notification Tag"
description: "notification tag for updating and dismissing the notification"
default: {}
selector:
text:
timeout:
name: "Timeout duration"
default: {}
selector:
duration:
mode: restart
sequence:
- alias: "Set up variables"
variables:
action_confirm: "{{ 'CONFIRM_' ~ context.id }}"
action_dismiss: "{{ 'DISMISS_' ~ context.id }}"
- alias: "Send notification"
service: !input notify_device
data:
message: !input message
title: !input title
data:
actions:
- action: "{{ action_confirm }}"
title: !input confirm_text
- action: "{{ action_dismiss }}"
title: !input dismiss_text
tag: !input tag
- 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 }}"
- platform: event
event_type: mobile_app_notification_cleared
timeout: !input timeout
- choose:
- conditions: '{{ wait.trigger.event.event_type == "mobile_app_notification_cleared" }}'
sequence:
- service: !input notify_device
data:
message: clear_notification
data:
tag: !input tag
- choose:
default: !input dismiss_action
- conditions: "{{ wait.trigger.event.data.action == action_confirm }}"
sequence:
- service: !input notify_device
data:
message: clear_notification
data:
tag: !input tag
- choose:
default: !input confirm_action
- conditions: "{{ wait.trigger.event.data.action == action_dismiss }}"
sequence:
- service: !input notify_device
data:
message: clear_notification
data:
tag: !input tag
- choose:
default: !input dismiss_action
- conditions: "{{ wait.remaining == 0}}"
sequence:
- service: !input notify_device
data:
message: clear_notification
data:
tag: !input tag
- choose:
default: !input dismiss_action
Mentioning those who asked for this ability
@EvlLprchn @sacredshapes @tanderson1992 @frelev @jesc @rlyons20
I keep getting this error when trying to run the automation.
Error: Unable to find notify service for webhook ID
check if your notify service didnt change
Any chance anyone know how to get the Notification Channel working with this blueprint? Iâve modified it a bunch of different ways and I cannot get it to work. I feel like what I have here looks right, but Iâm no expert.
blueprint:
name: Test2
description: 'Send actionable notifications to an Android device
'
domain: automation
input:
notify_device:
name: Device to notify
description: Device needs to run the official Home Assistant app to receive
notifications
selector:
device:
integration: mobile_app
multiple: false
trigger_entity:
name: Trigger entity
description: Send the notification when this boolean turns on
selector:
entity:
domain: input_boolean
multiple: false
notification_title:
name: Notification title (Optional)
description: The title of the notification
default: ''
notification_message:
name: Notification message (Optional)
description: The message of the notification
default: ''
notification_tag:
name: Notification tag (Optional)
description: The tag of the notification
default: ''
notification_channel:
name: Notification channel (Optional)
description: The channel of the notification
default: ''
notification_timeout:
name: Notification timeout (Optional)
description: Length of time the notification is displayed
default: ''
persistent_notification:
name: Create persistent notification?
description: Persistent notifications cannot be dimissed by swiping away
default: false
selector:
boolean: {}
action_1_title:
name: First action name
description: Name of the first button
default: ''
action_1_uri:
name: URI for action 1 (Optional)
description: Optional URI for the first action
default: ''
first_action:
name: Action 1
description: Action to run when the first action is clicked
default: []
selector:
action: {}
action_2_title:
name: Second action name
description: Name of the second button
default: ''
action_2_uri:
name: URI for action 1 (Optional)
description: Optional URI for the second action
default: ''
second_action:
name: Action 2
description: Action to run when the second action is clicked"
default: []
selector:
action: {}
action_3_title:
name: Third action name
description: Name of the third button
default: ''
action_3_uri:
name: URI for action 3 (Optional)
description: Optional URI for the third action
default: ''
third_action:
name: Action 3
description: Action to run when the third action is clicked
default: []
selector:
action: {}
source_url: https://community.home-assistant.io/t/actionable-notifications-for-android/256773
mode: restart
max_exceeded: silent
variables:
notify_device: !input 'notify_device'
trigger_entity: !input 'trigger_entity'
notification_title: !input 'notification_title'
notification_message: !input 'notification_message'
notification_tag: !input 'notification_tag'
notification_channel: !input 'notification_channel'
notification_timeout: !input 'notification_timeout'
persistent_notification: !input 'persistent_notification'
action_1_title: !input 'action_1_title'
action_1_uri: !input 'action_1_uri'
first_action: !input 'first_action'
action_2_title: !input 'action_2_title'
action_2_uri: !input 'action_2_uri'
second_action: !input 'second_action'
action_3_title: !input 'action_3_title'
action_3_uri: !input 'action_3_uri'
third_action: !input 'third_action'
trigger:
platform: state
entity_id: !input 'trigger_entity'
from: 'off'
to: 'on'
action:
- service: input_boolean.turn_off
entity_id: !input 'trigger_entity'
- domain: mobile_app
type: notify
device_id: !input 'notify_device'
title: '{{ notification_title }}'
message: '{{ notification_message }}'
data:
tag: '{{ notification_tag }}'
timeout: '{{ notification_timeout }}'
persistent: '{{ persistent_notification }}'
data:
channel: '{{ notification_channel }}'
actions: "{% set titles = [action_1_title, action_2_title, action_3_title] %}\
\ {% set uris = [action_1_uri, action_2_uri, action_3_uri] %} {% set actions\
\ = namespace(data = []) %}\n{% for title in titles %}\n {% if title|length\
\ %}\n {% set uri = uris[loop.index - 1] %}\n {% set action_name = \"\
action\" + loop.index|string %}\n {% set action = {\n \"action\": \"\
URI\" if uri|length else action_name,\n \"title\": title,\n \"uri\"\
: uri \n }\n %}\n {% set actions.data = actions.data + [action] %}\n\
\ {% endif %}\n{% endfor %} {{ actions.data }}\n"
- wait_for_trigger:
platform: event
event_type: mobile_app_notification_action
- choose:
- conditions: '{{ wait.trigger.event.data.action == ''action1'' }}'
sequence: !input 'first_action'
- conditions: '{{ wait.trigger.event.data.action == ''action2'' }}'
sequence: !input 'second_action'
- conditions: '{{ wait.trigger.event.data.action == ''action3'' }}'
sequence: !input 'third_action'
ditch the extra data line and move channel back in line with persistent and actions.
-face palms- I swear I tried that and it didnât work⌠But it totally just worked. Thanks!
Thanks for this blueprint. One question though, is it possible that an action is executed if NO action button is clicked?
I have now made 3 options for the notification, but if neither is chosen, I want something to happen.
Thats a pretty good idea and would be nice to have
very cool with notify group. Can i add a camera image ? I can not add data / image on Push message
If you havenât figured this out yet, youâre looking for this one: Actionable notifications for Android w/ Cam Snapshot - #10 by ams3401
I tweaked the code for my purposes to allow any entity state as a trigger. Iâm no BP expert so check the code but it works for me actioning one of two scripts when the cat door enters curfew mode unexpectedly.
Could this also be modified to
-
have a ânormalâ trigger field so you can use every trigger that a normal automation can have?
-
be able to set the notification channel from the BP?
Best regards
Aaron
I would love to see the same like @aaroneisele55 said.
I would love to select my own trigger, and not be limited to a input boolean.
I just want to send a notification if lights are still on. And then have the option to turn it off with the notification.
totally agree, same for me
Is there a way to add the custom notification icon the same as other notification/alerts ive tried adding notification_icon:mdi but it doesnât work.
Thanks
Awesome work. I was wondering if instead of an input.boolean triggering the automation we could have time based reminders within the blueprint?
At the moment I have to create a reminder automation to set the input.boolean to turn on which in turn then sends this blueprint notification. Frankly it would eliminate the input.boolean and the additional automation.
I have used this blueprint for quite some time now. But lately i have been seeing some weird behaviourâŚ
Sometimes (maybe everytime) i get a notification and chose some action, it also fires different actions from other automations based on this blueprint ??
Today when i got a notification saying that my car was unlocked after being parked for 5 min. and i choose to lock the car from the notification it also turned off the pellet stove at home wich is an action i have in a different automation based on this blueprint
Has anyone else noticed this behavior ?
Is there any way to have a pop-up dialog on Android with this? i.e., instead of a notification in the status bar, we get an alert/dialog regardless of which app/home screen youâre on. So itâs easy to click a button like âYesâ or âNoâ and take some action.
that would need to be handled as a feature request for the app as the functionality does not exist yet, nice suggestion