Hey @Trilis29, it’s currently not supported yet, but I could add it into the list.
Hey @Jonathanpbk, late delivery!
Here’s a link to the script with priority and ttl added:
This is still not the final, I’m still working on a couple of features on my end but you can try this out first.
Amazing, that seems to work perfectly now! Thanks!
Hi, can you also change this for the multi-device version, so I can have the doorbell sound on both phones?
I am very happy with this blueprint and use it for many notifications. or could you explain how I can change this. thank you in advance!
Thankss!
First of all, I want to thank you for all the work you have put in this blueprint. Really a game changer when you want to use generic notifications. I have one issue that I don’t know how to solve when using generic notification. When I create a generic notification and I want to use it in various automations with the use of dynamic fields, it all works as long as the generic notification is finished before another automation calls the generic notification. When 2 automations want to use the same generic notification, the first notifications stops and only the second one gets finished. I think it has to do with the script.mode = restart. Can you recall the reason, why u use restart? Is there a possibility to use “parallel” instead, or would it break other features? Maybe it is possible to make the “mode” configurable, depending on your needs.
It was configured to be restart due to two reasons:
-
During the first implementation, there was no way to differentiate responses between instances of script calls.
-
Also, the script was initially not designed for reusability. That was only recently added with the release of script fields.
Maybe using parallel would work today, that’s a good catch, considering the context ID is now taken into account with the tag property today, it might work out.
I’ll add that to my list of items to work on.
First off, thank you @samuelthng for all the hours (weeks?) you’ve devoted to building this crazy powerful blueprint!!!
I just discovered an issue related to @poupaerta’s question.
I’m calling your script twice simultaneously via a parallel action in my automation. In my use case, when I unplug my phone before my alarm goes off (i.e. getting up at 5am because I can’t get back to sleep), I requested two actionable notifications:
-Should coffee start yet?
-Should the heat come on yet?
My result is that I receive both notifications (although which one is first varies), BUT the option I select first, is carried out by BOTH scripts instantly (e.g. I choose option 2 on the first notification, the option 2 for the other script is also fired). Selection of remaining notification is ignored.
I’m sure this is an odd and unforeseen use case. I see several workarounds for my case so I need nothing further. If you don’t go down the rabbit hole of changing it to parallel or making the mode user configurable, I figured it might be worthy of mentioning the limitation of the current version in case others get these unexpected results.
It is a rabbit hole indeed, been playing with variations on my end last weekend.
Also on this topic, PSA to anyone facing similar issues, the simplest workaround is to create multiple scripts as that will mitigate the issue where the script incorrectly listens to another instances’ tag.
Great job with notifications! Thank you lots!
I would like to cycle it in this way:
trigger →
notification 1
(no response)
(notification timeout)
delay
notification 1
(no response)
(notification timeout)
delay
notification 1
(no response)
timeout action
here is my working notification (single time)
alias: dummy notification script
use_blueprint:
path: samuelthng/notifications.yaml
input:
notify_device:
- 54a5ac724ecf51248f327fe6cac5791b
title: dummy acceso
message: spengo?
confirm_text: SI
confirm_action:
- service: input_boolean.turn_off
metadata: {}
data: {}
target:
entity_id: input_boolean.dummy_toggle
dismiss_text: "NO"
clear_on_timeout: true
run_timeout_actions: false
timeout:
hours: 0
minutes: 0
seconds: 10
Thank you lots!
Hey @delumerlino, thanks for the kind words.
You can do that by using another proxy script like the following example:
Example - Repeat notification X times until response is received.
alias: Retry Notifications
sequence:
- repeat:
count: 3 # <-- Times to repeat
sequence:
- service: script.my_test_notifications # <-- Replace with your Notifications script.
metadata: {}
data:
field_message: My Test Message
response_variable: response
- if:
- condition: template
value_template: "{{ response is defined }}"
- condition: template
value_template: >- # <-- Modify if required. `response.result != "timeout"` will also work.
{{ response.result == 'option_one' or response.result == 'option_two' or response.result == 'option_three' or response.result == 'notification_cleared' }}
then:
- stop: User has responded
mode: single
fields: {}
Thanks, I will give it a look!
How to handle a missing response at the timeout? Each time I have an error UndefinedError: ‘None’ has no attribute ‘event’
Maybe you might wanna share your yaml?
Also, be sure to have the latest version of the script for response variables to work.
Sorry, the problem was about “continue on timeout”
This is my proxy script.
It runs 3 times, the first is fired immediately, the other two at 20 seconds of delay.
If the answer is YES, dummy toggle is switched off
If the answer is NO the cycle continues
If there are no replies after three messages, dummy toggle is switched off
alias: Retry Notifications
sequence:
- service: script.1709625314536
metadata: {}
data: {}
response_variable: response
- delay: "00:00:20"
- condition: template
value_template: "{{ is_state('input_boolean.dummy_toggle', 'on') }}"
- service: script.1709625314536
metadata: {}
data: {}
response_variable: response
- delay: "00:00:20"
- condition: template
value_template: "{{ is_state('input_boolean.dummy_toggle', 'on') }}"
- service: script.1709625314536
metadata: {}
data: {}
response_variable: response
- choose:
- conditions:
- condition: template
value_template: "{{ response is defined }}"
- condition: template
value_template: "{{ response.result == 'option_one' }}"
sequence:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.dummy_toggle
data: {}
- stop: User has responded
- conditions:
- condition: template
value_template: "{{ response is defined }}"
- condition: template
value_template: "{{ response.result == 'option_two' }}"
sequence:
- stop: User has responded
- conditions:
- condition: template
value_template: "{{ response is not defined }}"
sequence:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.dummy_toggle
data: {}
mode: single
fields: {}
Thank you!!
Is it possible to add the ability to set the volume of the critical notification on iOS?
Could this be expanded to use other notification types such as Hass Agent or Fire TV notifications?
Hello @NateUT,
I’ve just pushed my local copy where I’ve been testing this change.
This is neither a release or pre-release due to the refactoring of payloads, so use at your own risk.
Do be sure to test your scripts before going about your day, won’t want to miss a notification!
Also be sure to set the Interruption Level
to Critical
for the volume options to be applied.
Version 2.0.2 Beta 2 - 23 March 2024
- Added: Field for
notification_link
. #26 (Thanks to HNKNTA) - Fixed: Field
enable_timeout
. - Added:
response_variable
with payload and response. - Added: Android High Priority Notifications
- Added: iOS Critical Notifications Volume
- Updated:
mode: parallel
- Refactor: Device specific payloads are now evaluated separately for future alternative device support
- Added: Optional Server URL input
Hey @Krispkiwi,
I have currently no plans to add other types of notification services as it will be difficult to maintain those payloads alone.
Hoever, in the above beta, I’ve refactored the code such it will be easy to add on support for those devices if you are able to:
- Identify the type of payload required for a given device
- Write a payload builder for the given device
I personally do not use either Hass Agent nor Fire TV, so any help will be greatly welcome!
Well, I am close but I cannot get any camera image in the notification.
This is the YAML I have:
alias: 🔔Send Motion Notification
use_blueprint:
path: samuelthng/notifications.yaml
input:
notify_device: 9f8ff81591a0936eb19abc1b944fd120
title: Vehicle Detected at Intercom
message: A vehicle was detected at the Rio Crest gate intercom
icon: mdi:motion-sensor
confirm_uri: com.mcu.reolink
confirm_text: Launch Reolink
confirm_option_mode: action
dismiss_enabled: false
notification_link: app://com.mcu.reolink
attachment_type: camera_entity
attachment_camera_entity: camera.rc_intercom_fluent
icon: mdi:motion-sensor
The resulting notification is (no snapshot on the message):
Launching the Reolink app works perfect.
If I “build the URL” I would suspect it should be (NOTE: I use Nabu Casa as this is a remote Home Assistant), I get the image no problem:
https://xxxxxxxxxxxxxxxxxxxxxxxxxx.ui.nabu.casa/api/camera_proxy/camera.rc_intercom_fluent?token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
A few words about what I am trying to do … I have a gate that is about 1 mile away from my winery. I want a notifications to folks when someone hits the gate. Home assistant exists in both places (winery and gate) but they are completely different systems even on different ISPs because of services that are available at the locations. Winery is on Starlink, gate is AT&T 5G so different routers, etc. And Home Assistant installed in both locations.
If the notification has something like “show image from local home assistant” that will not work, because the “viewer” might have Companion pointed to the winery. I would note that in examining the trace, I see this (token x’d out):
notification_data:
apple_device: false
subject: ''
visibility: private
importance: default
priority: high
ttl: 0
clickAction: app://com.mcu.reolink
image: >-
/api/camera_proxy/camera.rc_intercom_fluent?token=xxxxxxxxxxxxxxxxxxxxxxxxxxx
notification_icon: mdi:motion-sensor
channel: General
So does this mean that the notification arrives on the phone and the Companion app goes to “/api/camera_proxy/…” to get the image. If this is true, then I can understand why I get no image because my companion app is pointed to the Winery and not the Gate (completely different Nabu Casa URLs and the cameras are at the gate, not at the winery).
Note I am using the latest blueprint “Notifications (Version 2.0.2 Beta)”
OR … is their some limit on the image size? I would note this is a dual lens Reolink camera so the image is 1536 x 576
Update: I have diagnosed and this is a correct statement:
… the notification arrives on the phone and the Companion app goes to “/api/camera_proxy/…” to get the image.
I had been testing with my phone pointed at the Winery, I changed the Companion App server to point at the Gate and lookie, lookie (I get an image like I want in the notification):
Unfortunately that is not acceptable as a solution because it means people need the companion app pointed to the Gate when at the Winery. And therefore could not control lights/music/etc. So I believe an option needs to be made for the image to be a full URL to a remote server.
I would think this should be modified, accepting like an input_boolean for internal (default) or external… If external, the link for the image should be built with some user-provided external server (assuming this works but I would think it would unless the companion app notification cannot deal with absolute URLs):
- alias: Attachments
variables:
script_attachment_type: !input attachment_type
attachment_type: "{{ iif(field_attachment_type is defined, field_attachment_type, script_attachment_type) }}"
script_attachment_camera_entity: !input attachment_camera_entity
attachment_camera_entity: "{{ iif(field_attachment_camera_entity is defined, field_attachment_camera_entity, script_attachment_camera_entity) }}"
camera_image_url: >-
{% if (attachment_camera_entity|length) %}
{% if (state_attr(attachment_camera_entity,'entity_picture')|length) %}
{{state_attr(attachment_camera_entity,'entity_picture')}}
{% else %}
{{"/api/camera_proxy/{id}".format(id=attachment_camera_entity)}}
{%- endif %}
{%- endif %}
media_url: >-
{{
{
'none': '',
'camera_entity': iif(camera_image_url | length, camera_image_url)
}.get(attachment_type)
}}
As in:
variables:
...
script_camera_remote: !input attachment_remote
script_attachment_remote_server: !input attachment_remote_server
...
And then build the URL depending on whether you need an external HA camera source or an internal HA camera source. Given this from the notification service, I would think remote connections work as the first example is an absolute URL:
automation:
- alias: Notify Mobile app attachment
trigger:
...
action:
- service: notify.mobile_app_<your_device_id_here>
data:
message: "Something happened at home!"
data:
# an example of an absolute url
image: "https://github.com/home-assistant/assets/blob/master/logo/logo.png?raw=true"
# example of a relative url
image: "/media/local/image.png"
# the same works for video
video: "/media/local/video.mp4"
# and for audio
audio: "/media/local/audio.mp3"
This makes it even more evident that that URL sent to the notification service is a relative URL and not an absolute URL.
One note: I tried with no success to do things opposite. Since I use the Remote Home Assistant integration to link the two together, I can trigger the script/automation locally on the Winery Home Assistant. Good start but no bueno, I cannot get the image from the remote camera … images do not work from cameras in Remote Home Assistant AFAIK.
I could come up with an optional text input to override relative links for the camera stream and see if that resolves your issue.
Could you also try if the same is happening on relative links to Lovelace dashboards? The same solution should work in that scenario as well and we could have a go to fix it as well in a beta.