📸 Send camera snapshot notification on motion

You should format the config as code to make this useful to anybody else.

What is the relation of this to the topic of this thread (besides simply having an automation and camera in common), since this doesn’t seem to utilise the blueprint?

This blueprint works great! Only catch for me is that the images are ephermeral - if you tap the notification it just goes to home assistant and the image is sorta … gone.

Is there a way to take the same image, and create a card from it, to drop into another dashboard that could be a card with the “last image produced from the motion trigger being set off”?

1 Like

Push the notification, and keep it pushed until it opens.
Just a tap will open HA…

1 Like

Is this only working with active Ring subscription? Because the snashots are very old?

I wouldn’t know, I don’t use ring…

I figured it out.
i made a camera device out of the same image path, then made a card for the “camera”.

config.yaml:

camera:
   - platform: local_file
     name: foyer_snap
     file_path: /config/www/tmp/snapshot_m3116_lve_1.jpg

card jinja:

 camera_view: live
 type: picture-glance
 entities: []
   camera_image: camera.foyer_snap
1 Like

Need help pls! I have some problems with this blueprint.
I have installed home assistant on proxmox VM.
I can reach HA from the web.
The automations only worked the first time, I had the notification on phone with the attached snapshot.
After that the automations generate an image file of zero byte in the folder /www/temp/ and no image attached to the notification on mobile app
My cam is a Tapo C200

This is the blueprint config

blueprint:
  name: Send a camera snapshot when motion is detected
  description: 'This automation blueprint creates a camera snapshot if motion is detected  and
    sends a notification to your phone with the picture.

    '
  domain: automation
  input:
    motion_sensor:
      name: Motion sensor
      description: The sensor wich triggers the snapshot creation
      selector:
        entity:
          domain: binary_sensor
          device_class: motion
          multiple: false
    camera:
      name: Camera
      description: The camera which creates the snapshot
      selector:
        entity:
          domain: camera
          multiple: false
    notify_device:
      name: Device to notify
      description: Device needs to run the official Home Assistant app to receive
        notifications
      selector:
        device:
          integration: mobile_app
          multiple: false
    is_ios:
      name: Is it an iOS device?
      description: Toggle if your selected device runs iOS, default is Android
      selector:
        boolean: {}
      default: false
    notification_title:
      name: Notification title (Optional)
      description: 'Default: "Motion detected!"'
      default: Motion detected!
    notification_message:
      name: Notification message (Optional)
      description: 'Default: "{{ motion_sensor_name }} detected movement!"'
      default: '{{ motion_sensor_name }} detected movement!'
    delay:
      name: Delay (Optional)
      description: Wait before creating camera snapshot
      default: ''
      selector:
        number:
          min: 0.0
          max: 60.0
          unit_of_measurement: seconds
          mode: slider
          step: 1.0
  source_url: https://community.home-assistant.io/t/send-camera-snapshot-notification-on-motion/254565
trigger:
  platform: state
  entity_id: !input motion_sensor
  from: 'off'
  to: 'on'
variables:
  motion_sensor: !input motion_sensor
  motion_sensor_name: '{{ states[motion_sensor].name }}'
  camera: !input camera
  notify_device: !input notify_device
  is_ios: !input is_ios
  notification_title: !input notification_title
  notification_message: !input notification_message
  delay: !input delay
  snapshot_create_file_path: /config/www/tmp/snapshot_{{ states[camera].object_id
    }}.jpg
  snapshot_access_file_path: '{{ snapshot_create_file_path | replace(''/config/www'',''/local'')
    }}'
action:
- 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: '{% set android_data = {"image": "%s"} | format(snapshot_access_file_path)
  %} {% set ios_data = {"push": {"sound": {"critical": "1", "name": "default", "volume": "0.1"}}, "attachment": {"url": "%s", "content_type": "JPEG"}} | format(snapshot_access_file_path)
  %} {{ ios_data if is_ios else android_data }}'

This is my automation

- id: '1661436517428'
  alias: Send snapshot cam letto_sx movement detection
  description: ''
  use_blueprint:
    path: vorion/send-camera-snapshot-notification-on-motion.yaml
    input:
      motion_sensor: binary_sensor.letto_sx_motion
      camera: camera.cam_letto_sx_sd
      notify_device: bd3c0fb3b17128dd85de362ce9a61cbc
      delay: 1

You probably need to correct this line:

apparently it is save elsewhere

@aceindy
If I remove the snapshot file from the configured folder and manually launch the automation the file is created correctly in the folder but with 0 byte…

If I correct the path in the code from

snapshot_access_file_path: '{{ snapshot_create_file_path | replace(''/config/www'',''/local'')
    }}'

to

snapshot_access_file_path: '{{ snapshot_create_file_path | replace(''/config/www/tmp'',''/local'')
    }}'

the files are created with some size, but not attached to the notification on mobile app
and if I try to open the images they are unredable with gimp or similar…

EDIT: after edited the path only first time I run the automation the file have a size, second time I run the automation the files have 0 byte…again…

Hmm…sounds like there is an issue with

service camera.snapshot

What happens when you call it from developer tools?

@aceindy

2022-08-30 21:11:19.329 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140054179184704] Error handling message: Service service camera.snapshot does not match format <domain>.<name> for dictionary value @ data['sequence'][0]['service']. Got 'service camera.snapshot' (invalid_format)

Help please…

Nice blueprint. Like it really much.

I have one issue with it though. I updates the message that is pushed to iOS with the critical params. However, I notice the message does not come through as critical. All my other automations, with critical message, come through as critical.

Anyone else here experiencing the same?

Hi, im not getting any notification at all. Any ideas why? Thanks for a great blueprint.

Has anyone gotten the group notification to work? I have the group setup correctly in configuration.yaml, but I can’t figure out how to call the group from the template.

This blueprint is super!
I would like to point out a few additions/tweaks which which i found to be useful:

  1. Conditions - This automation is particularly useful when no one is at home, a condition for “being away” would be awesome, and would prevent a lot of useless notifications
  2. Multiple devices - The snapshot should be sent to me and my girlfriend (and perhaps other family members).
  3. Motion, Sound or Person detection - Right now it triggers on motion, which is great. But it takes a lot op pictures of my cat (who is indeed very cute) but person detection would be useful for this
  4. Media deletion - Right now the screenshots are saved indefinitely, which eventually bloats the storage. a deletion timeframe (for instance 180 days) would prevent this automation from overloading a system storage.

Hope this helps!

6 Likes

were you able to implement any of these tweaks and could you give some sample YAML of how you did it?

1 Like

Dear @vorion,
Thank you so much for this blueprint. It almost works for my case.
I am using Hikvision camera and with this automation, it could send picture when someone passes line defined (cross line alarm).
But the picture in the notification is always from the previous motion snapshot. I guess it is because the snapshot is not saved ready for the current motion, and the notification uses the available picture in /tmp/ dir.
is it possible to add a 1s delay to send the notification?
Or do you have any other solution?
Thank you so much in advance.

Lovely blueprint, my only two concerns are why there is no option to send to 2 devices the notifications? (for instance me and my girlfriend).
2nd concern is that I want to share it to my telegram and not to my phone device, it’s not possible at the moment to select the telegram entity that I have (notify.telegram_group)

Hi everyone, I have this BP now running for a while and it is great. I have now set up a notification group which works fine. However, I am not able to select the group in the Blueprint. Basically the same issue as @usaf_pride and @chillhahn.

To answer @parautenbach questions:

Notify group:

notify:
  - name: Familie
    platform: group
    services:
    - service: mobile_app_XXX_iphone
    - service: mobile_app_XX_iphone

The BP dropdown simply doesn’t show it.

Hi
I hope that anyone can help with this automation.
I used the blueprint with my nest doorbell.
The automation works nice when l activated manually ( from The file in blueprint ) . It send a snapshot
But when the doorbell is being pressed , nothing is happening. I get nothing!!!.

I have Nest doorbell. I don’t have a sensor as it written in the blue print. I put my camera name in this felt.
I don’t know if this is the reason for this problem ? But can’t find another sensor to put in this felt ( in the blue print)
I hope that anyone with nest doorbell can help. Thank you in advance ::slightly_smiling_face:

This is a screen shot of the blueprint in my automation