This blueprint ia awsome!
However, has anyone manage to use a condition in any way?
Iād like to use the automation only in case Iām not home!
Thank you so much!
Send camera snapshot and camera record to telegram using configured telegram bot:
Blueprint
blueprint:
name: Send a camera snapshot to telegram when motion is detected
description: 'This automation blueprint creates a camera snapshot if motion is detected and
sends a notification via preconfigured Telegram bot 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
notification_title:
name: Notification title (Optional)
description: 'Default: "{{ motion_sensor_name }} detected movement!"'
default: '{{ motion_sensor_name }} detected movement!'
source_url: https://community.home-assistant.io/t/send-camera-snapshot-notification-on-motion/254565
trigger:
platform: state
entity_id: !input motion_sensor
to: 'on'
variables:
motion_sensor: !input motion_sensor
motion_sensor_name: '{{ states[motion_sensor].name }}'
camera: !input camera
notification_title: !input notification_title
snapshot_file_name: >-
{{ now().strftime("%Y%m%d-%H%M%S") }}
snapshot_create_file_path: >-
/media/snapshots/{{ states[camera].object_id }}_{{ snapshot_file_name }}.jpg
record_create_file_path: >-
/media/records/{{ states[camera].object_id }}_{{ snapshot_file_name }}.mp4
action:
- service: camera.snapshot
target:
entity_id: !input camera
data:
filename: '{{ snapshot_create_file_path }}'
- service: telegram_bot.send_photo
data:
parse_mode: html
file: '{{ snapshot_create_file_path }}'
caption: '{{ notification_title }}'
- repeat:
while:
- condition: state
entity_id: !input camera
state: unavailable
for:
hours: 0
minutes: 0
seconds: 10
sequence:
- delay: '00:00:01'
- service: camera.record
target:
entity_id: !input camera
data:
duration: 15
filename: '{{ record_create_file_path }}'
- service: telegram_bot.send_video
data:
parse_mode: html
file: '{{ record_create_file_path }}'
caption: '{{ notification_title }}'
Thanks for the blueprint!
Iām new to blueprints in general and would like to know if thereās a way to edit it so that i can comment out the vehicle sensor requirement?
Also, could someone suggest an automation to remove the saved images on a regular basis?
thanks!
evening, this doesnāt work for me. when i push on the alert, Google asks if i want to silent the notifications permanently. it never opens up the snapshot.
maybe iām doing something else wrongā¦?
Hey @0la1, @usaf_pride, chillhahn,
Not sure if you all figured this out, but I have managed to find a workaround for sending the notification to multiple devices.
You first need to create the notify:
group with your devices, then edit the blueprint at
/config/blueprints/automation/vorion/send-camera-snapshot-notification-on-motion.yaml
comment out the notify_device input section
# notify_device:
# name: Device to notify
# description: Device needs to run the official Home Assistant app to receive
# notifications
# selector:
# action:
# device:
# integration: mobile_app
then comment out the notify_device variables section
# notify_device: !input 'notify_device'
and then lastly in the action section at the bottom of the blueprint file, edit as below:
# - device_id: !input 'notify_device'
# domain: mobile_app
# type: notify
# title: '{{ notification_title }}'
# message: '{{ notification_message }}'
- service: notify.all_phones
data:
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 }}'
note I have called my notify group āall_phonesā. So change that to suit your naming. If you are feeling confident you could go back and delete all the commented out lines to clean the blueprint up.
Iām sure there must be another way to do this but Iāve not been able to figure it out
Donāt know if Iām the only one that noticed, thereās a pretty big concern of privacy in using this blueprint as is.
It stores the screenshot in the www folder, thatās accessible (by design) and not covered by HA authentication. For me itās a pretty big deal as I live in a flat and have my security cameras inside the house, so anyone that has my HA link to that file can access it and privacy is gone.
I guess one step in the right direction is to create a random string of text as a folder to put the files in, so itās harder to brute force the link.
First requirement is to have access to your network, I hope itās not accessible by everyone in your flat, not your cameraās, not your HA.
The same goes for receiving these snapshots: anyone that receives them has access to your network anyway.
Thank you for such a great blueprint!..it save me a lot of work!..
ā¦now I facing āhow to access the pictures from outside you networkā¦ā, I know, I know, it was already discuss on the thread, but I read all those old comments and I donāt have a clear idea of what to check or what need to be done differently with the current state of the bleuprintā¦so sorry if is repeated, just point me in the right directionā¦
So, notifications are working and I can get the pictures as part of the message in all devices in my networkā¦from outside I only get the notification without the snapshot attachedā¦
Reading the thread I try to add:
homeassistant:
allowlist_external_dirs: /config/www/tmp #also try with /config/www
I change the integration code to save snapshots inside www instead www/tmp ā¦and I check the picture was actually thereā¦reboot everything several times, but still no pictures from outside my networkā¦
What Iām missing?..I know there are concerns about security but I want to make it work first and fix that later, so any suggestion will be wellcomeā¦
can be realted to how I access HA remotely?, I use cloudflare so my url is something like https://mycloudflareurl.tk/lovelace/default_view , so as a test, should the image be accesible doing something like:
wget https://mycloudflareurl.tk/snapshot_camerasomething.jpg
? ( assuming picture is stored in www folder) ā¦if so, the is not accesible like that and no idea how to enable something like that with cloudflareā¦
What Iām missing or missreading?
Thanks!
Home Assistant 2023.8.1
Supervisor 2023.08.1
Frontend 20230802.0 - latest
ā¦btw, I note that when I click in the saved snapshot inside www/tmp I get a long weird url for the image
http://localip:8123/api/hassio_ingress/tIYmL62o23vA6NLEFBuDRrPpW_IV5IoAvRU28wi1Quw/api/file?filename=/config/www/tmp/snapshot_backyard_2.jpg
Iām talking about outside-access. Iām using a cloudflare tunnel so nothing of my network is exposed directly, so no, itās not accessible by anyone if not the people with passwords, and yes, the www folder via the correct link is visible from outside, so yes, itās a privacy problem especially for security camera snapshots (i donāt mind having for example a wifi qr code for the guest wifi, which is obviously separated from the main one)
First of all, thank you for such a great blueprint.
I have a very strange behaviour. At first glance it was kind of working fine but afterwards I realize that itās serving me always the first snapshot. When I check under www/tmp, I saw the snapshot and is being updated each time I run the automatization but the picture I see at https://my.home.assistant/local/tmp/snapshot.jpg is the very first one that was taken. I have even removed the file from tmp folder, tried in private tab of different internet browsers, etcā¦ No matter what I do, I keep seeing the very first snapshot. Some kind of strange cache issue? Anyone has faced this?
I have found the solution on the issue in my previous post.
The problem was cloudflare caching. Enabling āDevelopment Modeā helpedā¦
Cloudflareās developer mode is only active for 4 hours. After that you have the same problem again. Is there another solution for this?
Edit:
I have now solved it like this:
I add date, hour and minute to the filename:
- service: camera.snapshot
data:
filename: /config/www/tmp/Terrasse_{{ now().strftime(ā%Y%m%d-%H%Mā) }}.jpg
target:
entity_id: camera.terrasse
And specify the same in the notification:
- service: notify.mobile_app_
data:
data:
image: >-
https://XXXX/local/tmp/Terrasse_{{ now().strftime(ā%Y%m%d-%H%Mā)
}}.jpg
entity_id: camera.terrasse
so that a new file is created each time and the current one is sent.
Iām having this exact problem on my Android. Did you ever figure it out? I see an old picture in that www folder and thatās the one I keep receiving on the phoneā¦
Hello, how could I set it to capture using the cameraās own motion sensor?
two problems here
image is late in agent dvr if you see the notification i can see the person but in ha image the person has already gone out of the view.
android phones all Samsung note series receiving notification late. yeah battery optimization for HA is off
cant i send from webhook image and then this module can process it
so far i send from actions in agent dvr to ha and in automation ha gets grab0.jpg i think but i am not able to go further what to do with it
hi, is it possible to have the formatted code or better yet a blueprint of this solution. sorry but i am at the beginning
hi, is it possible to have the formatted code or better yet a blueprint of this solution. sorry but i am at the beginning
This is quite cool, however did not come out very useful for me. The phone sends a partial screenshot in the push where I canāt see all of the picture, and when I click it Home Assistant opens, Screenshot is gone, canāt find it anywhereā¦
I just used the blueprint and when I trace the automation it does not run, but give the following error.
Executed: November 7, 2023 at 5:30:25 PM
Error: offset should be format āHH:MMā, āHH:MM:SSā or āHH:MM:SS.Fā