I'm not quite sure I understand. My grace period is now set to the default I guess, of 10 minutes. The program is terminating perhaps 4-5 hours after it starts, when I would guess that it should terminate more like an average (taking the midpoints of the random intervals) of a total of 430 minutes or 7 hours later. But without a trace I can't tell exactly what's going on. If I understand what you're saying when "time is sunset" becomes false, which is I presume at sunset + 10 min, then the next time there is a wait, the program ends. So if I want to trigger on sunset, but not kill the program after the grace period, then how do I do it? Do I set the grace period for the maximum time the program might run after sunset, which is about 10 hours?
Is there a better way to do this? Should I set up some kind of variable that indicates whether the current state of the system is "sundown" or "sunup" i.e. dark or light outside, and then test on that?
Thanks,
Barclay