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

Thank you so much again! :saluting_face:

As for yaml code, if you meant to use templates in the message, we can do that right now, but it is a little less pretty due to interface user interface limitations.

Check out the preview section in this changelog for some examples of using templates in the scripts.

1 Like

Hello, so got it to work but as soon as I restart the token changes. is there a way to solve this? is there the possibility to save them somehow permanently?
Maybe save the snapshots to a www folder or so?

You can try the camera.snapshot service, this might be what youā€™re looking for. I have not used it myself, so wonā€™t be able to advice much on it!

The service saves the image to a folder of your choosing if Iā€™m not wrong. I donā€™t really like this method because if youā€™re accessing it externally it would be less secure than having the token attached.

Edit: @flrnwrzl oof sorry man, reply didnā€™t work somehow. So tagging you here instead.

Thanks.

Fore some reason when i try to send a notification with a snapshot of the camera attached using your script it takes too long to capture. So i never see whats happening.
I call the script in a automatiom when movement is detected via automation.

In different blueprint it works faster and very reliable. What can it be softwareside?

Yeah there can be differences based on how the integrations setup the entityā€™s image, or which source image is being used.

Do you have a link to the other blueprint? I could have a study to understand the mechanism used by the other blueprint, and if itā€™s more effective, could review having that as an optional alternative strategy.

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