[SOLVED]  Thanks to everyone who replied.  Because I'm not a python guru, 
but I have a lot of *old* Unix experience from 10+ years ago, I opted to do 
it all in a bash script that I invoke 1 minute before the 5-minute weewx 
interval at 00, 05, 10, etc.  This does what I want.  There likely are more 
efficient ways of doing this.  Web page is here:

<http://www.ve1dx.net/>

- Paul

======================================================

#!/bin/bash
#
# Extract today's sunrise and sunset
#
SUNRISE=`grep -A 1 Sunrise /home/weewx/public_html/index.html | cut -f2 
-d\> | cut -f1 -d\< | tail -1`
SUNSET=`grep -A 1 Sunset /home/weewx/public_html/index.html | cut -f2 -d\> 
| cut -f1 -d\< | tail -1`
NOW=`date +%s`
#
# See it it's day time.  If so, take a picture.  If dark, use a black 
square with next update time
#
if [ $NOW -ge `date -d"$SUNRISE" +%s` ] && [ $NOW -le `date -d"$SUNSET" 
+%s` ]; then
   # Because of cron's granularity being limited to 1 minute, we wait to 
   # start because we want this picture to be very close in time to the 
weather
   # readings.  This should get it within 2-3 seconds.
   sleep 52
   pix_name=$(date +"%Y-%m-%d_%H-%M-%S").jpg
   /usr/bin/ffmpeg -f video4linux2 -s 1280X960 -i /dev/video0 -ss 0:0:2 
-frames 1 /data2/wx_pix/$pix_name
   #
   # Date and time stamp picture and move it to the upload directory
   #
   TEXT=`date`
   convert -font helvetica -fill blue -pointsize 36 -draw "text 15,50 
'$TEXT'" /data2/wx_pix/$pix_name /data2/wx_pix/$pix_name
   cp -f /data2/wx_pix/$pix_name /home/weewx/public_html/wx_pix.jpg
 else
    TEXT1="It is dark now. Pictures will"
    TEXT2="resume at "$SUNRISE
    convert -font helvetica -fill red -pointsize 36 -draw "text 15,275 
'$TEXT1 " /home/pdunphy/blank_square.jpg /home/pdunphy/blank_square_1.jpg
    convert -font helvetica -fill red -pointsize 36 -draw "text 15,325 
'$TEXT2 " /home/pdunphy/blank_square_1.jpg /home/pdunphy/blank_square_2.jpg
    cp -f /home/pdunphy/blank_square_2.jpg 
/home/weewx/public_html/wx_pix.jpg
fi
exit

======================================================




On Saturday, November 26, 2016 at 9:53:24 AM UTC-4, WindnFog wrote:
>
> I have a USB camera pointed at my backyard.  It takes a picture every 5 
> minutes, one minute before weewx does it's calculations and uploads (i.e. 
> picture at 04, weewx at 05 and so on.)  It works fine now on a cron job 
> every 5 minutes, 24/7.  
>
> I want to enhance it to just take pictures during daylight hours.  My 
> thoughts are to put a time check in my .bat file that runs every 5 
> minutes.  Something like: IF (DAYLIGHT) TAKE_PICTURE ELSE FORGET_IT sort of 
> thinking.  
>
> Is there a better way (from a Linux bash script, not Python) than parsing 
> /home/weewx/public_html/index_html to obtain these values?  I'm looking for 
> the simplest solution.  I'm hoping I can make DAYLIGHT a boolean that is 
> something like this:
>
> DAYLIGHT = ((time > Start civil twilight) AND time <  (End civil twilight))
>
> I could use Sunrise and Sunset instead if they are easier to obtain.
>
> I'd like to upload this photo to my weewx web site, and I can now except 
> well over half of them are taken in the dark.  I want to put a .jpg there 
> that says something like "Next photo update at sunrise" or similar.
>
> Thoughts?  Better ideas?
>
> - Paul
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to