From: Vincent Date: Thu, 27 Feb 2020 10:17:10 +0000 (+0100) Subject: . X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=c20c24fba538bc68617dcf0059b8cf02cd2a4634;p=tortuga-home.git . --- diff --git a/.idea/workspace.xml b/.idea/workspace.xml index c3387fa..6912b86 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,7 +3,10 @@ - + + + + @@ -1208,11 +1214,11 @@ - + - + @@ -1227,18 +1233,18 @@ - - + + - - - + + + - + diff --git a/config/chambre.php b/config/chambre.php index 3a9c900..541aef0 100644 --- a/config/chambre.php +++ b/config/chambre.php @@ -6,7 +6,7 @@ config('SLEEPSCREEN', 15); config('SCREENSAVER_BRIGHTNESS', 100); config('SLEEPTYPE', 'screensaver'); config('SCREENSAVER','weatherstation'); -config('VOLUME_DEVICE', 'SqueezeboxPlayer'); +config('VOLUME_DEVICE', 'RaspberryPi:lit'); config('HIDEMASK_TIMEOUT',250); if(DISPLAYINTERFACE) { diff --git a/scripts/lib/lib.php b/scripts/lib/lib.php index 85cf080..a68538e 100644 --- a/scripts/lib/lib.php +++ b/scripts/lib/lib.php @@ -432,11 +432,18 @@ function volume($volume, $increase = '') echo $device . ' (' . $p . ') : ' . $d; + $e = explode(':', $d); + $rpiDevice = null; + if (isset($e[1])) { + $rpiDevice = $e[1]; + $d = $e[0]; + } + switch ($d) { case 'Raspberry': case 'RaspberryPi': $cmd = 'amixer -c 0 -M -- sset PCM playback ' . round(max(0, min(100, $volume))) . '%' . $increase; - return sshCommand($cmd); + return sshCommand($cmd, $rpiDevice); case 'SqueezeboxPlayer': return squeezeVolume($volume, $increase, $player); case 'Harmony': diff --git a/scripts/lib/scenes.php b/scripts/lib/scenes.php index cb51b4b..eb011a8 100644 --- a/scripts/lib/scenes.php +++ b/scripts/lib/scenes.php @@ -488,6 +488,10 @@ $scenes = [ ['type' => 'hue', 'group' => $wc, 'scene' => 'h82j28eNu6ZHVhM'], ['type' => 'function', 'function' => 'squeezePlayByName', 'args' => ['FIP', $squeezeboxPlayers['WC'], 30, false]], ], + 'wc/late' => [ + ['type' => 'hue', 'group' => $wc, 'scene' => 'IGo4F5jRQXc1H95'], + ['type' => 'function', 'function' => 'squeezePlayByName', 'args' => ['FIP', $squeezeboxPlayers['WC'], 30, false]], + ], 'wc/night' => [ ['type' => 'hue', 'group' => $wc, 'scene' => 'eJy09JTEzCiIL1P'], ], @@ -689,8 +693,10 @@ function sdbToggle() function wcOn($vmc = true) { $hour = getHour(); - if ($hour > 2.5 && $hour < 6.75) { + if (getNightMode()) { $period = 'night'; + } else if ($hour > 0 && $hour < 6.75) { + $period = 'late'; } else if ($hour >= 6.75 && $hour < 10) { $period = 'morning'; } else if ($hour >= 10 && $hour < 20) { diff --git a/scripts/lib/weatherstation.php b/scripts/lib/weatherstation.php index 49f73d2..79fe585 100644 --- a/scripts/lib/weatherstation.php +++ b/scripts/lib/weatherstation.php @@ -113,11 +113,18 @@ function accuweatherIcon($icon) } function isDay() +{ + return getPeriodOfDay()['day']; +} + +function getPeriodOfDay() { $time = new DateTime('now', new DateTimeZone('Europe/Paris')); $timestamp = $time->getTimestamp(); $offset = $time->getOffset() / 3600; + $hours = intval(date('H')); + $sunrise = date_sunrise($timestamp, SUNFUNCS_RET_TIMESTAMP, LATITUDE, LONGITUDE, 90, $offset); $sunset = date_sunset($timestamp, SUNFUNCS_RET_TIMESTAMP, LATITUDE, LONGITUDE, 90, $offset); @@ -125,8 +132,30 @@ function isDay() $sunrise += 3600 * 24; } - if ($timestamp < $sunrise || $timestamp > $sunset) { - return false; + + $start_twilight = $sunset - 3600; + $end_twilight = $sunset + 3600; + + $start_dawn = $sunrise - 3600; + $end_dawn = $sunrise + 3600; + + $day = !($timestamp < $sunrise || $timestamp >= $sunset); + + if ($timestamp >= $start_twilight && $timestamp < $end_twilight) { + $period = 'twilight'; + } else if ($timestamp >= $start_dawn && $timestamp < $end_dawn) { + $period = 'dawn'; + } else if ($day) { + + } else { + $period = 'night'; } - return true; + + if ($day) { + $midday = ($sunset + $sunrise) / 2; + } else { + + } + + return ['day' => $day, 'period' => $period]; } \ No newline at end of file