Camera - Send & Save snapshot to mobile device when motion is detected with Conditions. Now with Custom Triggers!

This automation blueprint creates a camera snapshot if motion is detected, or if a binary sensor’s state turns ‘off’ to ‘on’, and sends a notification to your device with the picture when certain conditions are met.

Inspired by vorion’s Send camera snapshot notification on motion blueprint but with Conditions and Binary Sensors! Clicking the notification will navigate to dashboard URL.

Binary Sensor Trigger:
Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Custom Triggers:
Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

To Notify Multiple Devices
Highly requested is the ability to notify multiple devices, but that wasn’t really easy to do as the service is setup for a single/specific device. However, I came across something called a Notification Group. Try making a group of devices and using that group as a device to notify!

notify:
  - name: ALL_DEVICES
    platform: group
    services:
      - service: mobile_app_iphone_one
      - service: mobile_app_iphone_two
      - service: mobile_app_ipad_one
      - service: mobile_app_pixel_4_xl

Now, you can send notifications to everyone in the group using:

  automation:
    - alias: "Notify Mobile app group"
      trigger:
        ...
      action:
        - service: notify.ALL_DEVICES
          data:
            message: "Something happened at home!"

Notification Documentation

Changes:
Binary Sensor Trigger:
v1.1 - Conditions no longer required!
v1.2 - Clicking the notification will navigate to dashboard URL (Tested on Android, iOS not confirmed)
v1.3 - Added option to save camera snapshot with conditions
v1.4 - Added option to add additional actions. Useful to send notifications to more devices!
v1.42 - Added time variable and added to default message.
v1.5 - Added option to add an addition action BEFORE everything else. Useful to turn on a light before the snapshot! Added option to set delay before sending another notification.
v1.5.1 - Added option to allow for the notification to device to be optional.

Major Rewrite in V2

v2.0
BREAKING CHANGES - Notification Delay (changed to number selector), implementation also changed. Delay is in seconds and will not block the rest of the automation from running, just the notification.
No longer need to mark device as iOS, it should use the right parameters for each device type.
Ability to set much more notification parameters, like the icon, color, channel, group, sticky, sound and volume! Some settings are exclusive to Android or iOS.
Most importantly, move snapshot image to /media from /www/tmp for better security, no longer exposing snapshot to rest of internet. Double check your File Path parameter

v2.2
FIXED Notification Groups. Unable to use a device selector, so you must enter the created group’s name you used, for example, all_devices, or notify.all_devices. This will overwrite the individual device previously selected.
EXPERIMENTAL: Android TV support. I believe I added the code for TV support but since I have a Google TV, I can’t install Home Assistant on that, so I cannot test this. Please give me feedback. I use Notifications for Android TV which can be installed on an Android Device to relay the notification to the Google TV. Works if only using a single device selected in the blueprint, as long as the app is also on that device!
EXPERIMENTAL: Notification Actions support. Currently added support for a single URI action. I am testing with a door lock/unlock script for more advanced actions.

2.2.2
FIXED: Simplified iOS Critical Notification

2.2.3
ADDED: Collapsible input options

2.2.7
CHANGED: Default of Save Archive Files? to false.
FIXED: Bug that didn’t attach image to notification in the Custom Triggers automation (I JUST noticed this with this particular automation, for those who were using this one with this bug, it may now be fixed).
ADDED: Option to set conditions to run the automation entirely (useful if you just want to capture and save snaps in particular conditions).

2.2.8
ADDED:

  • Delay option between taking snapshot and sending snapshot, titled Send Snapshot Delay.
  • Option to Change Automation Mode, titled Mode Select. Default is Parallel so the automation will run actions guaranteed, but there are some cases when you don’t want that.

2.3
ADDED:

  • Additional triggers to original Binary Sensor blueprint.

Want to Add:
Nothing Yet

Also combined niemyjski’s Save a camera snapshot with archive when motion is detected blueprint with conditions. Useful to save your snapshots and make a picture entity to display the last snapshot taken.
Example:


*Note - If you save snapshot to /media, which is recommended, create a Local File Camera entity in your configuration.yaml file.

camera:
  - platform: local_file
    file_path: /media/front_porch/last_motion.jpg # match your 'File Path' location from the Blueprint
    name: Front Porch Last Motion

Otherwise, if save your snapshot in the /www folder, point to /local to show your snapshot, but this will host the image to the internet with no authentication, so not recommended.

Card:

type: picture-entity
show_state: true
show_name: true
camera_view: auto
entity: binary_sensor.front_porch_sensor_motion
image: /media/front_porch/last_motion.jpg # Optional: match your 'File Path' location from the Blueprint
camera_image: camera.front_porch_last_motion # match your Camera ID when using local file camera entity
name: Front Porch Last Motion
tap_action:
  action: call-service
  service: camera.snapshot
  data:
    entity_id: camera.192_168_86_168_2
    filename: /media/front_porch/last_motion.jpg # match your 'File Path' location from the Blueprint
hold_action:
  action: more-info
state_filter:
  'on': brightness(100%)
  'off': brightness(100%)

The Blueprint:

Binary Sensor Trigger:

Custom Triggers:

15 Likes

Getting this message when trying to import.

Invalid blueprint: Unknown selector type condition found for dictionary value @ data[‘blueprint’][‘input’][‘condition’][‘selector’]. Got {‘condition’: None}

Is there something else needing to be done first?

Did you set a condition?

No, I can’t import the blueprint at all. That error appears when trying to preview the blueprint, so can’t download it at all.
I’ve not seen this before when importing blueprints.

is your Home Assistant updated? Using OS? The Conditional Selector is new

1 Like

Ah, I see what you mean. I’m on 2023.7.3, so I’ll try again after updating.
On on a supervised Debian system, but I hang back a month on releases.

ah gotcha! Yea, the Conditional Selector was JUST added, like 2023.8. Lemme know if it works well for you! 2023.8.2 broke some TP-Link plugs, so I understand why you’d wait a little.

Hi thanks for this. How do you have it set to read when you tap the notification on your phone? On mine at the moment it just loads home-assistant where as I would like to show the snapshot in full size & or load the video to go with it.

I’m not sure. But I can look into that

Thanks I’ve just started creating a dashboard that shows the latest snapshot & recordings so going to link to that.

1 Like

I think I’m using this or the other version I’m not sure.
How would I add a second phone to notify as well it only allows me to select one.

I don’ think it worked when having more than one notification, but try duplicating the automation and selecting the other device to notify.

I’ve imported the blueprint i can see the notification from my phone but when I tap ok it i can’t see the snapshot the System automatically redirect on the main page of home assistant… could you Help me ?

I’d have to create an option for that, but yes, it’s something I want to fix was well. I’ll see what I can do

I added the option to navigate to a certain dashboard when the notification is clicked

I added an additional action option. Read the example in the blueprint to send to an additional device!

I’ve just disabled my old automation and added yours with my wife’s phone now added :+1:t2:
Not sure if it’s worked yet she’s at work.
Cheers mate.

1 Like

buzz her at work! LOL

1 Like

:laughing:
You know what would be good in my case.
My camera views the whole of the front garden so in my snapshot I see the whole garden in the notification.
It would be great if I was able to zoom in on the notification picture to view my doorstep or maybe click on it to open the actual picture :thinking:

I dunno about zooming in, but try creating a dashboard with a single picture entity card and select the lastmotion.jpg. See my blueprint for an example. It may not me exactly what you want, but its close. Also, I use motioneye to host my streams. You can also create a webview of motioeye in HA, and view them that way. ans save still to you r device as well.

1 Like