require_once __DIR__ . "/../import.php";
-function cronOneLoop($cronmin)
-{
- set_time_limit(0);
-
- echo '------------------------------------' . "\n";
- _logSection('One Loop // ' . $cronmin);
- cronHeartbeat($cronmin, false);
- cronHotWater($cronmin);
- cronRooms($cronmin);
- cronWeather($cronmin);
- cronMagnet($cronmin);
-
- if ($cronmin % 5 == 0) {
-
- cronTraffic($cronmin, false);
- cronVelib($cronmin);
- cronGuest($cronmin);
- cronShield($cronmin);
- }
- if ($cronmin % 10 == 0) {
- cronSqueezeFavorites($cronmin);
- }
- if ($cronmin % 20 == 0) {
- cronBackyard($cronmin);
- cronSqueezeCheckPlayers($cronmin);
- }
-
- if ($cronmin % 2 == 0) {
- cronPing($cronmin);
- }
- if ($cronmin % 15 == 0) {
- cronXPlanet($cronmin);
- cronPodcasts($cronmin);
- cronMediaLibrary($cronmin);
- cronTmdb($cronmin);
- }
- cronHarmony($cronmin);
- cronInterface($cronmin);
-
- if ($cronmin == 0) {
- cronEcoMode($cronmin);
- }
- if ($cronmin % 5 == 0) {
- cronTranscode($cronmin);
- }
- if ($cronmin % 15 == 0) {
- cronKodi($cronmin);
- }
- cronHeartbeat($cronmin, true);
- _logSection('End Loop (min:' . $cronmin . ')');
+function cronOneLoop($cronmin) {
+ set_time_limit(0);
+
+ echo '------------------------------------' . "\n";
+ _logSection('One Loop // ' . $cronmin);
+ cronHeartbeat($cronmin, false);
+ cronHotWater($cronmin);
+ cronRooms($cronmin);
+ cronWeather($cronmin);
+ cronMagnet($cronmin);
+
+ if ($cronmin % 5 == 0) {
+
+ cronTraffic($cronmin, false);
+ cronVelib($cronmin);
+ cronGuest($cronmin);
+ cronShield($cronmin);
+ }
+ if ($cronmin % 10 == 0) {
+ cronSqueezeFavorites($cronmin);
+ }
+ if ($cronmin % 20 == 0) {
+ cronBackyard($cronmin);
+ cronSqueezeCheckPlayers($cronmin);
+ }
+
+ if ($cronmin % 2 == 0) {
+ cronPing($cronmin);
+ }
+ if ($cronmin % 15 == 0) {
+ cronXPlanet($cronmin);
+ cronPodcasts($cronmin);
+ cronMediaLibrary($cronmin);
+ cronTmdb($cronmin);
+ }
+ cronHarmony($cronmin);
+ cronInterface($cronmin);
+
+ if ($cronmin == 0) {
+ cronEcoMode($cronmin);
+ }
+ if ($cronmin % 5 == 0) {
+ cronTranscode($cronmin);
+ }
+ if ($cronmin % 15 == 0) {
+ cronKodi($cronmin);
+ }
+ cronHeartbeat($cronmin, true);
+ _logSection('End Loop (min:' . $cronmin . ')');
}
-function cronHotWater($cronmin)
-{
- _logSection('Hot water');
- hotwaterCheckMode();
+function cronHotWater($cronmin) {
+ _logSection('Hot water');
+ hotwaterCheckMode();
}
-function cronMagnet($cronmin)
-{
- //_logSection('Magnet links');
- //file_get_contents("https://entree.home.tortuga.enhydra.fr/scripts/freeboxapi.php?action=magnets");
+function cronMagnet($cronmin) {
+ //_logSection('Magnet links');
+ //file_get_contents("https://entree.home.tortuga.enhydra.fr/scripts/freeboxapi.php?action=magnets");
}
-function cronXPlanet($cronmin)
-{
- _logSection('XPlanet');
- $path = ROOT . '/tools/xplanet/';
- $suncurve = $path . 'xplanet-suncurve';
- $earth = $path . 'xplanet-earth';
+function cronXPlanet($cronmin) {
+ _logSection('XPlanet');
+ $path = ROOT . '/tools/xplanet/';
+ $suncurve = $path . 'xplanet-suncurve';
+ $earth = $path . 'xplanet-earth';
- `$suncurve;$earth`;
+ `$suncurve;$earth`;
}
-function cronBackyard($cronmin)
-{
- _logSection('Backyard');
- $device = 6898;
- domoticzSwitch($device, getDomoticzDeviceStatus($device) === 'On');
+function cronBackyard($cronmin) {
+ _logSection('Backyard');
+ $device = 6898;
+ domoticzSwitch($device, getDomoticzDeviceStatus($device) === 'On');
}
-function cronShield($cronmin)
-{
- _logSection('Shield');
- `/usr/local/bin/adb-connect`;
+function cronShield($cronmin) {
+ _logSection('Shield');
+ `/usr/local/bin/adb-connect`;
}
-function cronGuest($cronmin)
-{
+function cronGuest($cronmin) {
- _logSection('Guest');
- setState('guest', hasGuest() ? '1' : '0');
+ _logSection('Guest');
+ setState('guest', hasGuest() ? '1' : '0');
}
-function cronInsteon($cronmin)
-{
- _logSection('Insteon');
- insteonCommand('knock');
+function cronInsteon($cronmin) {
+ _logSection('Insteon');
+ insteonCommand('knock');
}
-function cronEcoMode($cronmin)
-{
- _logSection('Ecomode');
- ecoMode(null, false);
+function cronEcoMode($cronmin) {
+ _logSection('Ecomode');
+ ecoMode(null, false);
}
-function cronTranscode($cronmin)
-{
- _logSection('Transcode');
- httpRequest('https://salon.home.tortuga.enhydra.fr/scripts/transcode.php', 'get', [], null, 10, true);
+function cronTranscode($cronmin) {
+ _logSection('Transcode');
+ httpRequest('https://salon.home.tortuga.enhydra.fr/scripts/transcode.php', 'get', [], null, 10, true);
}
-function _logSection($t)
-{
- echo '------' . $t . ' :: ' . date('Y-m-d H:i:s') . "\n";
+function _logSection($t) {
+ echo '------' . $t . ' :: ' . date('Y-m-d H:i:s') . "\n";
}
-function cronRooms($cronmin)
-{
- _logSection('Rooms');
+function cronRooms($cronmin) {
+ _logSection('Rooms');
- _logSection('Bureau');
- updateBureauAuto();
+ _logSection('Bureau');
+ updateBureauAuto();
- _logSection('Chambre');
- updateChambreAuto();
+ _logSection('Chambre');
+ updateChambreAuto();
- _logSection('Cour');
- updateCourAuto();
+ _logSection('Cour');
+ updateCourAuto();
- _logSection('Salon');
- updateSalonAuto();
+ _logSection('Salon');
+ updateSalonAuto();
- _logSection('Cuisine');
- updateCuisine();
- _logSection('Planetarium');
- checkPlanetarium();
- if ($cronmin % 2) {
- _logSection('WC VMC');
- checkWCVMC();
- }
+ _logSection('Cuisine');
+ updateCuisine();
+ _logSection('Planetarium');
+ checkPlanetarium();
+ if ($cronmin % 2) {
+ _logSection('WC VMC');
+ checkWCVMC();
+ }
}
-function cronMediaLibrary($cronmin)
-{
- global $directories;
- _logSection('Media Library');
+function cronMediaLibrary($cronmin) {
+ global $directories;
+ _logSection('Media Library');
- $media = array();
- $shareroot = '/volume1/Share';
+ $media = array();
+ $shareroot = '/volume1/Share';
- foreach ($directories as $name => $directory) {
- $dir = $shareroot . '/Videos/' . $directory['dir'];
- if ($directory['context'] == 'tvshow' || $name == 'Films') {
- continue;
- }
- $media[$directory['id']] = array('name' => $name, 'items' => getMediaContents($dir, $directory['context']));
- }
+ foreach ($directories as $name => $directory) {
+ $dir = $shareroot . '/Videos/' . $directory['dir'];
+ if ($directory['context'] == 'tvshow' || $name == 'Films') {
+ continue;
+ }
+ $media[$directory['id']] = array('name' => $name, 'items' => getMediaContents($dir, $directory['context']));
+ }
- connectRedis()->igbset('medialibrary', $media);
+ connectRedis()->igbset('medialibrary', $media);
- _getTVShows(true);
- _getMovies(true);
- _getMediaRecentAdded(true);
+ _getTVShows(true);
+ _getMovies(true);
+ _getMediaRecentAdded(true);
}
-function cronTmdb($cronmin)
-{
- _logSection('TMDB');
- _getTVShows(true, false);
- _getMovies(true, false);
- _getMediaRecentAdded(true);
- parseMoviesLibrary();
+function cronTmdb($cronmin) {
+ _logSection('TMDB');
+ _getTVShows(true, false);
+ _getMovies(true, false);
+ _getMediaRecentAdded(true);
+ parseMoviesLibrary();
}
-function cronPing($cronmin)
-{
- _logSection('Pings');
- global $devices;
- setState('vincenthere', ping('192.168.13.20', 5) ? '1' : '0');
- setState('hasnetwork', ping('1.1.1.1', 3, 443) ? '1' : '0');
- foreach ($devices as $name => $device) {
- if (!isset($device['host'])) {
- continue;
- }
- $result = ping($device['host'], 3, 22) ? '1' : '0';
- setState('device_' . $name . '_awake', $result);
- echo 'device_' . $name . '_awake : ' . getState('device_' . $name . '_awake') . "\n";
- if ($result) {
- sshCommand('pwd', $device['host'], false, false);
- sshCommand('pwd', $device['host'], false, true);
- }
- }
+function cronPing($cronmin) {
+ _logSection('Pings');
+ global $devices;
+ setState('vincenthere', ping('192.168.13.20', 5) ? '1' : '0');
+ setState('hasnetwork', ping('1.1.1.1', 3, 443) ? '1' : '0');
+ foreach ($devices as $name => $device) {
+ if (!isset($device['host'])) {
+ continue;
+ }
+ $result = ping($device['host'], 3, 22) ? '1' : '0';
+ setState('device_' . $name . '_awake', $result);
+ echo 'device_' . $name . '_awake : ' . getState('device_' . $name . '_awake') . "\n";
+ if ($result) {
+ sshCommand('pwd', $device['host'], false, false);
+ sshCommand('pwd', $device['host'], false, true);
+ }
+ }
}
-function cronSqueezeFavorites($cronmin)
-{
- _logSection('Squeeze Favorites');
- $favorites = getSqueezeFavorites();
- if ($favorites !== false && count($favorites) > 0) {
- connectRedis()->igbset('squeezebox_favorites', $favorites);
- }
+function cronSqueezeFavorites($cronmin) {
+ _logSection('Squeeze Favorites');
+ $favorites = getSqueezeFavorites();
+ if ($favorites !== false && count($favorites) > 0) {
+ connectRedis()->igbset('squeezebox_favorites', $favorites);
+ }
}
-function cronSqueezeCheckPlayers($cronmin)
-{
- _logSection('Check squeezebox players');
+function cronSqueezeCheckPlayers($cronmin) {
+ _logSection('Check squeezebox players');
}
-function cronWeather($cronmin)
-{
- _logSection('Weather');
- getWeather();
+function cronWeather($cronmin) {
+ _logSection('Weather');
+ getWeather();
}
-function cronVelib($cronmin)
-{
- _logSection('Velib');
- velibStations(false);
+function cronVelib($cronmin) {
+ _logSection('Velib');
+ velibStations(false);
}
-function cronTraffic($cronmin, $force = false)
-{
- _logSection('Traffic');
- $cache = ROOT . '/cache/traffic.json';
-
- $hour = date('G');
- $day = date('w');
- $limit = 3600;
- $departure_in = 5;
-
- if ($day > 0 && $day < 6 && $hour > 6 && $hour < 10) {
- $limit = 60;
- }
- if ($force || !file_exists($cache) || filemtime($cache) < time() - $limit) {
- $traffic = array('time' => date('H:i', time() + ($departure_in * 60)), 'jams' => trafficJams(), 'car' => itineraryIssy('driving'), 'subway' => itineraryIssy('transit'), 'bike' => itineraryIssy('bicycling'));
- $json = json_encode($traffic);
- file_put_contents($cache, $json);
- if (isset($_GET['force'])) {
- ob_end_clean();
- header('Content-type: application/json');
- echo $json;
- exit;
- }
- }
+function cronTraffic($cronmin, $force = false) {
+ _logSection('Traffic');
+ $cache = ROOT . '/cache/traffic.json';
+
+ $hour = date('G');
+ $day = date('w');
+ $limit = 3600;
+ $departure_in = 5;
+
+ if ($day > 0 && $day < 6 && $hour > 6 && $hour < 10) {
+ $limit = 60;
+ }
+ if ($force || !file_exists($cache) || filemtime($cache) < time() - $limit) {
+ $traffic = array('time' => date('H:i', time() + ($departure_in * 60)), 'jams' => trafficJams(), 'car' => itineraryIssy('driving'), 'subway' => itineraryIssy('transit'), 'bike' => itineraryIssy('bicycling'));
+ $json = json_encode($traffic);
+ file_put_contents($cache, $json);
+ if (isset($_GET['force'])) {
+ ob_end_clean();
+ header('Content-type: application/json');
+ echo $json;
+ exit;
+ }
+ }
}
-function cronPodcasts($cronmin)
-{
- checkSpottyLogin();
- return;
- _logSection('Podcasts');
- $podcasts = getSqueezeFavorites(0, 'podcasts');
- if ($podcasts !== false && count($podcasts) > 0) {
- connectRedis()->igbset('squeezebox_podcasts', $podcasts);
- }
+function cronPodcasts($cronmin) {
+ checkSpottyLogin();
+ return;
+ _logSection('Podcasts');
+ $podcasts = getSqueezeFavorites(0, 'podcasts');
+ if ($podcasts !== false && count($podcasts) > 0) {
+ connectRedis()->igbset('squeezebox_podcasts', $podcasts);
+ }
}
-function cronInterface($cronmin)
-{
- _logSection('Interface');
- if ((getState('ecomode') == '0' && $cronmin % 3 == 0) || $cronmin % 10 == 0) {
- $devices = ['salon', 'bureau', 'entree', 'cuisine', 'litvincent', 'litjerome', 'sdb', 'chambre', 'bureausun', 'wc'];
- foreach ($devices as $device) {
- file_get_contents('https://' . $device . '.home.tortuga.enhydra.fr/');
- }
- }
+function cronInterface($cronmin) {
+ _logSection('Interface');
+ if ((getState('ecomode') == '0' && $cronmin % 3 == 0) || $cronmin % 10 == 0) {
+ $devices = ['salon', 'bureau', 'entree', 'cuisine', 'litvincent', 'litjerome', 'sdb', 'chambre', 'bureausun', 'wc'];
+ foreach ($devices as $device) {
+ file_get_contents('https://' . $device . '.home.tortuga.enhydra.fr/');
+ }
+ }
}
-function cronHarmony($cronmin)
-{
- _logSection('Harmony');
- $currentActivity = getCurrentHarmonyActivity();
-
- if (!$currentActivity) {
- return;
- }
- if ($currentActivity == 'musique') {
- setPlaying('squeezebox', 'bureau');
- } else if ($currentActivity == 'poweroff' || $currentActivity == 'off') {
- setPlaying('mycanal', 'bureau');
- }
+function cronHarmony($cronmin) {
+ _logSection('Harmony');
+ $currentActivity = getCurrentHarmonyActivity();
+ if ($currentActivity == HARMONY_MUSIQUE) {
+ setPlaying('squeezebox', 'bureau');
+ } else if ($currentActivity == HARMONY_OFF) {
+ setPlaying('mycanal', 'bureau');
+ }
}
-function cronHeartbeat($cronmin, $devices = false)
-{
- _logSection('Heartbeat');
- setState('cron_heartbeat', time());
- domoticzCmd(null);
- squeezeRequest(null);
- hueCommand(null);
-
- if (!$devices || $cronmin % 5 != 0) {
- return;
- }
- restartDeadDevices();
+function cronHeartbeat($cronmin, $devices = false) {
+ _logSection('Heartbeat');
+ setState('cron_heartbeat', time());
+ domoticzCmd(null);
+ squeezeRequest(null);
+ hueCommand(null);
+
+ if (!$devices || $cronmin % 5 != 0) {
+ return;
+ }
+ restartDeadDevices();
}
-function cronKodi($cronmin)
-{
- _logSection('Kodi');
- kodiSyncPlayedStatus();
+function cronKodi($cronmin) {
+ _logSection('Kodi');
+ kodiSyncPlayedStatus();
}
\ No newline at end of file