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