Welcome to the Cumulus Support forum.

Latest Cumulus MX release 3.8.0 (build 3090) - 12 August 2020 (please see important announcement regarding releases since 3.5.0)
Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of the NOAA report and Snow Index drop-down menus to 2030)

Use this link to Download the Software (Cumulus MX / Cumulus 1 and other related items). Software

Bash scrip

Hardware/software/hints and tips/discussion/webcam links etc
Post Reply
User avatar
dazza1223
Posts: 532
Joined: Sun 25 Jan 2015 8:41 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 10
Location: Worthing
Contact:

Bash scrip

Post by dazza1223 »

Hi has any one made bash scrip to take snapshot off a ip cam and over lay in with data?
Have fun and keep learning

dazza :D

Image

User avatar
ConligWX
Posts: 798
Joined: Mon 19 May 2014 10:45 pm
Weather Station: Davis vPro2 Plus +DFARS
Operating System: Ubuntu / Windows 10
Location: Bangor, NI
Contact:

Re: Bash scrip

Post by ConligWX »

yep :)

I run mine every minute I think with crontab. something like this:

camdataT.txt Template processed realtime.

Code: Select all

Temp: <#temp>°C - Press: <#press> hPa - Hum: <#hum>% - Wind: <#wspeed> mph(<#currentwdir>) - Rain: <#rfall> mm - UV Index: <#UV> - SolarRad: <#SolarRad> W/m² - CloudBase: <#cloudbase>.
then minute script

Code: Select all

#!/bin/sh
#
#set variable yday to be like 20100208
#
#tday=$(date -d today +%Y%m%d%H%M%S);
#stamp=$(date '+DATE: %d/%m/%y%nTIME:%H:%M:%S');
tday=$(date +%Y%m%d%H%M%S);
#stamp=$(date +%Y%m%d);
#
# get weather image
wget --auth-no-challenge --http-user=xxxxxx --http-password=xxxxxxxx "http://xxx.xxx.xx.xxx/cgi/jpg/image.cgi" -O "/share/weather/sky1.jpg";
# next 2 lines add weather info
testdata="$(/bin/cat /share/weather/camdata.txt)";
testdata1=`date +"%A %d-%b-%Y %R %Z"`;

# add layers and text to image
convert -fill RoyalBlue4 -draw "fill-opacity 0.4 rectangle 0 0 1280 25" \
-fill red -draw "fill-opacity 0.6 rectangle 0 26 1280 27" \
-fill RoyalBlue4 -draw "fill-opacity 0.7 rectangle 0 695 1280 720" \
-fill red -draw "fill-opacity 0.6 rectangle 0 693 1280 694" \
-fill white -pointsize 18 -font /share/script/arialbold.ttf -draw "text 10,20 'Conlig Weather Station:  $testdata1 - ICODOWNN2 - www.conligwx.org'" \
-fill yellow -pointsize 18 -draw "text 10,715 '$testdata'" /share/weather/sky1.jpg  /share/weather/skywebcam.jpg

# convert image.jpg to 150kb for WUnderground
convert /share/weather/skywebcam.jpg -define jpeg:extent=150kb /share/weather/image.jpg

# ftp webcam to wunderground
lftp -e 'put /share/weather/image.jpg; bye' -u xxxxxxxx,passwordxxxx webcam.wunderground.com -d
Image
Regards Simon

https://www.conligwx.org - @conligwx
Davis Vantage Pro2 Plus with Daytime FARS • WeatherLink Live • CumulusMX • Saratoga Templates •

User avatar
dazza1223
Posts: 532
Joined: Sun 25 Jan 2015 8:41 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 10
Location: Worthing
Contact:

Re: Bash scrip

Post by dazza1223 »

o Simon thank you for that!!! i did have a Bash scrip but it keep crashing and makeing the imges go all funny? i will try and add yours..... but i will pont out this tho i do think it very nice that some ppl on here do share there hard work and give it to other and includeing you :D
Have fun and keep learning

dazza :D

Image

Big Daddy
Posts: 189
Joined: Tue 10 Sep 2013 8:40 pm
Weather Station: Ecowitt GW1003 (GW1000)
Operating System: Raspbian 10 (Buster) / Mono 6.8
Location: Freiston, Lincolnshire, UK
Contact:

Re: Bash scrip

Post by Big Daddy »

Thanks for this post Simon. Inspired with the idea I did the same for my webcams. All generated on a PI (which also runs my CumuusMX) and managed to integrate a background image using Imagemagick so it blends in with the rest of my website.

http://midlifedad.me.uk/weather/webcam_north.php

Andy

water01
Posts: 1943
Joined: Sat 13 Aug 2011 9:33 am
Weather Station: WH1081
Operating System: Windows 10 64bit
Location: Burnham-on-Sea
Contact:

Re: Bash scrip

Post by water01 »

Very nice, love the time lapse. Is all that running on the Pi?

Assume the template is home built?
David
Image

User avatar
ConligWX
Posts: 798
Joined: Mon 19 May 2014 10:45 pm
Weather Station: Davis vPro2 Plus +DFARS
Operating System: Ubuntu / Windows 10
Location: Bangor, NI
Contact:

Re: Bash scrip

Post by ConligWX »

I do have a tinelapse script too if you guys want it

I am in Berlin for a few days but back home hopefully on Wednesday evening.
Regards Simon

https://www.conligwx.org - @conligwx
Davis Vantage Pro2 Plus with Daytime FARS • WeatherLink Live • CumulusMX • Saratoga Templates •

User avatar
dazza1223
Posts: 532
Joined: Sun 25 Jan 2015 8:41 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 10
Location: Worthing
Contact:

Re: Bash scrip

Post by dazza1223 »

yes plz mate thanks
Have fun and keep learning

dazza :D

Image

Big Daddy
Posts: 189
Joined: Tue 10 Sep 2013 8:40 pm
Weather Station: Ecowitt GW1003 (GW1000)
Operating System: Raspbian 10 (Buster) / Mono 6.8
Location: Freiston, Lincolnshire, UK
Contact:

Re: Bash scrip

Post by Big Daddy »

The Timelapse runs on an old Windows PC using some external software (IPTimelapse) as the PI wasnt able to handle creating 3 video images. It snaps frames using rtsp from my cameras every 10 seconds and then compiles the videos just after midnight each day. Its scheduled to captue between dawn and dusk using lat / long plus I add a bias before and after dusk to capture dark to light and vice versa.

The template started life as a WeatherByYou template "Weather Blues 2" (there is a section in the Sandaysoft forum) but as I learnt more I added more. I cant take all the credit for it, most of that goes to Jacques who developed the original template.

Andy

water01
Posts: 1943
Joined: Sat 13 Aug 2011 9:33 am
Weather Station: WH1081
Operating System: Windows 10 64bit
Location: Burnham-on-Sea
Contact:

Re: Bash scrip

Post by water01 »

OK thanks wondered if the PI was capable of doing the time lapse as well as everything else!!
David
Image

User avatar
dazza1223
Posts: 532
Joined: Sun 25 Jan 2015 8:41 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 10
Location: Worthing
Contact:

Re: Bash scrip

Post by dazza1223 »

i think it will be OK as i tried it with when i was running cumulus /SQL web server etc it a bit slow off making it but it dose the job and have u got the pi 3?
Have fun and keep learning

dazza :D

Image

User avatar
ConligWX
Posts: 798
Joined: Mon 19 May 2014 10:45 pm
Weather Station: Davis vPro2 Plus +DFARS
Operating System: Ubuntu / Windows 10
Location: Bangor, NI
Contact:

Re: Bash scrip

Post by ConligWX »

ok had a look at the script which did work but have done some editing due to the fact uploading to WU for webcams should be no more than 2 minutes apart. 1 minute intervals will most likely be ignored.

so with that I suggest one crontab entry for uploading to WU, there by a separate script or command line entry.

every 2 minutes.

Code: Select all

# ftp webcam to wunderground
#
lftp -e 'put /share/htdocs/weather/image.jpg; bye' -u XXXXXXXX,xxxxxxxx webcam.wunderground.com
then 2 other scripts,

one to handle the image layers and create image and timed filenames:

Code: Select all

#!/bin/sh
#
# set variable yday to be like 20100208
#
# tday=$(date -d today +%Y%m%d%H%M%S);
# stamp=$(date '+DATE: %d/%m/%y%nTIME:%H:%M:%S');
tday=$(date +%Y%m%d%H%M%S);

# stamp=$(date +%Y%m%d);
#
# get weather image
wget --auth-no-challenge --http-user=xxxxx --http-password=xxxxxx "http://x.x.x.x/cgi/jpg/image.cgi" -O "/share/htdocs/weather/sky1.jpg";

# next 2 lines add weather info
#
testdata="$(/bin/cat /share/htdocs/weather/camdata.txt)";
testdata1=`date +"%A %d-%b-%Y %R %Z"`;

# convert -fill RoyalBlue4 -draw "fill-opacity 0.4 rectangle 0 0 1280 25" \
#
convert -fill RoyalBlue4 -draw "fill-opacity 0.4 rectangle 0 0 1280 25" \
-fill red -draw "fill-opacity 0.6 rectangle 0 26 1280 27" \
-fill RoyalBlue4 -draw "fill-opacity 0.7 rectangle 0 695 1280 720" \
-fill red -draw "fill-opacity 0.6 rectangle 0 693 1280 694" \
-fill white -pointsize 18 -font /share/db_backup/script/arialbold.ttf -draw "text 10,20 'Conlig Weather Station:  $testdata1 - INEWTOWN20 - www.conligwx.org'" \
-fill yellow -pointsize 18 -draw "text 10,715 '$testdata'" /share/htdocs/weather/sky1.jpg  /share/htdocs/weather/skywebcam.jpg

# convert image.jpg to 150kb for WUnderground
# 
convert /share/htdocs/weather/skywebcam.jpg -define jpeg:extent=150kb /share/htdocs/weather/image.jpg

# add timestamp to filename for image history and video timelapse.
cp /share/htdocs/weather/sky.jpg /share/htdocs/weather/image-history/video@"$tday".jpg;
the other to create a timelapse video from the image history (run once a day) atapprox 00:01

Code: Select all

#!/bin/sh
#maketimelapse movie
#
#set variable yday to be like 20100208
#
#yday=$(date +%Y%m%d %s -d $(( $(date +%s) - 86400 )));

yday=$(date -d "1 day ago" +%Y%m%d);
#
# make directory for yesterdays images
#
mkdir /share/htdocs/weather/image-history/"$yday";
# mkdir /volume1/Web/fishcam/image-history/"$yday";
#
# move yesterdays images to new directory sample image name is video@20100208000313.jpg
#
mv /share/htdocs/weather/image-history/video@"$yday"??????.jpg /share/htdocs/weather/image-history/"$yday"/;
# remove 0 byte files test script. find . -type f -size 0 | xargs ls -ld
cd /share/htdocs/weather/image-history/"$yday";
#find . -type f -size 0 | xargs rm;
# mv /volume1/Web/fishcam/image-history/video@"$yday"??????.jpg /volume1/Web/fishcam/image-history/"$yday"/;
# remove 0 byte files test script.
# cd /volume1/Web/fishcam/image-history/video@"$yday"??????.jpg /volume1/Web/fishcam/image-history/"$yday";
# /usr/bin/find . -type f -size 0 | xargs rm;
#
# create sequential files for ffmpeg to process apparently they have to be sequential for ffmpeg
#
x=1;
for i in $(ls -r -t /share/htdocs/weather/image-history/"$yday"/*jpg);
do counter=$(printf %04d $x);
ln -s "$i" /share/Public/tmp/img"$counter".jpg;
x=$(($x+1));
done;
#
#process with ffmpeg
#
# /volume1/.@plugins/AppCentral/upnp-server-v2/bin/ffmpeg -r 15 -f image2 -i /volume1/tmp/img%04d.jpg -qmax 9 /volume1/Web/weather/timelapse/"$yday".avi;
# /usr/local/bin/ffmpeg -r 15 -f image2 -i /volume1/tmp/img%04d.jpg -qmax 9 /volume1/Web/weather/timelapse/"$yday".avi;
ffmpeg -r 15 -f image2 -i /share/Public/tmp/img%04d.jpg -qmin 16 -qmax 26 /share/htdocs/weather/image-history/timelapse/"$yday".avi;
#
#tidy
#
rm /share/Public/tmp/img????.jpg;
#
# repeat final stages for fishcam..
#
# x=1;
# for i in $(ls -r -t /volume1/Web/fishcam/image-history/"$yday"/*jpg);
# do counter=$(printf %04d $x);
# ln "$i" /volume1/tmp/img"$counter".jpg;
# x=$(($x+1));
# done;
#
#process with ffmpeg
#
# /usr/local/bin/ffmpeg -r 15 -f image2 -i /volume1/tmp/img%04d.jpg -qmax 9 /volume1/Web/fishcam/timelapse/"$yday".avi;
# /volume1/Download/FFMPEG/ffmpeg -r 15 -f image2 -i /volume1/tmp/img%04d.jpg -qmax 9 /volume1/Web/fishcam/timelapse/"$yday".avi;
#
#tidy
#
# rm /volume1/tmp/img????.jpg;
#
#zip up yesterdays images to keep file count down
#

# /usr/builtin/bin/zip -rm0 /volume1/Web/fishcam/image-history/"$yday" /volume1/Web/fishcam/image-history/"$yday"
zip -rm9 /share/htdocs/weather/image-history/"$yday" /share/htdocs/weather/image-history/"$yday"
Please note I have not run the timelapse one for sometime and may differ from you own setups but it should give you an idea of how to create a timelapse video from your images you create from the previous day. I dont take credit for this, most of which was give to me by a friend (ho66es), and I had tweaked it to my setup and values I wanted for my layers.


Also inclusive is my CamdataT.txt template processed by CumulusMX to camdata.txt

Code: Select all

Temp: <#temp>°C - Press: <#press> hPa - Hum: <#hum>% - Wind: <#wspeed> mph(<#currentwdir>) - Rain: <#rfall> mm - UV Index: <#UV> - SolarRad: <#SolarRad> W/m² - CloudBase: <#cloudbase>.
hope this helps someone.
Regards Simon

https://www.conligwx.org - @conligwx
Davis Vantage Pro2 Plus with Daytime FARS • WeatherLink Live • CumulusMX • Saratoga Templates •

Sadgit
Posts: 183
Joined: Sun 04 Jan 2009 5:56 pm
Weather Station: Vantage Vue
Operating System: Windows 7
Location: Middlesbrough, England

Re: Bash scrip

Post by Sadgit »

old post but this is exactly what I was looking for, so thank you!

User avatar
ConligWX
Posts: 798
Joined: Mon 19 May 2014 10:45 pm
Weather Station: Davis vPro2 Plus +DFARS
Operating System: Ubuntu / Windows 10
Location: Bangor, NI
Contact:

Re: Bash scrip

Post by ConligWX »

Sadgit wrote:
Tue 12 May 2020 1:01 pm
old post but this is exactly what I was looking for, so thank you!
no problem!
Regards Simon

https://www.conligwx.org - @conligwx
Davis Vantage Pro2 Plus with Daytime FARS • WeatherLink Live • CumulusMX • Saratoga Templates •

Post Reply