Hello @Domy5,
its a pleasure that someone is interested in
-1st question: i have create a folder named “shell_scripts” under config : like that : /config/shell_scripts/cuisine_camera_shell_script.sh
and lol i understand because i create a .log file to see if it works, so this is the content of the “cuisine_camera_shell_script.sh” for example
#!/bin/bash
exec &>>/config/shell_scripts/cuisine_cam.log
date
echo "token is: $1"
cam_token=$1
folder=/config/www/cam_record
id=$(date +"%y-%m-%d_%H-%M-%S")cuisine_camera
http_url=https://192.168.xxx.xxx:8123/api/camera_proxy_stream/camera.cuisine?token=$1
mkdir $folder
ffmpeg -i $http_url -t 10 -vcodec copy $folder/$id.mp4
ls -lh $folder/$id.mp4 $folder/cuisine_camera.mp4
cp $folder/$id.mp4 $folder/cuisine_camera.mp4 ;
So you can see after triggered manualy your automation, the log will be create and inside its normally looks like mine in my previous message.
-2nd shell_command: does it have to be hosted in configuration.yaml? : you can but i create a file “shell_command.yaml” to put all my shell commands…like :
cuisine_cam_shell: '/config/shell_scripts/cuisine_cam.sh {{ state_attr("camera.cuisine","access_token") }}'
if you do, dont forget to put in configuration.yaml : “shell_command: !include shell_command.yaml”
You can do whithout and just put in configuration.yaml :
shell_command:
cuisine_camera_shell_script: "bash /config/shell_scripts/cuisine_camera_shell_script.sh {{cam_token}}"
-3rd is necessary : no, i havent that in my config…
Last thing : its the automation : you have to triggered with something, like a motion sensor. I have one attached on the camera (you can see here my thingverse : [https://www.thingiverse.com/thing:3816458] (https://www.thingiverse.com/thing:3816458) ).
My automation is :
- id: 'xxxxxxxxxxxxxxxx'
alias: Record cam detecteur cuisine
trigger:
- entity_id: binary_sensor.cuisine_pir_sensor
for: 00:00:02
from: 'off'
platform: state
to: 'on'
condition:
- condition: state
entity_id: binary_sensor.somebody_home
state: 'off'
action:
- data:
entity_id: camera.cuisine
filename: /config/www/cam_captures/cuisine_{{ now ().year }}_{{ now ().month
}}_{{ now ().day }}_{{ now ().hour }}_{{ now ().minute }}.jpg
service: camera.snapshot
- delay: 00:00:01
- data_template:
data:
force_image: true
image: https://XXXXXX.duckdns.org/local/cam_captures/cuisine_{{ now ().year
}}_{{ now ().month }}_{{ now ().day }}_{{ now ().hour }}_{{ now ().minute
}}.jpg
message: Détection de mouvement cuisine
title: Alerte cuisine
service: notify.mobile_app_galaxy_note10
- data_template:
data:
images:
- /config/www/cam_captures/cuisine_{{ now ().year }}_{{ now ().month }}_{{
now ().day }}_{{ now ().hour }}_{{ now ().minute }}.jpg
message: Capteur de mouvements Cuisine déclenché
title: '!!! Hassio Detection Cuisine !!!'
service: notify.email_notify
- service: shell_command.cuisine_cam_shell
Now you have all what you need
Enjoy! give me some feedback if its ok for you please