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

Hi, for sure.

As far as i seen it, it saves pictures to folder www. Very fast, very stable from my feeling.

Thanks

1 Like

Thank you for the really great blueprint!
How can I get notifications on android to be more noticeable? All I get is a notification banner, but I would like it to be able to make my phone ring/beep/etc for cases such as a home alarm or water leak sensor being triggered.
Hereā€™s what I have so far:

alias: šŸ”” Notifications (Version 2.0.1)
use_blueprint:
  path: samuelthng/notifications.yaml
  input:
    notify_device: <my device id>
    title: Home Alarm Triggered
    message: Home Alarm Triggered
    dismiss_enabled: false
    run_timeout_actions: false
    channel: alarm_stream
    importance: high
    visibility: public
icon: mdi:alarm-light-outline

Thank you,
Ari

Hey Ari, thank you for trying out the blueprint!

You can try the following to set custom notification rules for specific notifications.

Firstly, youā€™ll have to set a group to the notification.

Next, run the script so that your phone registers the notification group youā€™ve created via the sent notification.

Finally, on your Android phone settings, configure the specific group (in notifications settings, under the Home Assistant Companion app) to have specific options. On my Samsung device, Iā€™m able to set a custom ringtone and to make the notification a pop-up. YMMV.

I might also look into adding status bar icons in the next release so that you have a customisable visual indicator if the icon notification is missed.

P.S. Sadly we donā€™t have a Critical Notification equivalent option for Android. :smiling_face_with_tear: Iā€™ll have to do some research.

Oh yeah I did study this blueprint before implementing the camera snapshot feature. I initially did not see the benefit of having to store a separate snapshot that has weaker security initially, when home assistant provided the entity picture basically free.

However, since it has its merits, Iā€™ll take a look at the feasibility of adding this as an alternative strategy. No promises at this point!

P.S. sorry I still donā€™t have an actual camera to test in my home. So Iā€™ll have to try it out, if it gets somewhere, will need to put it in beta for some time to get comments.

1 Like

Thank you, I believe I had done that with the notification ā€œchannelā€. In the alert script I had set the channel to ā€œalarm_streamā€, and then in the HA Companion app, I had configured the alerts for that channel as in the screenshot below:

and also, the notification sound and volume level for that channel:

Could this perhaps be more an issue with the companion app than with the script?

Or a known issues with Samsung? (Iā€™m using a Samsung Galaxy S21)
https://github.com/home-assistant/android/issues/1465

Iā€™ve tried a number of suggestions but cannot get the notifications to be audible.
Until thatā€™s sorted Iā€™ve just put something in macrodroid to read notifications from home assistant and alert me with sound, TTS, and vibration

Hey @adoucette I seem to be able to reproduce the issue youā€™re describing on my S20 FE. :sob:

In the previous version of Android I recall being able to send urgent notifications, but it seems some of that functionality has changed.

Iā€™ll take a look at this at my next availability, busy with the holiday season. If itā€™s an issue with the app, Iā€™ll try to come up with a minimal reproducible example for HA companion app.

the macrodroid workaround is working fine - no rush.
still really appreciate your blueprint

1 Like

Is there a way I can have multiple cameras trigger this notification blueprint and the message or entity is passed via a variable?

Hey @igorski88, yes it is possible.

  1. Setup a generic notification script for all cameras to begin.

  2. Thereafter, when calling the script from your automation, you are able to override the camera entity selected:

    Field names in yaml mode:

    • Override message: field_message
    • Override camera entity: field_attachment_camera_entity
  3. You may choose to override other fields if required.

  4. If you wish to use templates for the field variables, check out the examples provided in the Preview section of this reply.

I would think if you are able to determine which camera entity triggered the automation, youā€™d be able to map the camera entity dynamically either using templates or manually mapping using a choose block.


Example: Dynamic notification in automations using templates

Hereā€™s a simple automation with two triggers (my homeā€™s bypass helpers).

When the automation is triggered, the trigger variable will be set. You can find the details in the Traces ā†’ Changed Variables page of your automation.

Using the trigger variable, you can create dynamic notifications like the following:

image image

alias: My Test Automation
mode: single

# Two triggers.
trigger:
  - platform: state
    entity_id:
      - input_boolean.bypass_disable_leave_home_automation
  - platform: state
    entity_id:
      - input_boolean.living_room_disable_light_sensor

# Dynamic notification details based on automation trigger.
action:
  - service: script.my_test_notifications
    metadata: {}
    data:
      field_title: "{{ trigger.to_state.attributes.friendly_name }}"
      field_message: >-
        {{ trigger.from_state.state | title }} ā†’ {{ trigger.to_state.state |
        title }}

Hope this is clear and helps!

Hi, thanks so much for this awesome blueprint. Very well thought out and intuitive.

I am somewhat new to ios notificaitons with HA, and am running into some issues. I am attempting to send an alert to my phone when the home alarm is armed. This works fine. However, I also want to add an option to disarm the alarm, so I have toggled on Option 1, and added an action to disarm the alarm device. However, I donā€™t see any option when I receive the notification on my phone. I just get the message that the alarm is armed. When I click on the notification it just opens home assistant.

I feel like I am missing something basic here. Appreciate any tips anyone can provide.

Hey @statecowboy, thanks for trying out the script and for your kind words.

Firstly, on iOS, try to press and hold the notification and see if the option is there. No idea why Apple hides the notification options, but thatā€™s how it is. :frowning:

If it is not, would you mind sharing your notification script and the automation script? You can send it to me in a private message instead if thatā€™s more appropriate for you.

1 Like

Wow, thanks for the quick reply. So, sure enough holding on the alert brings up the options. Everything appears to be working as intended. I guess I was expecting the options to show up underneath of the alert. Now I know.

Thanks again.

1 Like

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: {}

1 Like

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. :sob:

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.