Hi, thank you for the code. It helped me to finally show my FTP based CCTV DVR snapshots on my UI. One question, each camera snapshot is saved with a different first part ie “ch01_XXX.jpg”, “ch02_XXX.jpg” etc. How do I get this automation to use a condition based on the first 4 characters to run? I want to run a different automation based on the file names…
alias: Kguard FTP File Path Update
trigger:
event_data:
event_type: created
event_type: folder_watcher
platform: event
condition: []
action:
Help is much appreciated. Also, something I came across. For the folder_watcher component, using a patterns “ch0*.jpg” does not work, but “ch0.jpg” does work: (with the extra “*”
Hi, I’ve read all the topic and I’ve tested some of the suggestion that I’ve read and this automation is that it’s working in my HA:
- id: fotogaraje
alias: Pta garaje abierta tiempo
trigger:
- entity_id: cover.sonoffgarage
for: 0:05:00
platform: state
to: open
condition: []
action:
- data:
entity_id: camera.garaje
filename: /config/www/cam_captures/garaje_{{ now ().year }}_{{ now ().month
}}_{{ now ().day }}_{{ now ().hour }}_{{ now ().minute }}.jpg
service: camera.snapshot
- delay: 00:00:05
- alias: ''
data:
message: Puerta garaje abierta mucho tiempo con foto
service: telegram_bot.send_message
- data:
file: /config/www/cam_captures/garaje_{{ now ().year }}_{{ now ().month }}_{{
now ().day }}_{{ now ().hour }}_{{ now ().minute }}.jpg
service: telegram_bot.send_photo
Do I need to open ports on my router or something else?
Also when I remove the time/date stamp I still don’t get the image. It can be viewed on the browser though.
Thank you so much for your scripts. It took me a very look time to get these to work, but I’m pleased to say with your samples I have managed to do so. Thank you.
I should point out, I am new to Hass.io and I relay a LOT on other people’s input. Finally to get this working I had to keep looking for the errors inside the log file, eventually after many hours of Googling and trying to understand what the errors meant I got it to work. It’s not easy. Far from it.
Thanks so much.
This post helped me a lot with a android IP webcam. But I run it directly the longest time - Hoped it the bash file takes care of the timeout wich I had to use first.
maybe with a wait template… but I dont know.
I also had problems with files with files more then 2mb
So i used
-t 4 -b:v 2048k -vcodec libx264 -fs 2048k
Edit:
Said and done - I changed your Script therefore a little more
Sure
You see the 'mosquitto_pub ’ in the shell script?
This publishes a message and the sensor reacts to it. Therefore the wait template gets satisfied
I know I must be close, but I can’t seem to get this to work.
here is my script
presence_backyard_notifications_when_detected:
alias: Occupancy Detection - backyard - Notifications
sequence:
- data:
entity_id: camera.backyard
filename: /config/www/cam_captures/backyard_{{ now ().hour }}_{{ now ().minute }}.jpg
service: camera.snapshot
- delay: 00:00:05
- service: notify.all_hands
data:
message: Motion detected in the backyard at {{ states('sensor.time') }}
title: Presence Detected at backyard
data:
attachment:
content-type: jpg
hide-thumbnail: false
url: 'https://mydomain/local/cam_captures/backyard_{{ now ().hour }}_{{ now ().minute }}.jpg'
image: 'https://mydomain/local/cam_captures/backyard_{{ now ().hour }}_{{ now ().minute }}.jpg'
It works perfect if I just use a save the snapshot without the variables for date and time (backyard.jpg), but onces I include those, I get no picture attached. I know the URL is good though, just to be sure I added it to the message. When the message sent I could copy the link from the notification and paste it into a browser and see it fine. What am I doing wrong with adding the date and time on it? I have tried single quotes, double quotes, no quotes…
P.S. I have the attachment and the image elements in the data element because I’m sending to two different services in the notify.all_hands btw. That’s why you see that listed twice. again it works if its just “https://mydomain/local/cam_captures/backyard.jpg” and honestly I’d leave it like that except that the snapshot function doesn’t seem to overwrite the file if one exists. This would save me the trouble of cleaning out the folder periodically.
That’s still a no go. The snapshot is saved, the URL is valid even from outside the house, but the image is not added to the notification. The URL in the message is even clickable and takes you to the image, I don’t get it. Is there a way to just over write the previous file so I don’t need to worry about the time stamp at all?
Any time you are using a template you need to use “x_template:” (data_template, service_template, etc). Be informed tho that not everything can be templated so you need to make sure you follow the docs to see which things can be.