I’m using a blueprint from vorion that takes a camera snapshot upon detecting motion. I want to pause notifications after a motion detection to prevent spamming. If I add an action to wait, HA moves it to the top in yaml so that the pause is the first action, not the last. How do I overcome this?
Here’s the code:
alias: Send a camera snapshot when motion is detected
description: Sends snapshot to Raymond’s iPhone
use_blueprint:
path: vorion/send-camera-snapshot-notification-on-motion.yaml
input:
motion_sensor: binary_sensor.doorbell_motion
camera: camera.doorbell
notify_device: bb90e12a8c255c270fab66930f8e0f2c
is_ios: true
delay: 1
notification_message: "{{ motion_sensor_name }} "
mode: single
Sir_Goodenough
((SG) WhatAreWeFixing.Today)
December 16, 2024, 9:52pm
2
Hello Raymond ,
First could you post the whole blueprint and use the </> notation offered in the text editor here so that the spacing shows up correctly?
A link to it if it is already somewhere is fine as well.
Spacing and intents are everything, and I have no context with that text formatted block above to know what is going on.
alias: Send a camera snapshot when motion is detected
description: Sends snapshot to Raymond's iPhone
use_blueprint:
path: vorion/send-camera-snapshot-notification-on-motion.yaml
input:
motion_sensor: binary_sensor.doorbell_motion
camera: camera.doorbell
notify_device: bb90e12a8c255c270fab66930f8e0f2c
is_ios: true
delay: 0
notification_message: "{{ motion_sensor_name }} "
This is the blueprint:
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
camera:
name: Camera
description: The camera which creates the snapshot
selector:
entity:
domain: camera
notify_device:
name: Device to notify
description: Device needs to run the official Home Assistant app to receive notifications
selector:
device:
integration: mobile_app
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
max: 60
unit_of_measurement: seconds
mode: slider
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 = {"attachment": {"url": "%s", "content_type": "JPEG"}} | format(snapshot_access_file_path) %}
{{ ios_data if is_ios else android_data }}
Thanks for responding. I hope this is what you asked for.
Sir_Goodenough
((SG) WhatAreWeFixing.Today)
December 16, 2024, 10:26pm
4
Thanks for the code.
Well the first thing all automations do is trigger. This one triggers on the motion. The next thing it does is delay.
Your calling automation for the blueprint sets the delay to 0, so it will not pause.
Setting a time for this might do what you want?
rayellio77:
delay: 0
Perhaps you can help me what exactly do you want to happen if that is not it?
I want there to be a 2-minute pause/delay/wait after a notification before another notification fires.
Thanks again.
Sir_Goodenough
((SG) WhatAreWeFixing.Today)
December 16, 2024, 11:07pm
6
What happens when you put 120 (seconds) into the delay field in the blueprint automation screen?
there is a 120-second delay before any notification.
Sir_Goodenough
((SG) WhatAreWeFixing.Today)
December 17, 2024, 1:21am
8
And the next notification can be no sooner than 120 seconds after that.
Look if you want to edit the blueprint to notify then wait, change to:
action:
- 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 = {"attachment": {"url": "%s", "content_type": "JPEG"}} | format(snapshot_access_file_path) %}
{{ ios_data if is_ios else android_data }}
- delay: "{{ delay }}"
Sorry for being such a noob, but I don’t know what to do with this.