Can I setup a notification when the light is left on of for a x amount of time using this script?
Hey @hazio, the script allows you to configure the notifications youāll see on your phone.
After youāve setup the script, you can use the script in any automation of your choice. You can think of it as a building block to help configure notifications for other automations.
You may refer to the How To Use section for more information.
A quick example for an automation that will call this script if a light was left on would be as so:
Example
description: "Triggers a notification script if light left on for 30 minutes"
mode: single
trigger:
- platform: state
entity_id:
- light.my_light_here # The entity_id of your light.
to: "on"
for:
hours: 0
minutes: 30 # Configure your duration here
seconds: 0
condition: []
action:
# Trigger a notification script created using this blueprint.
- service: script.light_left_on_reminder_here
metadata: {}
data: {}
Hi, your template is great, thanks!
Iām having some trouble with android notification group. No matter what I do, it always ends up as a general notification.
When I send this to my phone, it successfully creates a group:
service: notify.mobile_app_pixel_7
data:
message: "create_channel"
data:
channel: "Doorbell"
importance: high
ttl: 0
color: red
group: doorbell
It also arrives a bit quicker that the script notification.
Is there anything I can do to force it?
Thanks!
Hey @Jonathanpbk, yeah actually those are my fault.
I have a fix coming along but am recently overwhelmed at my day job.
The fix for the channels are already available here:
As for ttl
and importance
, those are already verified and will be added in the next commit.
Thank you for highlighting these issues! Appreciate it!
How to set volume of ios critical notification?
Thanks, the beta version solved the notification channel! Now I can set custom notification sound etc for this alert.
Eagerly awaiting the ttl and importance addition, because the notifications are still very delayed, and Iām trying to use it for a doorbell notification.
Is there a simple way of me adding it myself? I tried editing the blueprint, but it wouldnāt work because of the mapping, and I really donāt understand how it all works, so I wonāt mess with it any further lol
Yes, itās in fact commented out in the beta, you can uncomment it and have it hard coded and added to the payload. Give me about 36 hours, I should be able to push at least these changes by Saturday.
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.