http://www.perlmonks.org?node_id=1203340


in reply to Efficiency of indoor grow light timer

Hi stevieb!
I do figure that you are way over-thinking this.

To handle power-failure restarts, put a call to turn_off_lights(); in the Pi boot routine.

Schedule a chron job to run this code every 10,20 minutes, or even every hour.
Even if the Pi doesn't acquire the correct time, this should prevent the problem of the lights being on too long for multiple days.

#!/usr/bin/perl use strict; use warnings; # time off: 1800 - 0600 6PM to 6AM my $hour = (localtime(time))[2]; if ($hour >= 06 and $hour <= 18) { turn_on_lights(); #day time } else #18:01 to 05:59 avoids the hour 00 discontinuity { turn_off_lights(); #night time }
Update:
I think I had the wrong sense between day and night time before. Oops.
Here is one link to ChronTab.

I have a Raspberry PI 3. What version do you have?