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

The blueprint pulls the images directly from the camera entity’s attribute 'entity_picture’.

It’s supposed to be set by every camera entity and would come with a token specifically for external access.

You can try using Developer Tools :arrow_right: States, select a camera entity in the set states section. It will show you all the attributes on the entity, and you should find entity picture there as a relative path to the image.

I’m looking to trigger notification after a certain time. How can I set this up?
Ex: If lights were left on for more than 30 minutes, I will get a notification.

Thanks

Hello @hazio, this is a script blueprint. After creating the script for your notification, you can trigger it in any automation you require.

See How To Use for some pointers.

1 Like

:christmas_tree: Version 2.0: Fields!

:arrow_double_down: Import Version | :link: Github Link | :male_detective:t2: Compare Changes

Multi-device Variant:

:arrow_double_down: Import Version | :link: Github Link | :male_detective:t2: Compare Changes

:memo: What’s Changed

If you are already using Version 2 Beta 2, you may skip this release.

:warning: Service to Notify has been deprecated, stay on v1.6.1 if you rely on this option.

Existing scripts that do not use the above should not be affected this release. :crossed_fingers:t2: 🫳🏻 :wood:

  • :beetle: iOS Notifications with Camera Snapshots showing Failed to load attachment.
  • :oncoming_automobile: Android: Added Show on Android Auto option.
  • :hourglass: Enable Timeout Action(s) option to dynamically disable timeout actions
  • :scroll: Fields Support Added! (requires Home Assistant 2023.11 or newer)

:question: How to update:

Home Assistant 2023.12 and up:

Before Home Assistant 2023.12:

:mag_right: Things to check after updating:

  • As usual, existing scripts should be loaded.
  • If you have switched between either variants, check out this reply.
  • Script should show one of:
    • Version 2.0
    • Version 2.0 - Multi-device.

:eyes: Preview:

Show/Hide: Script Fields Preview


Show/Hide: Script Fields with Templates


Example payload:

service: script.my_test_notifications
data:
  field_title: >-
    {{ state_attr("sun.sun", "friendly_name") }}
  field_message: >-
    {% if is_state("sun.sun", "above_horizon") -%}
      The sun rose {{ relative_time(states.sun.sun.last_changed) }} ago.
    {%- else -%}
      The sun will rise at {{ as_timestamp(state_attr("sun.sun", "next_rising")) | timestamp_local }}.
    {%- endif %}

Result:


Show/Hide: Script Fields in Automations with Templates


Version 2 - 12 Dec 2023

  • Fixed: iOS showing Failed to load attachment
  • Refactor: Build payload in templates
  • Deprecated: 📲 Notification Strategy due to refactor.
  • Deprecated: 📲 Service to notify due to refactor.
  • Added: Support for fields
    • Added: 🏷️ Title field
    • Added: 💬 Message field
    • Added: 🏷️ Subtitle field
    • Added: 📸 Attachment: Camera Entity: Camera Entity field
    • Added: Options show/hide fields
    • Added: ⌛️ Enable Timeout and ⌛️ Enable Timeout Action(s) fields.
  • Added: 🚘 Show on Android Auto option.
  • Added: ⌛️ Enable Timeout Action(s) option and field.

Notes:

  • When enabling boolean fields with value of false, be sure to toggle them to true once, and then to false.
    There seems to be a bug where the boolean value is not passed if it’s enabled and value is false without the toggle.
  • If you rely on 📲 Service to notify, do not upgrade, Version 1.6.1 will be the last version supporting that feature.

Hi @samuelthng, I am trying your blueprint for the first time and it looks amazing! My congratulations for the great work.

I’m just having a small problem and that is that I would like to group several related notifications (group) and be able to replace them with new ones (tag) as reminders.

I have created a new script using your Blueprint and just set a message, disabled the action buttons (option 1 and option 2) and set the Group ID field to “tasks” and Tag to “dishwasher”. Then, I run the script and, when I check the traces, I see that neither the group nor the tag are being sent.

What could be the problem?

Thanks in advance!

Hey @Deivy7,

Firstly, welcome to the community, thank you for your kind words!

Secondly, it’s a bug on the blueprint - a miss on my end after the last refactor.
Thank you very much for bringing this to my attention, really appreciate it!

Here’s a fixed version that should resolve the missing tag and group data:

:lady_beetle: Version 2.0.1: Missing Tag and Group!

:arrow_double_down: Import Version | :link: Github Link | :male_detective:t2: Compare Changes

Multi-device Variant:

:arrow_double_down: Import Version | :link: Github Link | :male_detective:t2: Compare Changes

:memo: What’s Changed

Existing scripts that do not use the tag and group fields should not be affected this release. :crossed_fingers:t2: 🫳🏻 :wood:

  • :lady_beetle: Fixed: Tag and Group were not being sent after the refactor.

:question: How to update:

Home Assistant 2023.12 and up:

Before Home Assistant 2023.12:

:mag_right: Things to check after updating:

  • As usual, existing scripts should be loaded.
  • If you have switched between either variants, check out this reply.
  • Script should show one of:
    • Version 2.0.1
    • Version 2.0.1 - Multi-device.
  • The tag and group property should now be set if you have them defined, you can verify this in the notification step of your trace.
2 Likes

Hi, just installed and completly love your scripts. simple to use, very powerful. AWESOME!

I got one question. how can i access the pictures which are attached to the push notification?
Where is it saved? How can i access this folder?

Thanks for your work and help!

1 Like

Hey @flrnwrzl, thank you for the kind words, makes the effort totally worth it!

The pictures from the camera entity are derived directly from it’s entity_picture attribute.
You can use this template to view the relative path to the image:

{{ state_attr('camera.<your_camera_entity_id>', 'entity_picture') }}

You can get the value of the attribute at this page:
Open your Home Assistant instance and show your template developer tools.

The result of the template will be a relative URL to the snapshot used in the blueprint.

Example:

  1. Home assistant URL: http://homeassistant.local:8123

  2. Entity: camera.roborock_g10_map

  3. Using the template:

  4. The image URL:
    http://homeassistant.local:8123/api/camera_proxy/camera.roborock_g10_map?token=<some_token>

Hope this helps!

P.S. Do keep the token private, it’s considered sensitive data.

1 Like

Hey @samuelthng ,

I just tested again and now the tag and group are working perfectly!
I’m going to start creating all my notifications with your blueprint.

Thank you very much for your quick response and hotfix! :blush:

1 Like

Wow thanks for the quick and detailed answer. I will try this weekend and give feedback. And maybe ask again if needed. But still amazed by this powerful script.

Maybe one thing as inspiration for a possible new feature in the fututre. The 1 thing I am missing is to add YAML code to message text. If this would work in the future…amazing.

Keep up the amazing work!

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?