Ejemplo n.º 1
0
function getSunStatus()
{
    if ($_REQUEST['scheme']) {
        return $_REQUEST['scheme'];
    }
    $cm = dateToMinutes(time());
    $sunSet = getSunset();
    $sunRise = getSunrise();
    if ($cm > $sunSet || $cm < $sunRise) {
        return 'night';
    } else {
        return 'day';
    }
}
Ejemplo n.º 2
0
function dayPeriod()
{
    global $schedulePars;
    $t = getCurrentLocalTime(true);
    switch ($schedulePars[SCHEDULE_DAYMODE]) {
        case 0:
            $sr = 60 * getSunrise(SUNFUNCS_RET_DOUBLE);
            $ss = 60 * getSunset(SUNFUNCS_RET_DOUBLE);
            if ($t < $sr + $schedulePars[SCHEDULE_DAWNSTARTMINUTES]) {
                $period = 1;
            } else {
                if ($t < $sr + $schedulePars[SCHEDULE_DAYSTARTMINUTES]) {
                    $period = 2;
                } else {
                    if ($t > $ss + $schedulePars[SCHEDULE_DUSKENDMINUTES]) {
                        $period = 1;
                    } else {
                        if ($t > $ss + $schedulePars[SCHEDULE_DAYENDMINUTES]) {
                            $period = 4;
                        } else {
                            $period = 3;
                        }
                    }
                }
            }
            break;
        case 1:
            $period = 0;
            break;
        case 2:
            $times = $schedulePars[SCHEDULE_TIMES];
            $period = count($times) - 1;
            $maxLessV = -1;
            for ($i = 0; $i < count($times); $i++) {
                $fMins = $times[$i];
                $j = strpos($fMins, ':');
                if ($j > 0) {
                    $fMins = substr($fMins, 0, $j) * 60 + substr($fMins, $j + 1);
                    if ($fMins <= $t) {
                        if ($fMins > $maxLessV) {
                            $maxLessV = $fMins;
                            $period = $i;
                        }
                    }
                }
            }
            $period += 5;
            break;
    }
    return $period;
}
Ejemplo n.º 3
0
<?php

$isDay = $t >= strtotime(date('H:i', getSunrise(false))) && $t <= strtotime(date('H:i', getSunset(false)));
$dayString = $isDay ? 'DAY' : 'NIGHT';
$this->callEventHandlers(array($_POST['event']), $_POST);
print json_encode($GLOBALS['log']);
$_POST['log'] = $GLOBALS['log'];
#WriteToFile('log/event.log', date('Y-m-d H:i:s').' trigger '.json_encode($_POST).chr(10));
Ejemplo n.º 4
0
      menuVisible = false;
      
      toggleMenu = function() {
        if(!menuVisible)
          $('#menu').fadeIn('normal');
        else
          $('#menu').fadeOut('normal');
        menuVisible = !menuVisible;
      };
      
      sunSet = <?php 
echo getSunset();
?>
;
      /* sunset <?php 
echo date('H:i:s', getSunset(false));
?>
 */
      sunRise = <?php 
echo getSunrise();
?>
;
      /* sunrise <?php 
echo date('H:i:s', getSunrise(false));
?>
 */
      currentRefMinutes = <?php 
echo dateToMinutes(time());
?>
;
      /* current <?php 
Ejemplo n.º 5
0
$mode = new H2Mode();
if ($mode->current != 'No Auto') {
    $weather = json_decode(file_get_contents('data/openweather.json'), true);
    @($mainWeather = $weather['weather'][0]);
    $weekDay = date('N');
    $WE = $weekDay == 6 || $weekDay == 7 ? 'WEEKEND' : 'WEEKDAY';
    $weekDayName = $GLOBALS['weekdays'][$weekDay];
    $coolDown = time() - 120;
    $eventAdresses = array('TICK');
    foreach (array(time(), time() - 60) as $t) {
        foreach (array('TIME-' . date('H:i', $t), $weekDayName . '-' . date('H:i', $t), $WE . '-' . date('H:i', $t), 'MINUTE-' . date('i', $t)) as $e) {
            $eventAdresses[] = $e;
        }
        $sunRiseIn = round(($t - strtotime(date('H:i', getSunrise(false)))) / 60);
        $sunSetIn = round(($t - strtotime(date('H:i', getSunset(false)))) / 60);
        $sunEventDistance = 300;
        #minutes
        if ($sunRiseIn > -$sunEventDistance && $sunRiseIn <= 0) {
            $eventAdresses[] = 'SUNRISE' . $sunRiseIn;
        }
        if ($sunRiseIn < $sunEventDistance && $sunRiseIn >= 0) {
            $eventAdresses[] = 'SUNRISE+' . $sunRiseIn;
        }
        if ($sunSetIn > -$sunEventDistance && $sunSetIn <= 0) {
            $eventAdresses[] = 'SUNSET' . $sunSetIn;
        }
        if ($sunSetIn < $sunEventDistance && $sunSetIn >= 0) {
            $eventAdresses[] = 'SUNSET+' . $sunSetIn;
        }
        if ($sunRiseIn == 0) {