šŸ“ø Notification with camera snapshot with blocking condition and clickaction

Hmm youā€™re right, that wonā€™t work.
Iā€™ll have to experiment a bit.

EDIT: I tried it with service call notify.notify and then the data, but that didnā€™t seem to work.

- service: notify.notify
    data:
      title: "{{ notification_title }}"
      message: "{{ notification_message }}"
      target: !input notify_device
      data: >

I couldnā€™t not find a selector that would let met select the notify group.
So I tried with object and just typing in ā€œSmartphones_en_Tabletā€ as value (the name of my group).

Not working yet, here is what Iā€™m trying:

I have the notification to group working, but without all the data. Just the title and the message.
Iā€™m not quite sure how to solve this.
Iā€™ve tried many iterations of extra data: line or not.

  - service: notify.notify
    data:
      title: "{{ notification_title }}"
      message: "{{ notification_message }}"
      data:
       target: !input notify_who
       data: >
        {% if is_ios %}
          {% if is_critical %}
            {% set platform_data = { "channel": "%s", "url": "%s", "attachment": {"url": "%s", "content_type": "JPEG"},  "push": { "category": "%s", "sound": { "name": "default", "critical": 1, "volume": 1.0 } } } | format(channel_name, clickAction, snapshot_access_file_path, group_name) %}
          {% else %}
            {% if overwrite_similar %}
              {% set platform_data = { "channel": "%s", "url": "%s", "apns_headers": { "apns-collapse-id": "%s" }, "attachment": {"url": "%s", "content_type": "JPEG"},  "push": { "category": "%s", "sound": { "name": "default", "volume": 1.0 } } } | format(channel_name, clickAction, group_name, snapshot_access_file_path, group_name) %}
            {% else %}
              {% set platform_data = { "channel": "%s", "url": "%s", "attachment": {"url": "%s", "content_type": "JPEG"},  "push": { "category": "%s", "sound": { "name": "default", "volume": 1.0 } } } | format(channel_name, clickAction, snapshot_access_file_path, group_name) %}
            {% endif %}
          {% endif %}
        {% else %}
          {% if is_critical %}
            {% if overwrite_similar %}
              {% set platform_data = { "tag": "%s", "channel": "%s", "group": "%s", "ttl": 0, "priority": "high", "clickAction": "%s", "image": "%s"} | format(group_name, channel_name, group_name, clickAction, snapshot_access_file_path) %}
            {% else %}
              {% set platform_data = { "channel": "%s", "ttl": 0, "priority": "high", "clickAction": "%s", "image": "%s"} | format(channel_name, clickAction, snapshot_access_file_path) %}
            {% endif %}
          {% else %}
            {% if overwrite_similar %}
              {% set platform_data = { "tag": "%s", "channel": "%s", "group": "%s", "clickAction": "%s", "image": "%s"} | format(group_name, channel_name, group_name, clickAction, snapshot_access_file_path) %}
            {% else %}
              {% set platform_data = { "channel": "%s", "clickAction": "%s", "image": "%s"} | format(channel_name, clickAction, snapshot_access_file_path) %}
            {% endif %}
          {% endif %}
        {% endif %}
        {{ platform_data }}

Maybe I could just make a version of the blueprint with 2 mobile devices or another version with 3?
Would that be a solution?

Everything works as long as I put at least a 1 second delay-- but the image comes up like this in the notification.
I can find the actual JPG file inside /config/www/tmp but it doesnā€™t show in the notification.
Any ideas?

(Running from a Raspberry Pi, not a Docker or anything like that.)

Make sure you have your External URI configured correctly.

You should try to load the image using a browser to see if that works.
The URL is made out of the External URI you have in your configuration.
Something like: https://my.dyndns.org:8123/tmp/filename.jpg

Hi,

Itā€™s possible to ad an action on mobile for silence notification? similar on this blueprint :

I test but, Iā€™m new on yaml/automation/blueprint and nothing work for meā€¦ :frowning:

thankā€™s for your help

Hi @StanG
Thanks for the blueprint iā€™m wanting to use the trigger as a contact sensor instead of motion so i copied your yaml and editied the top part to this

  domain: automation
  input:
    motion_sensor:
      name: Door sensor
      description: The sensor wich triggers the snapshot creation (domain binary_sensor,
        class motion).
      selector:
        entity:
          domain: binary_sensor
          device_class: door

and also changed the trigger state

trigger:
  platform: state
  entity_id: !input 'motion_sensor'
  from: 'closed'
  to: 'open'

and i can select the contact sensor i want but it doesnā€™t seem to work though as no notifications are sent.
Can you confirm what else i would need to change as i notice i still had ā€œmotion_sensor:ā€ at the top but didnā€™t know what t change that to
Cheers

Hi StanG,

Iā€™m interested in this (send message to multiple devices) as well, did you find any solution for it?

If anyone is using Unifi Protect and are on iOS,if you want to open the Protect app instead of HA then use this URL: ā€œunifi-protect://ā€
Found that the default motion notifications that Protect makes are way to frequent. Using this blueprint with a simple node red debounce timer to prevent duplicate notifications for the same motion.

Just open the protect app on iphone. do you have a full query to open directly camera on IOS ?

I havenā€™t been able to find any combination to open a specific camera or event. But hereā€™s is where I found the URL though, if that helps. I havenā€™t been able to find any more resources on the topic.

Hi!
I just wanted to create a blueprint to send snapshots for alarms, but I am lazy AF and did a fast search and found your blueprint.
It is almost perfect for me, and maybe I can suggest you some modification to help others using this blueprint.
Do not restrict the activation only for motion, some people have sensors on doors/gates
Allow to add more then one activation entity (this way we donā€™t need more automations if we have different sensors for the same camera).
For blocking entity allow to set up itā€™s blocking state. This way you can use alarm panels state or alarm integrations states.
I am now on to do these changes, just wanted to mention them for you.

1 Like

Please share your revised blueprint with the community, so all can benefit.
Thanks

Hi,
I would like to have this blueprint to activate by a contact sensor, instead of a motion sensor.
Is there an easy way to do so?
Is there a blueprint with this modification?
Thanks.

I think itā€™s as easy as removing the domain class.
Try with the modified blueprint at the URL below.

1 Like

Thank you very much.

this is without blueprint

Hello
Finally I found this :slight_smile:
I have 3 places geocoded in HA. I dont want to receive notification if I am home but I do want to receive notification if I am at the other locations. What should I do? Do I need to remove those? Not really need themā€¦

The standard blueprint does just that.
You use the blocking entity to stop the notifications when you are home.

Blocking entity

As blocking entity you just create a helper template entity (binary template sensor) that has the status ON when you are home and the status OFF when youā€™re not. In the below template example I optionally change the icon as well to graphically show when people are home or not, because I also use this sensor in my dashboards.

With 1 person:

  - platform: template
    sensors:
      stang_home:
        value_template: >-
          {{ is_state('person.stan_g', 'home') }}
        icon_template: >-
          {% if is_state("binary_sensor.stang_home", "on") %}
            mdi:home-account
          {% else %}
            mdi:home
          {% endif %}

With 2 persons, with the OR operator:

  - platform: template
    sensors:
      people_home:
        value_template: >-
          {{ is_state('person.stan_g', 'home') 
          or is_state('person.xxyyy', 'home') }}
        icon_template: >-
          {% if is_state("binary_sensor.people_home", "on") %}
            mdi:home-account
          {% else %}
            mdi:home
          {% endif %}

In my example I have a geocoded location named ā€œHomeā€ and the template sensor looks for this location in the attributes of the person. If you home location is called differently i.e. thuis, house, etc ā€¦ just replace the ā€œhomeā€ in the above template sensor with your named location. Go to settings - ares & zones to look at your configured zones and the name.

The other geocoded locations donā€™t have any impact. You donā€™t need to do anything with them.

1 Like

I have this blueprint working now where it can send notifications to multiple devices (both Android and iOS)

Please note that I am what one would call an ā€œidiotā€, so I mightā€™ve done something dumb here, but it does work.

Go to your file editor and open /blueprints/automation/Stan-Gobien/CriticalCollapseOptionNotHomeMotionCameraSnapshotWithClickAction.yaml

Note the section that says:

    notify_device:
      name: Device to notify
      description: Device that runs the official Home Assistant app to receive notifications.
      selector:
        device:
          integration: mobile_app
          multiple: false

Duplicate this section and rename the ā€œnotify_deviceā€ for each into something unique. I did ā€œnotify_device1ā€ and ā€œnotify_device2ā€ because I am a simple man. See below for what that looks like:

    notify_device1:
      name: Device to notify
      description: Device that runs the official Home Assistant app to receive notifications.
      selector:
        device:
          integration: mobile_app
          multiple: false
    notify_device2:
      name: Device to notify
      description: Device that runs the official Home Assistant app to receive notifications.
      selector:
        device:
          integration: mobile_app
          multiple: false

Now scroll down to the ā€˜variablesā€™ section and find:

  notify_device1: !input notify_device

Duplicate this line and rename it to what you renamed the devices earlier. In my case:

  notify_device1: !input notify_device1
  notify_device1: !input notify_device2

Now scroll down to the ā€˜actionsā€™ section and find:

- delay: '{{ delay }}'
- service: camera.snapshot
  entity_id: !input camera
  data:
    filename: '{{ snapshot_create_file_path }}'
- device_id: !input notify_device
  domain: mobile_app
  type: notify
  title: '{{ notification_title }}'
  message: '{{ notification_message }}'
  data: "{% if is_ios %}\n  {% if is_critical %}\n    {% set platform_data = { \"channel\":
    \"%s\", \"url\": \"%s\", \"attachment\": {\"url\": \"%s\", \"content_type\": \"JPEG\"},
    \ \"push\": { \"category\": \"%s\", \"sound\": { \"name\": \"default\", \"critical\":
    1, \"volume\": 1.0 } } } | format(channel_name, clickAction, snapshot_access_file_path,
    group_name) %}\n  {% else %}\n    {% if overwrite_similar %}\n      {% set platform_data
    = { \"channel\": \"%s\", \"url\": \"%s\", \"apns_headers\": { \"apns-collapse-id\":
    \"%s\" }, \"attachment\": {\"url\": \"%s\", \"content_type\": \"JPEG\"},  \"push\":
    { \"category\": \"%s\", \"sound\": { \"name\": \"default\", \"volume\": 1.0 }
    } } | format(channel_name, clickAction, group_name, snapshot_access_file_path,
    group_name) %}\n    {% else %}\n      {% set platform_data = { \"channel\": \"%s\",
    \"url\": \"%s\", \"attachment\": {\"url\": \"%s\", \"content_type\": \"JPEG\"},
    \ \"push\": { \"category\": \"%s\", \"sound\": { \"name\": \"default\", \"volume\":
    1.0 } } } | format(channel_name, clickAction, snapshot_access_file_path, group_name)
    %}\n    {% endif %}\n  {% endif %}\n{% else %}\n  {% if is_critical %}\n    {%
    if overwrite_similar %}\n      {% set platform_data = { \"tag\": \"%s\", \"channel\":
    \"%s\", \"group\": \"%s\", \"ttl\": 0, \"priority\": \"high\", \"clickAction\":
    \"%s\", \"image\": \"%s\"} | format(group_name, channel_name, group_name, clickAction,
    snapshot_access_file_path) %}\n    {% else %}\n      {% set platform_data = {
    \"channel\": \"%s\", \"ttl\": 0, \"priority\": \"high\", \"clickAction\": \"%s\",
    \"image\": \"%s\"} | format(channel_name, clickAction, snapshot_access_file_path)
    %}\n    {% endif %}\n  {% else %}\n    {% if overwrite_similar %}\n      {% set
    platform_data = { \"tag\": \"%s\", \"channel\": \"%s\", \"group\": \"%s\", \"clickAction\":
    \"%s\", \"image\": \"%s\"} | format(group_name, channel_name, group_name, clickAction,
    snapshot_access_file_path) %}\n    {% else %}\n      {% set platform_data = {
    \"channel\": \"%s\", \"clickAction\": \"%s\", \"image\": \"%s\"} | format(channel_name,
    clickAction, snapshot_access_file_path) %}\n    {% endif %}\n  {% endif %}\n{%
    endif %} {{ platform_data }}\n"

Duplicate this section entirely and rename !input notify_device to what you called your devices earlier.

In my case this section now looks like this:

action:
- delay: '{{ delay }}'
- service: camera.snapshot
  entity_id: !input camera
  data:
    filename: '{{ snapshot_create_file_path }}'
- device_id: !input notify_device1
  domain: mobile_app
  type: notify
  title: '{{ notification_title }}'
  message: '{{ notification_message }}'
  data: "{% if is_ios %}\n  {% if is_critical %}\n    {% set platform_data = { \"channel\":
    \"%s\", \"url\": \"%s\", \"attachment\": {\"url\": \"%s\", \"content_type\": \"JPEG\"},
    \ \"push\": { \"category\": \"%s\", \"sound\": { \"name\": \"default\", \"critical\":
    1, \"volume\": 1.0 } } } | format(channel_name, clickAction, snapshot_access_file_path,
    group_name) %}\n  {% else %}\n    {% if overwrite_similar %}\n      {% set platform_data
    = { \"channel\": \"%s\", \"url\": \"%s\", \"apns_headers\": { \"apns-collapse-id\":
    \"%s\" }, \"attachment\": {\"url\": \"%s\", \"content_type\": \"JPEG\"},  \"push\":
    { \"category\": \"%s\", \"sound\": { \"name\": \"default\", \"volume\": 1.0 }
    } } | format(channel_name, clickAction, group_name, snapshot_access_file_path,
    group_name) %}\n    {% else %}\n      {% set platform_data = { \"channel\": \"%s\",
    \"url\": \"%s\", \"attachment\": {\"url\": \"%s\", \"content_type\": \"JPEG\"},
    \ \"push\": { \"category\": \"%s\", \"sound\": { \"name\": \"default\", \"volume\":
    1.0 } } } | format(channel_name, clickAction, snapshot_access_file_path, group_name)
    %}\n    {% endif %}\n  {% endif %}\n{% else %}\n  {% if is_critical %}\n    {%
    if overwrite_similar %}\n      {% set platform_data = { \"tag\": \"%s\", \"channel\":
    \"%s\", \"group\": \"%s\", \"ttl\": 0, \"priority\": \"high\", \"clickAction\":
    \"%s\", \"image\": \"%s\"} | format(group_name, channel_name, group_name, clickAction,
    snapshot_access_file_path) %}\n    {% else %}\n      {% set platform_data = {
    \"channel\": \"%s\", \"ttl\": 0, \"priority\": \"high\", \"clickAction\": \"%s\",
    \"image\": \"%s\"} | format(channel_name, clickAction, snapshot_access_file_path)
    %}\n    {% endif %}\n  {% else %}\n    {% if overwrite_similar %}\n      {% set
    platform_data = { \"tag\": \"%s\", \"channel\": \"%s\", \"group\": \"%s\", \"clickAction\":
    \"%s\", \"image\": \"%s\"} | format(group_name, channel_name, group_name, clickAction,
    snapshot_access_file_path) %}\n    {% else %}\n      {% set platform_data = {
    \"channel\": \"%s\", \"clickAction\": \"%s\", \"image\": \"%s\"} | format(channel_name,
    clickAction, snapshot_access_file_path) %}\n    {% endif %}\n  {% endif %}\n{%
    endif %} {{ platform_data }}\n"

- delay: '{{ delay }}'
- service: camera.snapshot
  entity_id: !input camera
  data:
    filename: '{{ snapshot_create_file_path }}'
- device_id: !input notify_device2
  domain: mobile_app
  type: notify
  title: '{{ notification_title }}'
  message: '{{ notification_message }}'
  data: "{% if is_ios %}\n  {% if is_critical %}\n    {% set platform_data = { \"channel\":
    \"%s\", \"url\": \"%s\", \"attachment\": {\"url\": \"%s\", \"content_type\": \"JPEG\"},
    \ \"push\": { \"category\": \"%s\", \"sound\": { \"name\": \"default\", \"critical\":
    1, \"volume\": 1.0 } } } | format(channel_name, clickAction, snapshot_access_file_path,
    group_name) %}\n  {% else %}\n    {% if overwrite_similar %}\n      {% set platform_data
    = { \"channel\": \"%s\", \"url\": \"%s\", \"apns_headers\": { \"apns-collapse-id\":
    \"%s\" }, \"attachment\": {\"url\": \"%s\", \"content_type\": \"JPEG\"},  \"push\":
    { \"category\": \"%s\", \"sound\": { \"name\": \"default\", \"volume\": 1.0 }
    } } | format(channel_name, clickAction, group_name, snapshot_access_file_path,
    group_name) %}\n    {% else %}\n      {% set platform_data = { \"channel\": \"%s\",
    \"url\": \"%s\", \"attachment\": {\"url\": \"%s\", \"content_type\": \"JPEG\"},
    \ \"push\": { \"category\": \"%s\", \"sound\": { \"name\": \"default\", \"volume\":
    1.0 } } } | format(channel_name, clickAction, snapshot_access_file_path, group_name)
    %}\n    {% endif %}\n  {% endif %}\n{% else %}\n  {% if is_critical %}\n    {%
    if overwrite_similar %}\n      {% set platform_data = { \"tag\": \"%s\", \"channel\":
    \"%s\", \"group\": \"%s\", \"ttl\": 0, \"priority\": \"high\", \"clickAction\":
    \"%s\", \"image\": \"%s\"} | format(group_name, channel_name, group_name, clickAction,
    snapshot_access_file_path) %}\n    {% else %}\n      {% set platform_data = {
    \"channel\": \"%s\", \"ttl\": 0, \"priority\": \"high\", \"clickAction\": \"%s\",
    \"image\": \"%s\"} | format(channel_name, clickAction, snapshot_access_file_path)
    %}\n    {% endif %}\n  {% else %}\n    {% if overwrite_similar %}\n      {% set
    platform_data = { \"tag\": \"%s\", \"channel\": \"%s\", \"group\": \"%s\", \"clickAction\":
    \"%s\", \"image\": \"%s\"} | format(group_name, channel_name, group_name, clickAction,
    snapshot_access_file_path) %}\n    {% else %}\n      {% set platform_data = {
    \"channel\": \"%s\", \"clickAction\": \"%s\", \"image\": \"%s\"} | format(channel_name,
    clickAction, snapshot_access_file_path) %}\n    {% endif %}\n  {% endif %}\n{%
    endif %} {{ platform_data }}\n"

Restart Home Assistant and now when you use the blueprint, itā€™ll give you two notification devices to select.

Please note

  • You could probably duplicate the line again if you wanted to add another device to notify, but I have not tested that
  • Your existing automations that use the old version of the blueprint will not show up anymore if you make changes to the original blueprint. To update those, go to your automations.yaml file and duplicate and update your ā€œnotify_deviceā€ names to those used in your blueprint.
  • Iā€™m not sure if this causes any issues with the iOS specific toggle under ā€œoverwrite similarā€ in the blueprint. I would imagine it does.
  • Iā€™m not adding the file as itā€™s pretty simple stuff and as mentioned before, Iā€™m an idiot. So please try this at your own risk.
  • I found that you can duplicate the blueprint and rename it for example to ā€œcameranotifies1ā€ and ā€œcameranotifies2ā€ you can keep both.

Hope this helps at all!