TimeLapse

Forum dédié aux problématiques concernant les scripts pour DomoticZ.
Entourez votre code et les logs avec les balises nommées code grâce au bouton <\>.
QcVictor
Messages : 79
Inscription : 17 janv. 2015, 14:52

TimeLapse

Message par QcVictor »

J'ai un script bash (adapté a mes besoin d’après ceux tuto http://www.magdiblog.fr/boa-pi-timelaps ... t-scripts/) pour généré une prise de photo de ma webcam.
#!/bin/bash

date >> /home/pi/uptime.log
output_dir=/home/pi/timelapse
heartbeat_dir=/home/pi/heartbeat
flag=/home/pi/timelapse.flag
now=`date "+%F_%H-%M-%S"`
streamer -f ppm -s 1920x1080 -t 10 -r 3 -o $output_dir"/timelapse_"$now"_00.ppm"
rm $output_dir/*_00.ppm
rm $output_dir/*_01.ppm
rm $output_dir/*_02.ppm
rm $output_dir/*_03.ppm
rm $output_dir/*_04.ppm
rm $output_dir/*_05.ppm
rm $output_dir/*_06.ppm
rm $output_dir/*_07.ppm
rm $output_dir/*_09.ppm
rm $output_dir/*_10.ppm
if [ ! -f $flag ] ; then
echo "0" > $flag
fi
nb_flag=`cat $flag`
new_nb_flag=$(($nb_flag+1))
echo "$new_nb_flag" > $flag
if [ "$new_nb_flag" == "1" ] ; then

echo " flag $new_nb_flag should send heartbeat now ... "

##wvdial free&

img_origin=$output_dir"/timelapse_"$now"_08.ppm"
img_heartbeat=$heartbeat_dir"/timelapse_"$now"_08.jpg"
convert -compress jpeg -resize 25% $img_origin $img_heartbeat
##curl --progress-bar --form img=@$img_heartbeat --form token=beat_B3O7A8S4 http://pi_timelapse/heartbeat_X8E7Q2L7.php
##echo "heartbeat send ..."
else
echo " flag $new_nb_flag no heartbeat ... "
if [ "$new_nb_flag" -gt "2" ] ; then
echo "reset flag"
echo "0" > $flag
fi
fi
##if [ -f /root/shutdown.flag ] ; then
##echo "shutdown flag detected ... shuting down !"
##shutdown -h now
##fi
J'ai crée une switch virtuel de type push button on avec les chemin de mon script bash dans les champs actions on et off et crée un script Dzvents
return {
active = true,
on = {
['timer'] = 'every 20 minutes'
},

execute = function(domoticz)
--domoticz.devices[5].switchOn()
local TimeLapse = domoticz.devices['TimeLapse']
TimeLapse.toggleSwitch()

end
}
Le script se lance bien au 20 minutes tel que voulu, mais j'ai une erreur lorsque
2017-02-26 09:20:00.628 LUA: =====================================================
2017-02-26 09:20:00.629 LUA: >>> Handler: script_time_timelapse
2017-02-26 09:20:00.629 LUA: .....................................................
2017-02-26 09:20:00.629 LUA: .....................................................
2017-02-26 09:20:00.629 LUA: <<< Done
2017-02-26 09:20:00.630 LUA: -----------------------------------------------------
2017-02-26 09:20:00.630 LUA: [1] = TimeLapse: On
2017-02-26 09:20:00.631 LUA: =====================================================
2017-02-26 09:20:00.634 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_time_main.lua
2017-02-26 09:20:00.673 (Dummy) Light/Switch (TimeLapse)
2017-02-26 09:20:01.835 Executing script: /home/pi/domoticz/scripts/timelapse.sh
2017-02-26 09:20:03.332 Error: Error executing script command (/home/pi/domoticz/scripts/timelapse.sh). returned: 256
QcVictor
Messages : 79
Inscription : 17 janv. 2015, 14:52

Re: TimeLapse

Message par QcVictor »

Finalement un dodo plus tard + un reboot et ça fonctionne,
Autre petit soucis, les photos généré, le propriétaire est root et 640, peu pas les récupéré sur mon partage "acces denied". un coup de sudo chmod 755 -R sur le dossier fonctionne, mais chaque nouvelle photo reste avec les même droit en 640, comment faire pour changer ces droits en permanence ?
Chrominator
Messages : 1042
Inscription : 19 déc. 2015, 07:29
Localisation : France

Re: TimeLapse

Message par Chrominator »

J'arrive tard, j'ai vu :)

As-tu essayé de mettre au début de ton script

Code : Tout sélectionner

umask 111
Un bon frein vaut mieux que deux sparadraps.

Ubuntu 24.04.3 LTS - Domoticz 2025.1 (build 16782)
Pentium G3220T 2.6GHz - 4Go DDR3
RFXtrx433 USB Ver Pro1/1043
Z-Stick GEN5 Version: 1.6-1136-g07ea22bb
Rtl433 RTL-SDR receiver
RFLink Gateway
Zigbee SLZB-06
Répondre