Welcome to the Cumulus Support forum.
Latest Cumulus MX V4 release 4.0.1 (build 4023) - 16 May 2024
Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024
Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)
Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki
Latest Cumulus MX V4 release 4.0.1 (build 4023) - 16 May 2024
Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024
Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)
Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki
How to display latest image with changing filename
-
- Posts: 15
- Joined: Fri 02 Sep 2016 8:11 am
- Weather Station: WeatherDuino Pro2
- Operating System: CumulusMX
- Location: Brackenfell, Cape Town, South Africa
- Contact:
How to display latest image with changing filename
I'm new to CumulusMX, websites and weather stations.
Managed to get my WeatherDuino Pro2 station up and running with the CumulusMX software running on a Raspberry Pi.
I've got the website that ships with the CumulusMX software running on my web hosting.
Now I'd like to add a weather camera to the website, problem is I have no idea how websites are put together or how it works.
Managed to add a "webcam" page and display an image from copying code from here:https://cumulus.hosiene.co.uk/viewtopic.php?f=19&t=15807
All seems to work fine, but the latest image is not loaded.
I do understand why the latest image is not loaded as the filename of the image to display is hardcoded and I need some code to load the latest image the webcam ftp'd to the webserver.
The webcam upload the images via ftp to the webserver as "cam1_20170325-150650.jpg" for example, problem is the date and time stamp within the filename changes as the webcam uploads new images.
How do I load the latest image with the filename constantly changing?
My webcam page: http://mht.co.za/weather/webcams.htm
Managed to get my WeatherDuino Pro2 station up and running with the CumulusMX software running on a Raspberry Pi.
I've got the website that ships with the CumulusMX software running on my web hosting.
Now I'd like to add a weather camera to the website, problem is I have no idea how websites are put together or how it works.
Managed to add a "webcam" page and display an image from copying code from here:https://cumulus.hosiene.co.uk/viewtopic.php?f=19&t=15807
All seems to work fine, but the latest image is not loaded.
I do understand why the latest image is not loaded as the filename of the image to display is hardcoded and I need some code to load the latest image the webcam ftp'd to the webserver.
The webcam upload the images via ftp to the webserver as "cam1_20170325-150650.jpg" for example, problem is the date and time stamp within the filename changes as the webcam uploads new images.
How do I load the latest image with the filename constantly changing?
My webcam page: http://mht.co.za/weather/webcams.htm
-
- Posts: 1183
- Joined: Fri 27 Jul 2012 11:29 am
- Weather Station: Chas O, Maplin N96FY, N25FR
- Operating System: rPi 3B+ with Buster (full)
Re: How to display latest image with changing filename
You are using jQuery to update an element with id of 'cam1', but your HTML only contains an element with id of 'webcam1'.
Code: Select all
<img src="........jpg" id="webcam1"
Code: Select all
$("#cam1").attr("src",
-
- Posts: 15
- Joined: Fri 02 Sep 2016 8:11 am
- Weather Station: WeatherDuino Pro2
- Operating System: CumulusMX
- Location: Brackenfell, Cape Town, South Africa
- Contact:
Re: How to display latest image with changing filename
Thank you, I corrected the error.sfws wrote:You are using jQuery to update an element with id of 'cam1', but your HTML only contains an element with id of 'webcam1'.
But the latest image is still not loaded.
-
- Posts: 1183
- Joined: Fri 27 Jul 2012 11:29 am
- Weather Station: Chas O, Maplin N96FY, N25FR
- Operating System: rPi 3B+ with Buster (full)
Re: How to display latest image with changing filename
MikeM wrote:Thank you, I corrected the error.
But the latest image is still not loaded.
Code: Select all
$("#cam1").attr("src","http://mht.co.za/weather/webcam/image.jpg" + timestamp)
More mistakes in code segment above, you are adding timestamp after .jpg instead of before and have wrong prefix (see suggestion below):"cam1_20170325-150650.jpg" for example
Code: Select all
$("#cam1").attr("src","http://mht.co.za/weather/webcam/cam1_" + timestamp + ".jpg")
-
- Posts: 15
- Joined: Fri 02 Sep 2016 8:11 am
- Weather Station: WeatherDuino Pro2
- Operating System: CumulusMX
- Location: Brackenfell, Cape Town, South Africa
- Contact:
Re: How to display latest image with changing filename
I made the corrections, but still not working.sfws wrote:If still not working, then perhaps timestamp does not match up, or perhaps function is not actually running, anyway someone whose javaScript knowledge is less rusty than mine may spot more mistakes and tell you.
Unfortunately I can't help myself, my knowledge of website design is none...
- PaulMy
- Posts: 3885
- Joined: Sun 28 Sep 2008 11:54 pm
- Weather Station: Davis VP2 Plus 24-Hour FARS
- Operating System: Windows8 and Windows10
- Location: Komoka, ON Canada
- Contact:
Re: How to display latest image with changing filename
Hi Mike,
Not sure if my work-about will work for your need. Do you need to keep all the date stamped images or only need the last one?
My Hikvision has failed so haven't used this for about a year but what we had done is to use a cron job to run a php script to take the latest time stamp file and rename and save it such as /folder/fixedname.jpg It worked great.
Enjoy,
Paul
Not sure if my work-about will work for your need. Do you need to keep all the date stamped images or only need the last one?
My Hikvision has failed so haven't used this for about a year but what we had done is to use a cron job to run a php script to take the latest time stamp file and rename and save it such as /folder/fixedname.jpg It worked great.
Code: Select all
<?php
#############################################################################################################
## Script to rename Hikvision IP uploaded files containing date and time in file name to a new fixed filename
## Provided by morfeas2002 http://kalamata.meteoclub.gr/
## CAUTION this script will remove any ???.jpg uploaded files from the folder
## CAUTION
## CAUTION
## CAUTION this script will remove any ???.jpg uploaded files from the folder
#############################################################################################################
date_default_timezone_set("America/Toronto"); //
//
//
$dir = "../hvipupload"; // change to suit your system relative to where this script is executed
//
$pattern = '\.(jpg)$';
//
$newstamp = 0;
$newname = "";
if ($handle = opendir($dir)) {
while (false !== ($fname = readdir($handle))) {
// Eliminate current directory, parent directory
if (ereg('^\.{1,2}$',$fname)) continue;
// Eliminate other pages not in pattern
if (! ereg($pattern,$fname)) continue;
// -------------
//
//
//
$pinakas[] = $fname;
}
//
//
sort($pinakas);
//
$posot = count($pinakas);
//
if ($posot>1) $newname = $pinakas[$posot-2];
if ($posot==1) $newname = $pinakas[$posot-1];
}
closedir ($handle);
// $newname
//
copy("../hvipupload/$newname", "../hvipimage/hvipimage.jpg"); // change to suit your system relative to where this script is executed
//
$filesa = glob('../hvipupload/*.jpg'); // change to suit your system relative to where this script is executed
array_walk($filesa,'myunlink');
function myunlink($t)
{
unlink($t);
}
?>
Paul
VP2+
C1 www.komokaweather.com/komokaweather-ca
MX https://komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX https://komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX https:// komokaweather.com/cumulusmx4/index.htm
C1 www.komokaweather.com/komokaweather-ca
MX https://komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX https://komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX https:// komokaweather.com/cumulusmx4/index.htm
-
- Posts: 15
- Joined: Fri 02 Sep 2016 8:11 am
- Weather Station: WeatherDuino Pro2
- Operating System: CumulusMX
- Location: Brackenfell, Cape Town, South Africa
- Contact:
Re: How to display latest image with changing filename
Thank you PaulMy,PaulMy wrote:Not sure if my work-about will work for your need. Do you need to keep all the date stamped images or only need the last one?
I don't need to keep all the images at this stage.
Could you give me some more detailed pointers to implement your solution?
- PaulMy
- Posts: 3885
- Joined: Sun 28 Sep 2008 11:54 pm
- Weather Station: Davis VP2 Plus 24-Hour FARS
- Operating System: Windows8 and Windows10
- Location: Komoka, ON Canada
- Contact:
Re: How to display latest image with changing filename
Hi Mike, I've sent a PM with some information of how I had been using it.
Enjoy,
Paul
Enjoy,
Paul
VP2+
C1 www.komokaweather.com/komokaweather-ca
MX https://komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX https://komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX https:// komokaweather.com/cumulusmx4/index.htm
C1 www.komokaweather.com/komokaweather-ca
MX https://komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX https://komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX https:// komokaweather.com/cumulusmx4/index.htm
-
- Posts: 15
- Joined: Fri 02 Sep 2016 8:11 am
- Weather Station: WeatherDuino Pro2
- Operating System: CumulusMX
- Location: Brackenfell, Cape Town, South Africa
- Contact:
Re: How to display latest image with changing filename
Hi Paul, thank you for the assistance.PaulMy wrote:I've sent a PM with some information of how I had been using it.
I have not received the PM with instructions.
- ConligWX
- Posts: 1672
- Joined: Mon 19 May 2014 10:45 pm
- Weather Station: Davis vPro2+ w/DFARS + AirLink
- Operating System: Ubuntu 24.04 LTS
- Location: Bangor, NI
- Contact:
Re: How to display latest image with changing filename
I had a similar issue with my Webcam - that the image when ftp'd was going to be a random filename (well with a date in the filename) so I ended up using wget to grab the image from the webcam (most webcams will allow this)
Then I could name it what I liked, apply the weather data to it, and then save as a different filename, which is always the same for the webserver to display.
this is obviously in Linux using a cron job, and runs every minute. I then also run another cronjob then next day to grab all of yesterdays images and create a timelapsed video.
works pretty well.
Then I could name it what I liked, apply the weather data to it, and then save as a different filename, which is always the same for the webserver to display.
Code: Select all
#!/bin/sh
#
tday=$(date +%Y%m%d%H%M%S);
#
# get weather image
wget --http-user=xxxxx --http-password=xxxxx "http://x.x.x.x/cgi/jpg/image.cgi" -O "/share/htdocs/weather/sky1.jpg";
# next 2 lines add weather info
#
#set variables
testdata="$(/bin/cat /share/htdocs/weather/camdata.txt)";
testdata1=`date +"%A %d-%b-%Y %R %Z"`;
#
# add top and bottom banners + weather data
/share/.qpkg/Qapache/bin/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 - ICODOWNN2 - www.conligwx.org'" \
-fill yellow -pointsize 18 -draw "text 10,715 '$testdata'" /share/htdocs/weather/sky1.jpg /share/htdocs/weather/sky.jpg
works pretty well.
Regards Simon
https://www.conligwx.org - @conligwx
Davis Vantage Pro2 Plus with Daytime FARS • WeatherLink Live • Davis AirLink • PurpleAir • CumulusMX v4.0.0
https://www.conligwx.org - @conligwx
Davis Vantage Pro2 Plus with Daytime FARS • WeatherLink Live • Davis AirLink • PurpleAir • CumulusMX v4.0.0
- PaulMy
- Posts: 3885
- Joined: Sun 28 Sep 2008 11:54 pm
- Weather Station: Davis VP2 Plus 24-Hour FARS
- Operating System: Windows8 and Windows10
- Location: Komoka, ON Canada
- Contact:
Re: How to display latest image with changing filename
Hi Mike,
I remember typing it, reading it several times to make sure if I could understand it myself, and thought I had clicked Send button but can't find it in my Sent folder. I will give it another try, sorry.
Paul
I remember typing it, reading it several times to make sure if I could understand it myself, and thought I had clicked Send button but can't find it in my Sent folder. I will give it another try, sorry.
Paul
VP2+
C1 www.komokaweather.com/komokaweather-ca
MX https://komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX https://komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX https:// komokaweather.com/cumulusmx4/index.htm
C1 www.komokaweather.com/komokaweather-ca
MX https://komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX https://komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX https:// komokaweather.com/cumulusmx4/index.htm
-
- Posts: 15
- Joined: Fri 02 Sep 2016 8:11 am
- Weather Station: WeatherDuino Pro2
- Operating System: CumulusMX
- Location: Brackenfell, Cape Town, South Africa
- Contact:
Re: How to display latest image with changing filename
Thank you!PaulMy wrote: I will give it another try, sorry.
-
- Posts: 15
- Joined: Fri 02 Sep 2016 8:11 am
- Weather Station: WeatherDuino Pro2
- Operating System: CumulusMX
- Location: Brackenfell, Cape Town, South Africa
- Contact:
Re: How to display latest image with changing filename
Hi Toxic17,Toxic17 wrote:I had a similar issue with my Webcam - that the image when ftp'd was going to be a random filename (well with a date in the filename) so I ended up using wget to grab the image from the webcam (most webcams will allow this)
Then I could name it what I liked, apply the weather data to it, and then save as a different filename, which is always the same for the webserver to display.
This is obviously in Linux using a cron job, and runs every minute. I then also run another cronjob then next day to grab all of yesterdays images and create a timelapsed video.
Works pretty well.
I like your solution as well, especially with the weather data on the image.
What do I need to do to get your script running on my Raspberry Pi?
Would like to get a timelapse video script running at a later stage.
- PaulMy
- Posts: 3885
- Joined: Sun 28 Sep 2008 11:54 pm
- Weather Station: Davis VP2 Plus 24-Hour FARS
- Operating System: Windows8 and Windows10
- Location: Komoka, ON Canada
- Contact:
Re: How to display latest image with changing filename
Hi Mike,
I think PM sent this time.
Enjoy,
Paul
I think PM sent this time.
Enjoy,
Paul
VP2+
C1 www.komokaweather.com/komokaweather-ca
MX https://komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX https://komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX https:// komokaweather.com/cumulusmx4/index.htm
C1 www.komokaweather.com/komokaweather-ca
MX https://komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX https://komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX https:// komokaweather.com/cumulusmx4/index.htm
-
- Posts: 15
- Joined: Fri 02 Sep 2016 8:11 am
- Weather Station: WeatherDuino Pro2
- Operating System: CumulusMX
- Location: Brackenfell, Cape Town, South Africa
- Contact:
Re: How to display latest image with changing filename
Thank you Paul, received it.PaulMy wrote:Hi Mike,
I think PM sent this time.
Enjoy,
Paul
Will go through the instructions this evening and try getting it up and running.