= 0 && $dawnI - $dt <= 300){ // this will trigger within 10 seconds of dawn
sleep($dawnI - $dt); // wait until dawn
$result = file_get_contents('https://maker.ifttt.com/trigger/dawn/with/key/' . $key); // accessing the url will trigger webhooks
report("dawn"); // report info when the script sends a trigger
}
if($duskI - $dt >= 0 && $duskI - $dt <= 300){ // this will trigger within 10 seconds of dusk
sleep($duskI - $dt); // wait until dusk
$result = file_get_contents('https://maker.ifttt.com/trigger/dusk/with/key/' . $key); // accessing the url will trigger webhooks
report("dusk"); // report info when the script sends a trigger
}
}
//
// report("debug"); // uncomment this line to output info on every run while debugging
//-----------------------
function report($trig){
global $dt, $dawn, $dusk, $result, $i, $sun_info;
echo $trig . " triggered on pass " . ($i+1) . "
\n";
foreach ($sun_info as $key => $val) { // show all elements of the sun array
echo "$key: " . date("H:i:s", $val) . "
\n";
}
echo "-----
\nnow = " . date("H:i:s", $dt) . "
\n"; // show time now and the corrected values used to trigger
echo "dawn = " . date("H:i:s", $dawn) . "
\n";
echo "dusk = " . date("H:i:s", $dusk) . "
\n";
echo "result of this run: " . $result;
}
?>