<project version="4">
<component name="ChangeListManager">
<list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
+ <change afterPath="$PROJECT_DIR$/scripts/day.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/scripts/lib/harmony.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/harmony.php" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/config/global.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/global.php" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/scripts/cron/cron.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/cron/cron.php" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/scripts/lib/scenes.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/scenes.php" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/scripts/lib/weatherstation.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/weatherstation.php" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<workItem from="1572939277711" duration="2473000" />
<workItem from="1573628826107" duration="201000" />
<workItem from="1573629043706" duration="29000" />
- <workItem from="1573629088225" duration="609000" />
- </task>
- <task id="LOCAL-00193" summary=".">
- <created>1562657440892</created>
- <option name="number" value="00193" />
- <option name="presentableId" value="LOCAL-00193" />
- <option name="project" value="LOCAL" />
- <updated>1562657440893</updated>
+ <workItem from="1573629088225" duration="3531000" />
+ <workItem from="1574065436563" duration="741000" />
</task>
<task id="LOCAL-00194" summary=".">
<created>1562738981896</created>
<option name="project" value="LOCAL" />
<updated>1572939348456</updated>
</task>
- <option name="localTasksCounter" value="242" />
+ <task id="LOCAL-00242" summary=".">
+ <created>1573630565923</created>
+ <option name="number" value="00242" />
+ <option name="presentableId" value="LOCAL-00242" />
+ <option name="project" value="LOCAL" />
+ <updated>1573630565923</updated>
+ </task>
+ <option name="localTasksCounter" value="243" />
<servers />
</component>
<component name="TodoView">
define('HUE_BRIDGE', '192.168.13.85');
define('HUE_USER', 'zZigF7nPQq9nTZ3GTB1zkntn98trOJVFHWAwFiqQ');
+define('LATITUDE', 48.8758392);
+define('LONGITUDE', 2.3422104);
+
$squeezeboxPlayers = array(
'Salle de bains' => 'b8:27:eb:ab:b4:50',
'Salon' => 'dc:a6:32:02:47:c1',
);
$devices = [
- 'cerveau' => ['id'=>'cerveau','host' => '192.168.13.60', 'user' => 'pi', 'password' => 'atacama'],
- 'litvincent' => ['id'=>'litvincent','host' => '192.168.13.61', 'user' => 'pi', 'password' => 'atacama'],
- 'litjerome' => ['id'=>'litjerome','host' => '192.168.13.62', 'user' => 'pi', 'password' => 'atacama'],
- 'sdb' => ['id'=>'sdb','host' => '192.168.13.63', 'user' => 'pi', 'password' => 'atacama'],
- 'entree' => ['id'=>'entree','host' => '192.168.13.64', 'user' => 'pi', 'password' => 'atacama'],
- 'jarvis' => ['id'=>'jarvis','host' => '192.168.13.60', 'user' => 'jarvis', 'password' => 'atacama'],
- 'minitel1' => ['id'=>'minitel1','host' => '192.168.13.65', 'user' => 'pi', 'password' => 'atacama'],
- 'salon' => ['id'=>'salon','host' => '192.168.13.66', 'user' => 'pi', 'password' => 'atacama'],
- 'bureau' => ['id'=>'bureau','host' => '192.168.13.67', 'user' => 'pi', 'password' => 'atacama'],
- 'cuisine' => ['id'=>'cuisine','host' => '192.168.13.68', 'user' => 'pi', 'password' => 'atacama'],
- 'bureausun' => ['id'=>'bureausun','host' => '192.168.13.70', 'user' => 'pi', 'password' => 'atacama'],
- 'lit' => ['id'=>'lit','host' => '192.168.13.71', 'user' => 'pi', 'password' => 'atacama'],
- 'avion' => ['id'=>'avion','host' => '192.168.13.5', 'user' => 'Tortuga', 'password' => 's77vpo*wu', 'mac' => 'E0:D5:5E:68:67:B9'],
+ 'cerveau' => ['id' => 'cerveau', 'host' => '192.168.13.60', 'user' => 'pi', 'password' => 'atacama'],
+ 'litvincent' => ['id' => 'litvincent', 'host' => '192.168.13.61', 'user' => 'pi', 'password' => 'atacama'],
+ 'litjerome' => ['id' => 'litjerome', 'host' => '192.168.13.62', 'user' => 'pi', 'password' => 'atacama'],
+ 'sdb' => ['id' => 'sdb', 'host' => '192.168.13.63', 'user' => 'pi', 'password' => 'atacama'],
+ 'entree' => ['id' => 'entree', 'host' => '192.168.13.64', 'user' => 'pi', 'password' => 'atacama'],
+ 'jarvis' => ['id' => 'jarvis', 'host' => '192.168.13.60', 'user' => 'jarvis', 'password' => 'atacama'],
+ 'minitel1' => ['id' => 'minitel1', 'host' => '192.168.13.65', 'user' => 'pi', 'password' => 'atacama'],
+ 'salon' => ['id' => 'salon', 'host' => '192.168.13.66', 'user' => 'pi', 'password' => 'atacama'],
+ 'bureau' => ['id' => 'bureau', 'host' => '192.168.13.67', 'user' => 'pi', 'password' => 'atacama'],
+ 'cuisine' => ['id' => 'cuisine', 'host' => '192.168.13.68', 'user' => 'pi', 'password' => 'atacama'],
+ 'bureausun' => ['id' => 'bureausun', 'host' => '192.168.13.70', 'user' => 'pi', 'password' => 'atacama'],
+ 'lit' => ['id' => 'lit', 'host' => '192.168.13.71', 'user' => 'pi', 'password' => 'atacama'],
+ 'avion' => ['id' => 'avion', 'host' => '192.168.13.5', 'user' => 'Tortuga', 'password' => 's77vpo*wu', 'mac' => 'E0:D5:5E:68:67:B9'],
];
// Browse media files on NAS
if ($cronmin % 5 == 0) {
cronTraffic($cronmin, false);
cronVelib($cronmin);
+ cronBackyard($cronmin);
}
if ($cronmin % 10 == 0) {
cronWeather($cronmin);
function cronTranscode($cronmin)
{
- httpRequest('https://home.tortuga.enhydra.fr/scripts/transcode.php','get',[],null,10,true);
+ httpRequest('https://home.tortuga.enhydra.fr/scripts/transcode.php', 'get', [], null, 10, true);
}
function cronRooms($cronmin)
checkPlanetarium();
}
+function cronBackyard($cronmin)
+{
+ if (isDay()) {
+ domoticzSwitch(679,true);
+ } else {
+ domoticzSwitch(679,false);
+ }
+}
+
function cronMediaLibrary($cronmin)
{
global $directories;
--- /dev/null
+<?php
+require_once "import.php";
+echo isDay()?'day':'night';
\ No newline at end of file
$litvincent = 9;
-$bedlowscreenbrightness = 8;
+$bedlowscreenbrightness = 12;
$home = 15;
$chambrebedgroup = $chambre;
['type' => 'insteon', 'command' => '0?1131=I=0=0'],
['type' => 'hue', 'group' => $chambrebedgroup, 'scene' => 'JNieZpDHu5fbMyf'],
['type' => 'scene', 'scene' => 'sdb/nuit'],
- ['type' => 'function', 'function' => 'bedbrightness', 'args' => [$bedlowscreenbrightness]],
+ ['type' => 'function', 'function' => 'bedbrightness', 'args' => [$bedlowscreenbrightness]],
['type' => 'scene', 'scene' => 'chambre/cheminee'],
['type' => 'scene', 'scene' => 'chambre/planetarium/on'], // Planétarium on
- ['type' => 'scene', 'scene' => 'chambre/deshumidificateur/off'],
+// ['type' => 'scene', 'scene' => 'chambre/deshumidificateur/off'],
['type' => 'scene', 'scene' => 'chambre/raspberry/off'],
['type' => 'phonetask', 'phone' => 'vincent', 'task' => 'Va Au Lit'],
],
['type' => 'function', 'function' => 'stopHarmony'],
['type' => 'function', 'function' => 'stopAllSqueezebox'],
['type' => 'function', 'function' => 'offAllOMX'],
- ['type' => 'scene', 'scene' => 'chambre/deshumidificateur/on'],
+// ['type' => 'scene', 'scene' => 'chambre/deshumidificateur/on'],
['type' => 'phonetask', 'phone' => 'vincent', 'task' => 'Stop All Sounds'],
['type' => 'scene', 'scene' => 'chambre/planetarium/off'],
['type' => 'ifttt', 'event' => 'coffee_off'],
- ['type' => 'ifttt', 'event' => 'oven_off'],
+ //['type' => 'ifttt', 'event' => 'oven_off'],
],
'home/welcome' => [
['type' => 'ecomode', 'mode' => '0'],
],
'sdb/off' => [
['type' => 'state', 'key' => 'sdb', 'value' => 0],
- ['type' => 'hue', 'group' => $sdb, 'scene' => ['on' => false, 'brightness' => 0, 'effect' => 'none']],
- ['type' => 'function', 'function' => 'stopSqueezeboxPlayer', 'args' => [$squeezeboxPlayers['WC'], false]],
+ ['type' => 'hue', 'group' => $sdb, 'scene' => ['on' => false]],
+ ['type' => 'function', 'function' => 'stopSqueezeboxPlayer', 'args' => [$squeezeboxPlayers['Salle de bains'], false]],
],
'sdb/on' => [
['type' => 'state', 'key' => 'sdb', 'value' => 1],
- ['type' => 'hue', 'group' => $sdb, 'scene' => ['effect' => 'none']],
+ // ['type' => 'hue', 'group' => $sdb, 'scene' => ['effect' => 'none']],
['type' => 'hue', 'group' => $sdb, 'scene' => '0L4cGh7y29uBBez'],
],
'sdb/morning' => [
],
'sdb/nuit' => [
['type' => 'state', 'key' => 'sdb', 'value' => 1],
- ['type' => 'hue', 'group' => $sdb, 'scene' => ['effect' => 'none']],
+ //['type' => 'hue', 'group' => $sdb, 'scene' => ['effect' => 'none']],
['type' => 'hue', 'group' => $sdb, 'scene' => 'ZTZBNRk6VZMlYvB'],
],
'sdb/spa' => [
['type' => 'domoticz', 'device' => '1', 'switchtype' => 'scene', 'command' => false],
],
'ecomode/notsuper' => [
- ['type' => 'domoticz', 'device' => '1', 'switchtype' => 'scene', 'command' => true, 'priority' => false],
+ ['type' => 'domoticz', 'device' => '1', 'switchtype' => 'scene', 'command' => true],
],
'ecomode/on' => [
['type' => 'scene', 'scene' => 'ecomode/basic'],
<?php
function weatherStationScreenSaver()
{
- $weather = json_decode(file_get_contents(ROOT . '/cache/weather.json'), true);
-
- $pressureTendency = $weather['pressureTendency'] == 'F' ? 'down' : 'up';
-
- $res = '<div id="weatherstation" class="screensaver">';
- $res .= '<div class="time"></div>';
- $res .= '<div class="current">';
- $res .= '<div class="icon">' . accuweatherIcon($weather['icon']) . '</div>';
- $res .= '<div class="icons">';
- $res .= '<div class="night">' . accuweatherIcon($weather['nightIcon']) . '</div>';
- $res .= '<div class="day">' . accuweatherIcon($weather['dayIcon']) . '</div>';
- $res .= '</div>';
- $res .= '<div class="temps">';
- $res .= '<div class="temp-min">' . $weather['min'] . '°C</div>';
- $res .= '<div class="temp"> ' . $weather['temp'] . '°C</div>';
- $res .= '<div class="temp-max">' . $weather['max'] . '°C</div>';
- $res .= '</div>';
- $res .= '<div class="pp"><i class="fa fa-water"></i> ' . $weather['precipitations24'] . ' mm | ' . $weather['pressure'] . ' hPa <i class="fa fa-arrow-circle-' . $pressureTendency . '"></i></div>';
- $res .= '</div>';
- $res .= '<div class="forecasts">';
- foreach ($weather['forecasts'] as $forecast) {
- $res .= '<div class="forecast">';
- $res .= '<div class="weekday">' . $forecast['day'] . '</div>';
- $res .= '<div class="night">' . accuweatherIcon($forecast['nightIcon']) . '</div>';
- $res .= '<div class="day">' . accuweatherIcon($forecast['dayIcon']) . '</div>';
- $res .= '<div class="temp-min">' . $forecast['min'] . '°C</div>';
- $res .= '<div class="temp-max">' . $forecast['max'] . '°C</div>';
- $res .= '</div>';
- }
- $res .= '</div>';
-
- $res .= '<div class="curves">';
- $res .= _curve($weather, 'sun');
- $res .= _curve($weather, 'moon');
- $res .= '</div>';
-
-
- $res .= '</div>';
- return $res;
+ $weather = json_decode(file_get_contents(ROOT . '/cache/weather.json'), true);
+
+ $pressureTendency = $weather['pressureTendency'] == 'F' ? 'down' : 'up';
+
+ $res = '<div id="weatherstation" class="screensaver">';
+ $res .= '<div class="time"></div>';
+ $res .= '<div class="current">';
+ $res .= '<div class="icon">' . accuweatherIcon($weather['icon']) . '</div>';
+ $res .= '<div class="icons">';
+ $res .= '<div class="night">' . accuweatherIcon($weather['nightIcon']) . '</div>';
+ $res .= '<div class="day">' . accuweatherIcon($weather['dayIcon']) . '</div>';
+ $res .= '</div>';
+ $res .= '<div class="temps">';
+ $res .= '<div class="temp-min">' . $weather['min'] . '°C</div>';
+ $res .= '<div class="temp"> ' . $weather['temp'] . '°C</div>';
+ $res .= '<div class="temp-max">' . $weather['max'] . '°C</div>';
+ $res .= '</div>';
+ $res .= '<div class="pp"><i class="fa fa-water"></i> ' . $weather['precipitations24'] . ' mm | ' . $weather['pressure'] . ' hPa <i class="fa fa-arrow-circle-' . $pressureTendency . '"></i></div>';
+ $res .= '</div>';
+ $res .= '<div class="forecasts">';
+ foreach ($weather['forecasts'] as $forecast) {
+ $res .= '<div class="forecast">';
+ $res .= '<div class="weekday">' . $forecast['day'] . '</div>';
+ $res .= '<div class="night">' . accuweatherIcon($forecast['nightIcon']) . '</div>';
+ $res .= '<div class="day">' . accuweatherIcon($forecast['dayIcon']) . '</div>';
+ $res .= '<div class="temp-min">' . $forecast['min'] . '°C</div>';
+ $res .= '<div class="temp-max">' . $forecast['max'] . '°C</div>';
+ $res .= '</div>';
+ }
+ $res .= '</div>';
+
+ $res .= '<div class="curves">';
+ $res .= _curve($weather, 'sun');
+ $res .= _curve($weather, 'moon');
+ $res .= '</div>';
+
+
+ $res .= '</div>';
+ return $res;
}
function _curve($weather, $curve)
{
- $time = time();
-
- if ($curve == 'sun') {
- $set = $weather['sunset'];
- $rise = $weather['sunrise'];
- $icon = '/images/weather/sun.svg';
- $radius = 75;
- $pointXOffset = 44;
- $pointYOffset = 33;
- } else {
- $set = $weather['moonset'];
- $rise = $weather['moonrise'];
- $icon = '/images/weather/moon/' . (round(($weather['moonage'] / 28) * 12) % 12) . '.svg';
- $radius = 50;
- $pointXOffset = 33;
- $pointYOffset = 21;
- }
-
- $diameter = $radius * 2;
-
- $duration = 360 * (($set - $rise) / (3600 * 24));
- $riseAngle = (180 - $duration) / 2;
- $setAngle = $riseAngle + $duration;
-
- //die('d '.$sunduration.';r '.$sunriseAngle.';s '.$sunsetAngle);
-
- $sunrisePos = getPosOnCircle($riseAngle, $radius, $pointXOffset, $pointYOffset);
- $sunsetPos = getPosOnCircle($setAngle, $radius, $pointXOffset, $pointYOffset);
- $sunangle = $riseAngle + (($time - $rise) / (3600 * 24)) * 360;
-
- $res = '<div class="curve curve-' . $curve . '">';
- $res .= '<div class="astre" style="transform: rotate(' . $sunangle . 'deg)"><img src="' . $icon . '" width="20" height="20" style="transform: rotate(' . (-$sunangle) . 'deg)" /></div>';
- $res .= '<div class="orbit"></div>';
- $res .= '<div class="horizon" style="top:' . ($sunrisePos['y'] + 3) . 'px;"></div>';
- $res .= '<div class="point rise" style="top:' . $sunrisePos['y'] . 'px;left:' . $sunrisePos['x'] . 'px;"><span>' . date('H:i', $rise) . '</span></div>';
- $res .= '<div class="point set" style="top:' . $sunsetPos['y'] . 'px;left:' . $sunsetPos['x'] . 'px;"><span>' . date('H:i', $set) . '</span></div>';
- $res .= '</div>';
-
- return $res;
+ $time = time();
+
+ if ($curve == 'sun') {
+ $set = $weather['sunset'];
+ $rise = $weather['sunrise'];
+ $icon = '/images/weather/sun.svg';
+ $radius = 75;
+ $pointXOffset = 44;
+ $pointYOffset = 33;
+ } else {
+ $set = $weather['moonset'];
+ $rise = $weather['moonrise'];
+ $icon = '/images/weather/moon/' . (round(($weather['moonage'] / 28) * 12) % 12) . '.svg';
+ $radius = 50;
+ $pointXOffset = 33;
+ $pointYOffset = 21;
+ }
+
+ $diameter = $radius * 2;
+
+ $duration = 360 * (($set - $rise) / (3600 * 24));
+ $riseAngle = (180 - $duration) / 2;
+ $setAngle = $riseAngle + $duration;
+
+ //die('d '.$sunduration.';r '.$sunriseAngle.';s '.$sunsetAngle);
+
+ $sunrisePos = getPosOnCircle($riseAngle, $radius, $pointXOffset, $pointYOffset);
+ $sunsetPos = getPosOnCircle($setAngle, $radius, $pointXOffset, $pointYOffset);
+ $sunangle = $riseAngle + (($time - $rise) / (3600 * 24)) * 360;
+
+ $res = '<div class="curve curve-' . $curve . '">';
+ $res .= '<div class="astre" style="transform: rotate(' . $sunangle . 'deg)"><img src="' . $icon . '" width="20" height="20" style="transform: rotate(' . (-$sunangle) . 'deg)" /></div>';
+ $res .= '<div class="orbit"></div>';
+ $res .= '<div class="horizon" style="top:' . ($sunrisePos['y'] + 3) . 'px;"></div>';
+ $res .= '<div class="point rise" style="top:' . $sunrisePos['y'] . 'px;left:' . $sunrisePos['x'] . 'px;"><span>' . date('H:i', $rise) . '</span></div>';
+ $res .= '<div class="point set" style="top:' . $sunsetPos['y'] . 'px;left:' . $sunsetPos['x'] . 'px;"><span>' . date('H:i', $set) . '</span></div>';
+ $res .= '</div>';
+
+ return $res;
}
function getPosOnCircle($angle, $radius, $x, $y)
{
- $angle -= 180;
- $cos = $radius / 2 + (cos(deg2rad($angle)) * $radius);
- $sin = $radius / 2 + (sin(deg2rad($angle)) * $radius);
+ $angle -= 180;
+ $cos = $radius / 2 + (cos(deg2rad($angle)) * $radius);
+ $sin = $radius / 2 + (sin(deg2rad($angle)) * $radius);
- return ['x' => $x + $cos, 'y' => $y + $sin];
+ return ['x' => $x + $cos, 'y' => $y + $sin];
}
function accuweatherIcon($icon)
{
- return '<img src="https://vortex.accuweather.com/adc2010/images/slate/icons/' . $icon . '.svg" />';
+ return '<img src="https://vortex.accuweather.com/adc2010/images/slate/icons/' . $icon . '.svg" />';
+}
+
+function isDay()
+{
+ $time = time();
+
+ $sunrise = date_sunrise($time, SUNFUNCS_RET_TIMESTAMP, LATITUDE, LONGITUDE);
+ $sunset = date_sunset($time, SUNFUNCS_RET_TIMESTAMP, LATITUDE, LONGITUDE);
+
+ if ($time > $sunset && $sunrise < $sunset) {
+ $sunrise += 3600 * 24;
+ }
+
+ if ($time < $sunrise || $time > $sunset) {
+ return false;
+ }
+ return true;
}
\ No newline at end of file