Hello,
i try to record a stream from a camera in hassio, i have follow a post : https://community.home-assistant.io/t/ip-camera-snapshot-automation/41319/14
this post is for snapshot pictures, and i try to adapt the shell_command from another post : https://community.home-assistant.io/t/not-working-to-do-snapshot-or-recording-using-esp32-cam/125360
because the token change often i read to replace the token by :
{{ state_attr('camera.esp32_camera','access_token') }}
here is my shell file :
#!/bin/bash
date
folder=/config/www/cam_record
id=$(date +"%y-%m-%d_%H-%M-%S")cuisine_camera
http_url=https://192.168.1.50:8123/api/camera_proxy_stream/camera.cuisine?token={{ State_attr('camera.cuisine','access_token') }}
mkdir $folder
ffmpeg -i $http_url -t 1 -vcodec copy $folder/$id.mp4
ls -lh $folder/$id.mp4 $folder/cuisine_camera.mp4
cp $folder/$id.mp4 $folder/cuisine_camera.mp4
ls -lh $folder/$id.mp4 $folder/cuisine_camera.mp4
find $folder -type f -name ‘*.mp4’ -mtime +30 -exec rm {} ;
i get these errors in the shell log file:
+ $'date\r'
/config/shell_scripts/cuisine_camera_shell_script.sh: line 2: $'date\r': command not found
+ $'\r'
/config/shell_scripts/cuisine_camera_shell_script.sh: line 3: $'\r': command not found
+ folder=$'/config/www/cam_record\r'
++ date +%y-%m-%d_%H-%M-%S
+ id=$'19-12-07_18-24-07cuisine_camera\r'
/config/shell_scripts/cuisine_camera_shell_script.sh: line 6: syntax error near unexpected token `('
/config/shell_scripts/cuisine_camera_shell_script.sh: line 6: `http_url=https://192.168.1.50:8123/api/camera_proxy_stream/camera.cuisine?token={{ state_attr('camera.cuisine','access_token') }}
sorry i try to use notepad++ and find where is the errors…but i am not familiar to shell command and shell files…
If someone could help please?
Thanks