I am seeking some advice on the following use-case:
I have a sensor on my postbox which signals me that it has been opened. Now I want to trigger an ESP CAM like 5 sec later to make a picture of the inside of my postbox and embed that picture in the push notification, so I know what’s in the postbox.
Has anyone implemented something similar?
Thanks!
I’m sure there are plenty of examples. People often do this sort of thing for their doorbell etc.
The espcam creates a camera entity. Camera entities can capture a snapshot. Camera - Home Assistant
Here’s an example. I find Telegram easy to use for dedicated “channels” and I like having the history of audio/visuals along with some other meta data. This example casts the image to my dedicated HA dashboard (TV), changes the tv to a camera feed, and then sends the image and a video to a “House security” Telegram channel. It’s a bit overkill for me but that’s how I like to do my projects;)
###############################################################################################################
#Front Door
###############################################################################################################
- id: '10322124585'
alias: Front Door Alert
trigger:
- platform: state
entity_id: binary_sensor.door_window_sensor_158d00031b360f
from: 'off'
to: 'on'
action:
- service: input_datetime.set_datetime
entity_id: input_datetime.last_door_open
data:
timestamp: '{{ now().timestamp() }}'
- service: switch.turn_on
data:
entity_id: switch.tv
- delay: 00:00:01
- service: camera.snapshot
data:
entity_id: camera.front_door
filename: /media/Cameras/FrontDoor/FrontDoorOpened_{{states.input_datetime.last_door_open.attributes.timestamp|int|timestamp_custom("%Y-%m-%d %H-%M-%S")}}.jpg
- service: camera.record
target:
entity_id: camera.front_door
data:
filename: /media/Cameras/FrontDoor/FrontDoorOpened_{{states.input_datetime.last_door_open.attributes.timestamp|int|timestamp_custom("%Y-%m-%d %H-%M-%S")}}.mp4
duration: 60
- delay: 00:00:06
- service: notify.chromecast_tv_livingroom
data:
title: 'Smile!'
message: ' '
data:
duration: 10
fontsize: 'large'
position: 'center'
color: 'red'
image:
path: /media/Cameras/FrontDoor/FrontDoorOpened_{{states.input_datetime.last_door_open.attributes.timestamp|int|timestamp_custom("%Y-%m-%d %H-%M-%S")}}.jpg
- service: browser_mod.navigate
data:
path: /lovelace-security/front-door
browser_id:
- XXXXXXXXXXX
- service: telegram_bot.send_photo
data:
file: /media/Cameras/FrontDoor/FrontDoorOpened_{{states.input_datetime.last_door_open.attributes.timestamp|int|timestamp_custom("%Y-%m-%d %H-%M-%S")}}.jpg
caption: '{{states.input_datetime.last_door_open.attributes.timestamp|int|timestamp_custom("%Y-%m-%d %H:%M:%S")}} Door Opened'
timeout: 400
target: '-XXXXXXXXXXX'
- delay: 00:01:30
- service: telegram_bot.send_video
data:
file: /media/Cameras/FrontDoor/FrontDoorOpened_{{states.input_datetime.last_door_open.attributes.timestamp|int|timestamp_custom("%Y-%m-%d %H-%M-%S")}}.mp4
caption: '{{states.input_datetime.last_door_open.attributes.timestamp|int|timestamp_custom("%Y-%m-%d %H:%M:%S")}} Door Opened'
timeout: 400
target: '-XXXXXXXXXXX'
This is old code. Like Nick mentioned, I’m sure there are lots of examples around. Probably some good blueprints.
Thank you for your input. I’ll have a try and in case I run into roadblocks I’ll get back and ask again.