risacher / sunwait

Sunwait calculates sunrise or sunset times with civil, nautical, astronomical and custom twilights, for use with Windows Task Scheduler or 'cron' on Linux.
GNU General Public License v3.0
193 stars 45 forks source link

Wait reduced for no apparent reason #3

Open pilkjaer opened 5 years ago

pilkjaer commented 5 years ago

Hi! I think the idea of this program is really nice and I would like to use it to control lights outside of the house. Time for sunrise and sunset are being correctly calculated for my location. Unfortunately, when using example stated in the documentation it doesn't work as I expect it. I expect program to terminate 30 min prior sunset. For some reason it terminates after 10 sec. Below is a debug printout. Last line in debug printout is a mystery to me. Why "wait" is being reduced!? I'm running "latest" version that I fetched and built about a week ago. Running on RPi3.

pi@pismart:~ $ sunwait wait debug set offset -00:30:00 \<My Latitude> \<My Longitude> Debug: argv[1]: >wait< Debug: argv[2]: >debug< Debug: argv[3]: >set< Debug: argv[4]: >offset< Debug: argv[6]: >XXXXXXXXXX< Debug: argv[7]: >XXXXXXXXXX< Debug: All output to use local timezone (nogmt). Debug: Now utcTm: Mon Apr 22 11:09:26 2019 GMT Debug: Now localTm: Mon Apr 22 13:09:26 2019 CEST Debug: Now UTC bias (add to GMT to get CEST) hours: 2.000000 Debug: UTC Bias (hours): 2.000000 Debug: Now: Days since 2000: 7051 Debug: Target year set to: 119 Debug: Target mon set to: 3 Debug: Target mday set to: 22 Debug: Target utcTm: Mon Apr 22 00:00:00 2019 GMT Debug: Target localTm: Mon Apr 22 02:00:00 2019 CEST Debug: Target UTC bias (add to GMT to get CEST) hours: 2.000000 Debug: Target: Days since 2000: 7051 Debug: Co-ordinates - Latitude: XXXXXXXXX Debug: Co-ordinates - Longitude: XXXXXXXXX Debug: Twilight - Daylight Debug: User specified offset (hours): -0.500000 Debug: Function selected: Wait Debug: sunriset.cpp: Sun directly south: 10.940656 UTC, Dirunal Arc = 14.845321 hours Debug: sunriset.cpp: Days since 2000: 7050 Debug: sunriset.cpp: Sun directly south: 10.937158 UTC, Dirunal Arc = 14.929036 hours Debug: sunriset.cpp: Days since 2000: 7051 Debug: sunriset.cpp: Sun directly south: 10.933778 UTC, Dirunal Arc = 15.012551 hours Debug: sunriset.cpp: Days since 2000: 7052 Debug: Wait reduced from 27880 to 10 seconds. pi@pismart:~ $ echo $? 0

pilkjaer commented 5 years ago

According to the code you do reduce wait to 10 sec when running in debug mode (by design). But it seems that even for "normal" mode same/similar timeout being applied.

Source code in question:

// // In debug mode, we don't want to wait for sunrise or sunset. Wait a minute instead. // if (pRun->debug == ONOFF_ON) { printf("Debug: Wait reduced from %li to 10 seconds.\n", waitSeconds); waitSeconds = 10; } else if (pRun->functionPoll == ONOFF_ON) waitSeconds += 60; // Make more sure that a subsequent POLL works properly (wink ;-)