Here’s a couple I’m using now. Could use some cleanup and optimizing but they work. They’re pretty general, the logic really isn’t tied specifically to the doorbell camera, can really work for ANY PIR sensor, just so happens that this is on the EZviz doorbell.
IOS Send Live view notification on PIR motion detection. Live video only works when I’m on my home network, so it doesn’t trigger if I’m not home.
automation:
- alias: Notify - Porch Motion
initial_state: on
trigger:
- platform: state
to: 'on'
entity_id:
- binary_sensor.doorbell_pir_motion
condition:
- condition: state
entity_id: binary_sensor.home_occupied
state: "on"
action:
- service: notify.ALL_IOS
data:
message: Front Porch Live
title: Motion Detected
data:
attachment:
content-type: jpeg
push:
category: camera
sound: "HummingbirdNotification_Haptic.caf"
entity_id: camera.doorbell
- service: automation.turn_off
entity_id: automation.notify_porch_motion
- delay: "00:01:00"
- service: automation.turn_on
entity_id: automation.notify_porch_motion
This one is for when I’m away from home, I take a snapshot and upload it to my backblaze b2 bucket, then since this link IS externally accessible I can view it from my phone anywhere.
The filename is somewhat randomized in order to prevent any brute force guesses viewing these snapshots.
- alias: Porch Motion Detect - Take Snapshot
initial_state: on
trigger:
- platform: state
to: 'on'
entity_id:
- binary_sensor.doorbell_pir_motion
- platform: state
entity_id:
- binary_sensor.front_door
to: 'on'
variables:
filename: "doorbell-{{ states.sensor.snmp_cable_out.state }}-{{ now().strftime('%s') }}.jpg"
action:
- service: camera.snapshot
data:
entity_id: camera.doorbell
filename: '/tmp/{{ filename }}'
- service: shell_command.b2_upload
data_template:
filename: '{{ filename }}'
- service: mqtt.publish
data:
topic: MQTTTOPIC/frontdoor/camera/last_capture
payload_template: "{{ filename }}"
retain: true
- alias: Porch Motion Detect - Notify
initial_state: on
trigger:
- platform: state
entity_id:
- sensor.lastcapture_front_door
condition:
- condition: state
entity_id: binary_sensor.front_door
state: "off"
action:
- service: notify.ALL_IOS
data:
message: Front Porch Snapshot
title: Motion Detected - Snapshot
data:
attachment:
url: "https://BACKBLAZEB2-PUBLIC-URL/file/BUCKET/{{ states('sensor.lastcapture_front_door') }}"
hide-thumbnail: false
content-type: jpeg
shell_command:
b2_upload: b2 upload-file BUCKET /tmp/{{ filename }} {{ filename }}