Welcome to the Cumulus Support forum.

Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025

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

If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080

Run External Programs based on Sunrise/Sunset webtags

Discussion and questions about Cumulus weather station software version 1. This section is the main place to get help with Cumulus 1 software developed by Steve Loft that ceased development in November 2014.
User avatar
ace2
Posts: 679
Joined: Tue 14 Jan 2014 12:38 pm
Weather Station: maxkon ws-1081pc
Operating System: windows 7 & 8
Location: Adelaide, south Australia, Australia
Contact:

Re: Run External Programs based on Sunrise/Sunset webtags

Post by ace2 »

Going to test cam uploading with this web tag <#isdaylight>.
Added a text with the webtag into cumulus which output the result been either a 1 or 0 to a file called onoff.text.

The script I'll run every 10 Minutes to check this file is :

Find "1" onoff.txt >nul && call "findpic.exe"

Now I think this will execute the findpic.exe which searches my NAS drive for the latest picture and uploads that.

I normally schedule findpic every 10 minutes and a swap htm to take the camera offline at a certain time.

By adding to the same script the line
Find "0" onoff.txt >nul && call "offline.exe"

This will do the picture swap to take the camera offline

This should automatically upload images between dawn and dusk and take the carema offline.
Now just have to wait till I get home to test this!!!

Have to find another solution to the stop start time lapse by nautical and astronomical twilight another time.
CHRIS
Image
web site
http://www.ace2weather.com
Follow me on Twitter
http://tinyurl.com/kwlr9re
YouTube channel
http://tinyurl.com/lehwpgp
Facebook page
http://tinyurl.com/k3sap4s
Tiny URL links used
User avatar
MackerelSky
Posts: 141
Joined: Fri 01 Apr 2011 8:14 pm
Weather Station: Davis VP2 w/FARS
Operating System: Toshiba Laptop Windows 7 x64
Location: Smethport, Pa.
Contact:

Re: Run External Programs based on Sunrise/Sunset webtags

Post by MackerelSky »

Thanks for posting the links BCJKiwi and for giving great insight on this topic.

Brad
BCJKiwi wrote:@ace2
Doing math on dates is absolutely do-able in a batch file.

Construct the batch file with sample data in the format that Cumulus will deliver it to test the match.
Then save the working batch file as batchT.txt
edit it to replace the test data with the webtag.
Cumulus will process the text file and save as batch.cmd
You then run batch.cmd in the program time slot of Cumulus' external programs.
The batch file can do any number of different things in the one file if you need more routines, or, you could have a separate batch file for each routine (from Cumulus or not) and chain them together in another batch file.

Time to study the many features of the batch file language ;)

All manner of things can be carried out in batch files - some complicated some less so.
There are also programs designed to extend and/or simplify these processes.

e.g. Math;
http://www.robvanderwoude.com/battech_math.php
Date and time
http://www.robvanderwoude.com/datetime.php

Also on that site many other commands are described;
http://www.robvanderwoude.com/batchfiles.php

I have also used the Kixtart program extensively over many years for login scripts and for routines similar to some php code.

While these references may appear old, nothing much has changed and these still work in all current versions of Windows AFAIK.
Davis VP2/FARS
Cumulus 1.9.4(1092)

McKean Weather
'cause not everyone lives at the airport

Image
User avatar
ace2
Posts: 679
Joined: Tue 14 Jan 2014 12:38 pm
Weather Station: maxkon ws-1081pc
Operating System: windows 7 & 8
Location: Adelaide, south Australia, Australia
Contact:

Re: Run External Programs based on Sunrise/Sunset webtags

Post by ace2 »

Completed the script for webcam uploading using dusk/dawn times which also switches the htm page to take online/offline.

Testing seem to be working fine...

Now to the next one with what BCJKiwi has suggested......
CHRIS
Image
web site
http://www.ace2weather.com
Follow me on Twitter
http://tinyurl.com/kwlr9re
YouTube channel
http://tinyurl.com/lehwpgp
Facebook page
http://tinyurl.com/k3sap4s
Tiny URL links used
captzero
Posts: 363
Joined: Wed 03 Mar 2010 10:20 am
Weather Station: Vantage Pro2 w/ daytime FARS
Operating System: Windows 10
Location: Brisbane, Australia
Contact:

Re: Run External Programs based on Sunrise/Sunset webtags

Post by captzero »

Thanks all.
I've checked the links and have a better understanding of how I might achieve my goal of starting and stopping a program based on sun position. I've decided to use either the <#isdaylight> or <#IsSunUp> tags to return 0 or 1.
This Windows Batch Scripting wiki has been a big help. http://en.wikibooks.org/wiki/Windows_Batch_Scripting but I've had to rely on sample batch files I've seen around the net and have cobbled together the following.....

Code: Select all

@REM Using cumulus webtags <#isdaylight> based on the dawn and dusk or <#IsSunUp> based on the sunrise/sunset
@REM if sun = 1 sun is up if sun = 0 sun has set
@ECHO off
@REM webtag variable 
SET sun=1
@REM Start program if sun equals 1
IF "!sun!"=="%1" START "" "C:\Program Files (x86)\Camstreams Media Encoder\Bin\CamstreamsEncoder.exe"
@REM Kill program if sun does not equal 1
IF not "!sun!"=="%1" taskkill /f /im CamstreamsEncoder.exe >nul 2>nul
exit
It will kill the program if its running if sun =0 or 1 and wont run it at all.
Although the links have been a help, I suspect the syntax and the structure are not correct.
I'd appreciate it if some one give me a nudge in the right direction.
Thanks
Last edited by captzero on Sat 24 May 2014 11:05 pm, edited 1 time in total.
Dan

http://www.brisbaneliveweather.com




A man with a thermometer always knows the temperature. A man with two thermometers, not so sure.
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Run External Programs based on Sunrise/Sunset webtags

Post by mcrossley »

As you are not using delayedexpansion change "!sun!" to "%sun%"
captzero
Posts: 363
Joined: Wed 03 Mar 2010 10:20 am
Weather Station: Vantage Pro2 w/ daytime FARS
Operating System: Windows 10
Location: Brisbane, Australia
Contact:

Re: Run External Programs based on Sunrise/Sunset webtags

Post by captzero »

Thanks Mark,
Perfect. How do you know this stuff???
Thanks again
(Also changed "%1" to "1")
Dan

http://www.brisbaneliveweather.com




A man with a thermometer always knows the temperature. A man with two thermometers, not so sure.
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Run External Programs based on Sunrise/Sunset webtags

Post by mcrossley »

captzero wrote:How do you know this stuff???
A lifetime (often it feels like more) working in IT :cry:
User avatar
ace2
Posts: 679
Joined: Tue 14 Jan 2014 12:38 pm
Weather Station: maxkon ws-1081pc
Operating System: windows 7 & 8
Location: Adelaide, south Australia, Australia
Contact:

Re: Run External Programs based on Sunrise/Sunset webtags

Post by ace2 »

Now all we need to do is work out dawn/dusk times with either + or - x minutes or a webtag for nornautical and astronomical twilight!!
CHRIS
Image
web site
http://www.ace2weather.com
Follow me on Twitter
http://tinyurl.com/kwlr9re
YouTube channel
http://tinyurl.com/lehwpgp
Facebook page
http://tinyurl.com/k3sap4s
Tiny URL links used
captzero
Posts: 363
Joined: Wed 03 Mar 2010 10:20 am
Weather Station: Vantage Pro2 w/ daytime FARS
Operating System: Windows 10
Location: Brisbane, Australia
Contact:

Re: Run External Programs based on Sunrise/Sunset webtags

Post by captzero »

If you want to capture images at sunrise and sunset you could use the <#isdaylight> tag to commence and cease capturing at dawn and dusk? Here in Brisbane at the moment, dawn is 25 mins before sunrise and dusk is 25 mins after sunset.
Dan

http://www.brisbaneliveweather.com




A man with a thermometer always knows the temperature. A man with two thermometers, not so sure.
User avatar
ace2
Posts: 679
Joined: Tue 14 Jan 2014 12:38 pm
Weather Station: maxkon ws-1081pc
Operating System: windows 7 & 8
Location: Adelaide, south Australia, Australia
Contact:

Re: Run External Programs based on Sunrise/Sunset webtags

Post by ace2 »

captzero wrote:If you want to capture images at sunrise and sunset you could use the <#isdaylight> tag to commence and cease capturing at dawn and dusk? Here in Brisbane at the moment, dawn is 25 mins before sunrise and dusk is 25 mins after sunset.
My goal is to start my time lapse just before first light and just after, here in Adelaide first light breaks about 30 minutes before dawn and about the same after dusk times.
Which kind of sucks!!

But I'm using the <isdaylight> web tag to do my webcam shot, which basically copies latest jpg to web site every X minutes.
CHRIS
Image
web site
http://www.ace2weather.com
Follow me on Twitter
http://tinyurl.com/kwlr9re
YouTube channel
http://tinyurl.com/lehwpgp
Facebook page
http://tinyurl.com/k3sap4s
Tiny URL links used
User avatar
ace2
Posts: 679
Joined: Tue 14 Jan 2014 12:38 pm
Weather Station: maxkon ws-1081pc
Operating System: windows 7 & 8
Location: Adelaide, south Australia, Australia
Contact:

Re: Run External Programs based on Sunrise/Sunset webtags

Post by ace2 »

Just a thought. Say you wanted to start a time lapse recording just before first light.
I found a script that can minus/add minutes to current time, of course supplement current time for the dawn webtag and once current time is greater than output to a 1 to a txt file.

Then is a matter of running a script that looks at the text and if =1 turn on software and 0 turn off.
Just a thought.
You think it might work??

http://acoderslife.com/index.cfm/blog/A ... batch-file
CHRIS
Image
web site
http://www.ace2weather.com
Follow me on Twitter
http://tinyurl.com/kwlr9re
YouTube channel
http://tinyurl.com/lehwpgp
Facebook page
http://tinyurl.com/k3sap4s
Tiny URL links used
BCJKiwi
Posts: 1259
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Run External Programs based on Sunrise/Sunset webtags

Post by BCJKiwi »

There is a lot of irrelevant code in that example for your application.
From Cumulus you can get the hour and minute (separately) for the current time, sunrise and sunset.

create a var for the offset you want.
Do the math

a sample batch file is attached as timeswT.txt
This will set a sunRise Rflag to 1 45 mins before sunrise.
This will set a sunSet Sflag to 1 45 mins after sunset.

It gets the current time, sunset and sunrise times in hour and minutes separately.

converts these times to minutes.
adds/subtracts the offsets, does the comparisons and sets the flags.

You will want to modify it to suit.

All this from the information available in the original references I supplied in the links above.
You do not have the required permissions to view the files attached to this post.
User avatar
ace2
Posts: 679
Joined: Tue 14 Jan 2014 12:38 pm
Weather Station: maxkon ws-1081pc
Operating System: windows 7 & 8
Location: Adelaide, south Australia, Australia
Contact:

Re: Run External Programs based on Sunrise/Sunset webtags

Post by ace2 »

BCJKiwi wrote:There is a lot of irrelevant code in that example for your application.
From Cumulus you can get the hour and minute (separately) for the current time, sunrise and sunset.

create a var for the offset you want.
Do the math

a sample batch file is attached as timeswT.txt
This will set a sunRise Rflag to 1 45 mins before sunrise.
This will set a sunSet Sflag to 1 45 mins after sunset.

It gets the current time, sunset and sunrise times in hour and minutes separately.

converts these times to minutes.
adds/subtracts the offsets, does the comparisons and sets the flags.

You will want to modify it to suit.

All this from the information available in the original references I supplied in the links above.
That would work well, but i would need to process the webtags to a txt file as i have to convert cmd/bat into a exe as the bat/cmd popup interrupt playback on my media pc and output the flags to a txt.
But is a solution..............
CHRIS
Image
web site
http://www.ace2weather.com
Follow me on Twitter
http://tinyurl.com/kwlr9re
YouTube channel
http://tinyurl.com/lehwpgp
Facebook page
http://tinyurl.com/k3sap4s
Tiny URL links used
User avatar
ace2
Posts: 679
Joined: Tue 14 Jan 2014 12:38 pm
Weather Station: maxkon ws-1081pc
Operating System: windows 7 & 8
Location: Adelaide, south Australia, Australia
Contact:

Re: Run External Programs based on Sunrise/Sunset webtags

Post by ace2 »

BCJKiwi
I forgot to say thank you for that script, as it is, it works perfectly and only requires a little modification for my needs.
I was going down a similar path to your script, but my scripting skills are poor....
So tx.
CHRIS
Image
web site
http://www.ace2weather.com
Follow me on Twitter
http://tinyurl.com/kwlr9re
YouTube channel
http://tinyurl.com/lehwpgp
Facebook page
http://tinyurl.com/k3sap4s
Tiny URL links used
BCJKiwi
Posts: 1259
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Run External Programs based on Sunrise/Sunset webtags

Post by BCJKiwi »

@ ace2;
Thnx

The main issue with batch files is understanding the rather arcane syntax.
Baby steps and example scripts along with tutorial type info such as that provided on the linked site in my first post are the way to go for me.

I have been at it since before windows existed but still need to refer back to source and apply trial and error as I just don't do it often enough anymore.
Post Reply