From: vincent Date: Sat, 11 Dec 2021 06:51:07 +0000 (+0100) Subject: . X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=60d55213e964d7fafabf921e6cd55ca68598858d;p=tortuga-home.git . --- diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 549288a..406367f 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,34 +2,65 @@ - - - - - - + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + + + + diff --git a/config/bureau.php b/config/bureau.php index 6bf3440..198881a 100644 --- a/config/bureau.php +++ b/config/bureau.php @@ -4,7 +4,7 @@ config('ROOM', 'bureau'); config('SQUEEZEBOX_PLAYER', 'Bureau'); config('VIDEOPLAYER', 'mediarasp'); config('VOLUME_DEVICE', 'harmony'); -config('VOLUME_STEP', 2); +config('VOLUME_STEP', 3); config('SLEEPTYPE', 'screensaver'); config('SCREENSAVER', 'suncurve'); config('SLEEPSCREEN', 15); @@ -20,8 +20,8 @@ if (DISPLAYINTERFACE) { $c = bureau(); $shortcuts['lights'] = $c['all']; $favoriteslights = [ - ['type' => 'volume', 'volume' => '3%', 'increase' => '+', 'label' => ''], - ['type' => 'volume', 'volume' => '3%', 'increase' => '-', 'label' => ''], + ['type' => 'volume', 'volume' => config('VOLUME_STEP') . '%', 'increase' => '+', 'label' => ''], + ['type' => 'volume', 'volume' => config('VOLUME_STEP') . '%', 'increase' => '-', 'label' => ''], ]; $favoriteslights = array_merge($favoriteslights, $c['favorites']); diff --git a/config/cave.php b/config/cave.php index 1c8bf1b..3d14f18 100644 --- a/config/cave.php +++ b/config/cave.php @@ -5,28 +5,28 @@ config('SQUEEZEBOX_PLAYER', 'Cave'); config('SLEEPSCREEN', 30); config('SCREENSAVER_BRIGHTNESS', 100); config('SLEEPTYPE', 'screensaver'); -config('SCREENSAVER','weatherstation'); +config('SCREENSAVER', 'weatherstation'); config('VIDEOPLAYER', 'mediarasp-small'); config('TVPLAYER', 'mediarasp-small'); config('VOLUME', 60); config('VOLUME_DEVICE', 'Squeezebox'); -config('VOLUME_STEP',5); -config('HIDEMASK_TIMEOUT',250); -config('THEME','#978270'); +config('VOLUME_STEP', 5); +config('HIDEMASK_TIMEOUT', 250); +config('THEME', '#978270'); if (DISPLAYINTERFACE) { $c = cave(); $shortcuts['lights'] = $c['all']; - $nav=['home','lights','music','media','remote','switch','settings','alert','off']; + $nav = ['home', 'lights', 'music', 'media', 'remote', 'switch', 'settings', 'alert', 'off']; - include_once ROOT . '/config/music.php'; + include_once ROOT . '/config/music.php'; - $favoriteslights = [ - ['type' => 'volume', 'volume' => '5%', 'increase' => '+', 'label' => ''], - ['type' => 'volume', 'volume' => '5%', 'increase' => '-', 'label' => ''], - ]; - $favoriteslights[] = array_merge($allmusics['France Info'], array('volume' => 50)); + $favoriteslights = [ + ['type' => 'volume', 'volume' => config('VOLUME_STEP') . '%', 'increase' => '+', 'label' => ''], + ['type' => 'volume', 'volume' => config('VOLUME_STEP') . '%', 'increase' => '-', 'label' => ''], + ]; + $favoriteslights[] = array_merge($allmusics['France Info'], array('volume' => 50)); $favoriteslights = array_merge($favoriteslights, $c['favorites']); - include "media.php"; - include "default.php"; + include "media.php"; + include "default.php"; } \ No newline at end of file diff --git a/config/cuisine.php b/config/cuisine.php index 101b699..4018be0 100644 --- a/config/cuisine.php +++ b/config/cuisine.php @@ -15,8 +15,8 @@ if (DISPLAYINTERFACE) { $c = cuisine(); $favoriteslights = [ - ['type' => 'volume', 'volume' => '5%', 'increase' => '+', 'label' => ''], - ['type' => 'volume', 'volume' => '5%', 'increase' => '-', 'label' => ''], + ['type' => 'volume', 'volume' => config('VOLUME_STEP').'%', 'increase' => '+', 'label' => ''], + ['type' => 'volume', 'volume' => config('VOLUME_STEP').'%', 'increase' => '-', 'label' => ''], ]; $favoriteslights = array_merge($favoriteslights, $c['favorites']); diff --git a/config/global.php b/config/global.php index 7ca4681..5346bde 100644 --- a/config/global.php +++ b/config/global.php @@ -18,6 +18,9 @@ define('HOMECONNECT_PASSWORD', 'YcR%vNmYnu%e$3dx2idM'); define('LATITUDE', 48.8758392); define('LONGITUDE', 2.3422104); +define('NAS_ROOT', 'smb://192.168.13.1/1.42.6-25556/'); +define('NAS_PWD_ROOT', 'smb://Share:RQpZHMDLtbc229FQV3@192.168.13.1/1.42.6-25556/'); + $squeezeboxPlayers = array( 'Cave' => 'b8:27:eb:ab:b4:50', 'Salle de bains' => '9f:e3:5d:6e:15:35', @@ -35,7 +38,8 @@ $squeezeboxPlayers = array( 'Lit Vincent' => 'b8:27:eb:40:0e:e9', 'WC' => 'b8:27:eb:f6:1d:30', //'Bureau' => 'cc:cc:2d:2a:b5:35', - 'Bureau' => '7e:23:f6:33:1d:3b', + //'Bureau' => 'd6:12:01:da:63:f9', + 'Bureau' => '00:04:20:17:82:8b', ); @@ -47,17 +51,17 @@ $phones = [ ], 'cuisine' => [ 'ip' => '192.168.13.31', - 'key' => 'dmGYolpN-k4:APA91bEcMcfkZ0jZViEvyqyVWoT71-vQko9DE0wwg-vzPkZ5-lHwiVJDH38dXfIoWrHWTrtEiMsv-6TrebFR-dNOLhVoVUb3rCsehmLi-Ew17lkP75Yqds3KsWEiyF_yx-i-9dc_4ewV', + 'key' => 'f1rVkITIwwc:APA91bFMwnvK_H-SvFeAQb2i8jmZw2Vcv0xrt46ejSjwaOLhBo7OVS2CozF79HgxDf3qsTbHRxZ976VW8-9JtxCAjQTqOV6n6UkS7x6oFCLbwlnyQhm5JTGu9171Gt7k_Bi6WFVJ9cFd', 'password' => '4pyA?Rnyeyc1$44M' ], 'salon' => [ 'ip' => '192.168.13.30', - 'key' => 'dmGYolpN-k4:APA91bEcMcfkZ0jZViEvyqyVWoT71-vQko9DE0wwg-vzPkZ5-lHwiVJDH38dXfIoWrHWTrtEiMsv-6TrebFR-dNOLhVoVUb3rCsehmLi-Ew17lkP75Yqds3KsWEiyF_yx-i-9dc_4ewV', + 'key' => 'd9-9VKyjp9c:APA91bGjiqU5rE52O6GvkCSSENWSsTYI9uZPfWofwwDHIivks4dKZJNSa1ixCLXTSg99rtC5Ca5Yv9-J_DG3c8hdDUAa_W7cHCdjLPbKxDTEgvnVBWgm9NLWCKG5KGmd5evkHuA3ZLzO', 'password' => '4pyA?Rnyeyc1$44M' ], 'sdb' => [ 'ip' => '192.168.13.32', - 'key' => 'dmGYolpN-k4:APA91bEcMcfkZ0jZViEvyqyVWoT71-vQko9DE0wwg-vzPkZ5-lHwiVJDH38dXfIoWrHWTrtEiMsv-6TrebFR-dNOLhVoVUb3rCsehmLi-Ew17lkP75Yqds3KsWEiyF_yx-i-9dc_4ewV', + 'key' => 'dcJ4TswVcXA:APA91bETlTCSE4HXOU-KiR2Hr6RdT6VwqsOcYl4XOpA-vLIs_qWT7zu8bRD9w4LXWdBYzn2iVZyGvQlBaU2KReJ62xe-H7oGuT93LbsZN20Az1oUxCgbjgLbcQ4WygEKBtoLa_WuQM1l', 'password' => '4pyA?Rnyeyc1$44M' ] //dOQilKX5CVQ:APA91bGOo1g2Hk2p7A4qYNg0wuKjvDeU3quKi6r73ae6rxVqSXmztMIDRn00DOZmXP1q1fBS0hLEd7xZo_Rr3LQMrRIHJpgy0FxnH7G_OV3kxFmGqWu1yOg5tBUEPlEybH_JkjlEgGof @@ -88,7 +92,7 @@ $devices = [ 'bureausun' => ['id' => 'bureausun', 'host' => '192.168.13.70', 'shield' => '192.168.13.41', 'user' => 'pi', 'password' => 'atacama'], 'lit' => ['id' => 'lit', 'host' => '192.168.13.69', 'user' => 'pi', 'password' => 'atacama'], 'sdb' => ['id' => 'sdb', 'shield' => '192.168.13.32'], - 'avion' => ['id' => 'avion', 'host' => '192.168.13.5', 'user' => 'Tortuga', 'password' => 's77vpo*wu', 'mac' => 'E0:D5:5E:68:67:B9'], + 'avion' => ['id' => 'avion', 'host' => '192.168.13.5', 'user' => 'Tortuga', 'password' => '8nc4PuwzCScw&^Vi$Fh#&n', 'mac' => 'E0:D5:5E:68:67:B9'], ]; // Browse media files on NAS diff --git a/config/salon.php b/config/salon.php index 97a1816..19a39cf 100644 --- a/config/salon.php +++ b/config/salon.php @@ -5,21 +5,21 @@ config('SQUEEZEBOX_PLAYER', 'Salon'); config('VIDEOPLAYER', 'shield'); config('TVPLAYER', 'shield'); config('VOLUME_DEVICE', 'DenonAVR'); -config('VOLUME_STEP',2); +config('VOLUME_STEP', 2); config('VIDEOPLAYER_DEVICE', 'salon'); config('HIDEMASK_TIMEOUT', 250); -config('THEME','#d0a25b'); +config('THEME', '#d0a25b'); config('SLEEPSCREEN', 150); config('SCREENSAVER_BRIGHTNESS', 100); config('SLEEPTYPE', 'screensaver'); -config('SCREENSAVER','weatherstation'); +config('SCREENSAVER', 'weatherstation'); if (DISPLAYINTERFACE) { $c = salon(); $shortcuts['lights'] = $c['all']; $favoriteslights = [ - ['type' => 'volume', 'volume' => '3%', 'increase' => '+', 'label' => ''], - ['type' => 'volume', 'volume' => '3%', 'increase' => '-', 'label' => ''], + ['type' => 'volume', 'volume' => config('VOLUME_STEP') . '%', 'increase' => '+', 'label' => ''], + ['type' => 'volume', 'volume' => config('VOLUME_STEP') . '%', 'increase' => '-', 'label' => ''], ]; $favoriteslights = array_merge($favoriteslights, $c['favorites']); @@ -27,5 +27,5 @@ if (DISPLAYINTERFACE) { include "default.php"; include ROOT . "/config/media.php"; - $nav=['home','lights','music','media','remote','switch','fan','settings','alert','off']; + $nav = ['home', 'lights', 'music', 'media', 'remote', 'switch', 'fan', 'settings', 'alert', 'off']; } diff --git a/config/sdb.php b/config/sdb.php index 5215fbb..2de3cce 100644 --- a/config/sdb.php +++ b/config/sdb.php @@ -5,28 +5,28 @@ config('SQUEEZEBOX_PLAYER', 'Salle de bains'); config('SLEEPSCREEN', 30); config('SCREENSAVER_BRIGHTNESS', 100); config('SLEEPTYPE', 'screensaver'); -config('SCREENSAVER','weatherstation'); +config('SCREENSAVER', 'weatherstation'); config('VIDEOPLAYER', 'mediarasp-small'); config('TVPLAYER', 'mediarasp-small'); config('VOLUME', 60); config('VOLUME_DEVICE', 'Squeezebox'); -config('VOLUME_STEP',5); -config('HIDEMASK_TIMEOUT',250); -config('THEME','#92475c'); +config('VOLUME_STEP', 3); +config('HIDEMASK_TIMEOUT', 250); +config('THEME', '#92475c'); if (DISPLAYINTERFACE) { $c = sdb(); $shortcuts['lights'] = $c['all']; - $nav=['home','lights','music','media','remote','switch','settings','alert','off']; + $nav = ['home', 'lights', 'music', 'media', 'remote', 'switch', 'settings', 'alert', 'off']; - include_once ROOT . '/config/music.php'; + include_once ROOT . '/config/music.php'; - $favoriteslights = [ - ['type' => 'volume', 'volume' => '5%', 'increase' => '+', 'label' => ''], - ['type' => 'volume', 'volume' => '5%', 'increase' => '-', 'label' => ''], - ]; - $favoriteslights[] = array_merge($allmusics['France Info'], array('volume' => 50)); + $favoriteslights = [ + ['type' => 'volume', 'volume' => config('VOLUME_STEP') . '%', 'increase' => '+', 'label' => ''], + ['type' => 'volume', 'volume' => config('VOLUME_STEP') . '%', 'increase' => '-', 'label' => ''], + ]; + $favoriteslights[] = array_merge($allmusics['France Info'], array('volume' => 50)); $favoriteslights = array_merge($favoriteslights, $c['favorites']); - include "media.php"; - include "default.php"; + include "media.php"; + include "default.php"; } \ No newline at end of file diff --git a/config/settings.php b/config/settings.php index cfd1046..278403c 100644 --- a/config/settings.php +++ b/config/settings.php @@ -13,8 +13,8 @@ $rebootdevices = ['entree' => 'Entrée', 'sdb' => 'Salle de bains']; $shortcuts['settings'] = [ - ['type' => 'volume', 'volume' => '10%', 'increase' => '+', 'label' => ''], - ['type' => 'volume', 'volume' => '10%', 'increase' => '-', 'label' => ''], + ['type' => 'volume', 'volume' => config('VOLUME_STEP').'%', 'increase' => '+', 'label' => ''], + ['type' => 'volume', 'volume' => config('VOLUME_STEP').'%', 'increase' => '-', 'label' => ''], ['type' => 'action', 'action' => 'screen-off', 'label' => 'écran off'], ['type' => 'action', 'action' => 'sound-off', 'label' => 'sound off'], ['type' => 'action', 'action' => 'close', 'label' => 'Fermer'], diff --git a/config/wc.php b/config/wc.php index 58bc543..12340a0 100644 --- a/config/wc.php +++ b/config/wc.php @@ -3,20 +3,20 @@ config('ROOM_NAME', 'WC'); config('ROOM', 'wc'); config('SQUEEZEBOX_PLAYER', 'WC'); config('VOLUME', 60); -config('VOLUME_STEP',5); +config('VOLUME_STEP', 5); config('VOLUME_DEVICE', 'SqueezeboxPlayer'); -config('HIDEMASK_TIMEOUT',250); +config('HIDEMASK_TIMEOUT', 250); if (DISPLAYINTERFACE) { $c = wc(); $shortcuts['lights'] = $c['all']; - $nav=['home','lights','music','remote','switch','settings','alert','off']; + $nav = ['home', 'lights', 'music', 'remote', 'switch', 'settings', 'alert', 'off']; include_once ROOT . '/config/music.php'; $favoriteslights = [ - ['type' => 'volume', 'volume' => '5%', 'increase' => '+', 'label' => ''], - ['type' => 'volume', 'volume' => '5%', 'increase' => '-', 'label' => ''], + ['type' => 'volume', 'volume' => config('VOLUME_STEP') . '%', 'increase' => '+', 'label' => ''], + ['type' => 'volume', 'volume' => config('VOLUME_STEP') . '%', 'increase' => '-', 'label' => ''], ]; $favoriteslights = array_merge($favoriteslights, $c['favorites']); include "media.php"; diff --git a/images/earth.png b/images/earth.png new file mode 100644 index 0000000..7f089f6 Binary files /dev/null and b/images/earth.png differ diff --git a/images/suncurve.png b/images/suncurve.png new file mode 100644 index 0000000..c188847 Binary files /dev/null and b/images/suncurve.png differ diff --git a/js/home.js b/js/home.js index 330abab..061d79c 100644 --- a/js/home.js +++ b/js/home.js @@ -527,7 +527,7 @@ function screenOff() { if (lastOffScreen < Date.now() - 30000) { lastOffScreen = Date.now(); if (androidApp) { - phonetask('screenoff'); + //phonetask('screenoff'); } else { sshCommand('/usr/local/bin/screenoff'); } @@ -548,7 +548,7 @@ function screenOn(hidescreensaver) { hidescreensaver = true; } if (androidApp) { - phonetask('screenon'); + //phonetask('screenon'); } else { sshCommand('/usr/local/bin/screenon'); } diff --git a/scripts/app_token b/scripts/app_token index 69440af..56f6a0a 100644 --- a/scripts/app_token +++ b/scripts/app_token @@ -1 +1 @@ -4mC9Si6L2UFREW9CAyAgcrsH5stP8Qk/TEk6rCAIzzSrp2G2C872NKdz3RC5VWiA \ No newline at end of file +afcd7pJHR6fef3QNlBUysKWSpr5Axe1pTKa7+p9YGjYwGKYBP87xcnYE/hV+FYCb \ No newline at end of file diff --git a/scripts/cron/cron.php b/scripts/cron/cron.php index 239b97d..ac1ddd3 100644 --- a/scripts/cron/cron.php +++ b/scripts/cron/cron.php @@ -11,6 +11,7 @@ function cronOneLoop($cronmin) cronRooms($cronmin); //cronInsteon($cronmin); cronWeather($cronmin); + cronMagnet($cronmin); if ($cronmin % 5 == 0) { cronTraffic($cronmin, false); @@ -53,6 +54,12 @@ function cronOneLoop($cronmin) _logSection('End Loop (min:' . $cronmin . ')'); } +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'); @@ -119,16 +126,21 @@ function cronRooms($cronmin) { _logSection('Rooms'); if (getState('bureauAutoMode') == '1') { + _logSection('Bureau'); updateBureauAuto(); } if (getState('chambreAutoMode') == '1') { + _logSection('Chambre'); updateChambreAuto(); } if (getState('courAutoMode') == '1') { + _logSection('Cour'); updateCourAuto(); } + _logSection('Planetarium'); checkPlanetarium(); if ($cronmin % 2) { + _logSection('WC VMC'); checkWCVMC(); } } @@ -177,7 +189,7 @@ function cronPing($cronmin) { _logSection('Pings'); global $devices; - setState('vincenthere', ping('192.168.13.31', 5) ? '1' : '0'); + 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) { $result = ping($device['host'], 3, 22) ? '1' : '0'; @@ -203,15 +215,6 @@ function cronSqueezeFavorites($cronmin) function cronSqueezeCheckPlayers($cronmin) { _logSection('Check squeezebox players'); -// $players = ['Salon' => 'salon', 'Bureau' => 'bureau']; -// foreach ($players as $player => $device) { -// if (getSqueezePlayerStatus($player) === -1) { -// if (!shieldPlayingVideo($device)) { -// shieldRunAppAndBackHome('sbplayer', $device, 1, true); -// sleep(5); -// } -// } -// } } function cronWeather($cronmin) @@ -249,6 +252,8 @@ function cronWeather($cronmin) $res['wc_humidity'] = toNumber(getDomoticzDeviceStatus(1502), true); $res['office_temp'] = toNumber(getDomoticzDeviceStatus(1496), 1); $res['office_humidity'] = toNumber(getDomoticzDeviceStatus(1497), true); + $res['cellar_humidity'] = toNumber(getDomoticzDeviceStatus(4818), true); + $res['cellar_temp'] = toNumber(getDomoticzDeviceStatus(4817), 1); $res['pressure'] = round($weather['Pressure']['Metric']['Value']); $res['pressureTendency'] = $weather['PressureTendency']['Code']; $res['precipitations24'] = round($weather['PrecipitationSummary']['Past24Hours']['Metric']['Value']); diff --git a/scripts/domoticz_device_event.php b/scripts/domoticz_device_event.php index 8232b81..5324b71 100644 --- a/scripts/domoticz_device_event.php +++ b/scripts/domoticz_device_event.php @@ -3,23 +3,24 @@ define('TIMELIMIT', 1); $_GET['im'] = '5'; -$wcSwitch = 6448; - -if ($_GET['device'] == 1033 || $_GET['device'] == 1476 || $_GET['device'] == 1478) { +if ($_GET['device'] == 4680 || $_GET['device'] == 1476 || $_GET['device'] == 1478 || $_GET['device'] == 4955) { $forceConfig = 'salon'; } -if ($_GET['device'] == $wcSwitch) { +if ($_GET['device'] == 1695) { $forceConfig = 'wc'; } -if ($_GET['device'] == 1478) { +if ($_GET['device'] == 4600) { $forceConfig = 'bureau'; } +if ($_GET['device'] == 4711) { + $forceConfig = 'sdb'; +} require_once "import.php"; if ($_GET['device'] == 480) { chambreToggle(); -} else if ($_GET['device'] == 1033 || $_GET['device'] == 1476) { +} else if ($_GET['device'] == 4680 || $_GET['device'] == 1476 || $_GET['device'] == 1478 || $_GET['device'] == 4955) { // Cube switch ($_GET['state']) { case 'Shake': @@ -52,9 +53,9 @@ if ($_GET['device'] == 480) { } } else if ($_GET['device'] == 1451) { domoticzSwitch(1450); -} else if ($_GET['device'] == $wcSwitch) { +} else if ($_GET['device'] == 1695) { $forceConfig = 'wc'; - switch (str_replace(' ', '_', $_GET['state'])) { + switch ($_GET['state']) { case 'Double_Click': execScene('wc/spa'); setState('wc', 1); @@ -67,7 +68,7 @@ if ($_GET['device'] == 480) { wcToggle(); break; } -} else if ($_GET['device'] == 1478) { +} else if ($_GET['device'] == 4600) { // Cube bureau switch ($_GET['state']) { case 'Shake': @@ -77,7 +78,7 @@ if ($_GET['device'] == 480) { execScene('bureau/rideaux/toggle'); break; case 'Flip_180': - execScene('bureau/auto'); + execScene('bureau/fan/toggle'); break; case 'Free_Fall': execScene('bureau/off'); @@ -92,14 +93,49 @@ if ($_GET['device'] == 480) { } break; case 'Clock_Wise': - volume(config('VOLUME_STEP'), '+'); + volume(config('VOLUME_STEP'), '+',); break; case 'Anti_Clock_Wise': volume(config('VOLUME_STEP'), '-'); break; case 'Tap': harmonyActivity('musique'); - squeezePlayByName('FIP', 'Bureau'); + $lastTap = getState('bureau_squeeze_tap', 0); + $musics = ['FIP', 'Samba']; + $i = ($lastTap + 1) % count($musics); + setState('bureau_squeeze_tap', $i); + squeezePlayByName($musics[$i], 'Bureau'); + break; + case 'Alert': + default: + break; + } +} else if ($_GET['device'] == 4711) { + // Cube SDB + switch ($_GET['state']) { + case 'Shake': + execScene('home/alert'); + break; + case 'Flip_90': + execScene('sdb/off'); + break; + case 'Flip_180': + execScene('sdb/on'); + break; + case 'Free_Fall': + off('sdb'); + break; + case 'Move': + //_remoteCmd('pause', 'salon'); + break; + case 'Clock_Wise': + volume(config('VOLUME_STEP'), '+'); + break; + case 'Anti_Clock_Wise': + volume(config('VOLUME_STEP'), '-'); + break; + case 'Tap': + squeezePlayByName('FIP', $squeezeboxPlayers['Salle de bains']); break; case 'Alert': default: diff --git a/scripts/domoticz_status.php b/scripts/domoticz_status.php index 222bc2a..8e59944 100644 --- a/scripts/domoticz_status.php +++ b/scripts/domoticz_status.php @@ -1,4 +1,5 @@ $type, 'data' => $res]; +$r = ['c' => $c, 'type' => $type, 'data' => $res]; +$r['paused'] = inWinsowsList('192.168.13.4', 'avion', 1); die(json_encode($r)); \ No newline at end of file diff --git a/scripts/import.php b/scripts/import.php index d30b8ad..c3a4e6b 100644 --- a/scripts/import.php +++ b/scripts/import.php @@ -8,6 +8,7 @@ if(defined('TIMELIMIT')){ } if (isset($_GET['delay'])) { + ignore_user_abort(true); set_time_limit($_GET['delay'] + 30); sleep($_GET['delay']); } diff --git a/scripts/lib/denon.php b/scripts/lib/denon.php index 9cd45e1..e085c40 100644 --- a/scripts/lib/denon.php +++ b/scripts/lib/denon.php @@ -14,6 +14,7 @@ function denon($on = false) function denonAVRVolume($volume, $increase = '') { $current = denonAVRGetVolume(); + echo '::' . $current . '::'; if ($increase === '+' || $increase === '-') { if ($increase === '+') { $volume += $current; @@ -23,6 +24,9 @@ function denonAVRVolume($volume, $increase = '') } $volume = min(80, max(0, round($volume))); if ($volume !== $current) { + if ($volume < 10) { + $volume = '0' . $volume; + } echo _denonTelnet('MV' . $volume); } return $current . '->' . $volume; @@ -74,6 +78,10 @@ function denonAVRInput($input, $setvolume = false) function denonAVRGetVolume() { $res = _denonTelnet('MV?'); + if (stristr($res, 'MVMAX')) { + return denonAVRGetVolume(); + } + echo '//' . $res . '//'; $res = substr($res, 2); if ($res > 100) { $res /= 10; @@ -125,30 +133,40 @@ function denonAVRGetPowerState() function _denonTelnet($cmd) { + $client = getDenonTelnetClient(); + profile('got denon telnet client for ' . $cmd); + $res = $client->execute($cmd); if ($res->isError()) { return false; } + profile('Denon telnet ' . $cmd); return trim($res->getResponseText()); } function denonAVROff() { - _denonTelnet('ZMOFF'); - _denonTelnet('Z2OFF'); - _denonTelnet('PWSTANDBY'); + profile('Denon AVR OFF'); + + if (denonAVRGetPowerState()) { + _denonTelnet('ZMOFF'); + } + //_denonTelnet('Z2OFF'); + //_denonTelnet('PWSTANDBY'); } function epson($on = true, $force = false) { + profile('Epson ' . $on); + $currentState = getState('EpsonPowerState', '0') === '1'; if (!$force && $currentState === $on) { return; } $cmd = $on ? 'PowerOn' : 'PowerOff'; echo 'Epson ' . $cmd . "\n"; - sshCommand('/usr/local/bin/ir Epson ' . $cmd, 'salon'); + sshCommand('/usr/local/bin/ir Epson ' . $cmd, 'salon', false, true); setState('EpsonPowerState', $on ? '1' : '0'); if ($currentState !== $on && $on) { sleep(30); @@ -160,10 +178,10 @@ function epson($on = true, $force = false) */ function getDenonTelnetClient() { - global $denonTelnetClient; - if (!isset($denonTelnetClient)) { - $denonTelnetClient = Graze\TelnetClient\TelnetClient::factory(); - $denonTelnetClient->connect('192.168.13.42:23', '', '', "\r", 2); - } + /** @var Graze\TelnetClient\TelnetClient $denonTelnetClient */ + $denonTelnetClient = Graze\TelnetClient\TelnetClient::factory(); + $denonTelnetClient->connect('192.168.13.42:23', '', '', "\r", 2); + $denonTelnetClient->setReadTimeout(2); + return $denonTelnetClient; } \ No newline at end of file diff --git a/scripts/lib/domoticz.php b/scripts/lib/domoticz.php index f8548ca..5599e52 100644 --- a/scripts/lib/domoticz.php +++ b/scripts/lib/domoticz.php @@ -41,6 +41,7 @@ function domoticzGetLevel($device) function domoticzCmd($command, $priority = false) { + $redis = connectRedis(); $queue_name = 'domoticz_queue'; @@ -63,7 +64,6 @@ function getDomoticzDeviceStatus($device, $force = false, $key = 'Data') //echo ':)'; $res = runDomoticzCommand(['type' => 'devices', 'rid' => $device]); $res = json_decode($res->getBody(), true); - // print_r($res); try { $update = new DateTime($res['result'][0]['LastUpdate']); $now = new DateTime(); diff --git a/scripts/lib/flowerpower.php b/scripts/lib/flowerpower.php index e13e8e1..2d671c3 100644 --- a/scripts/lib/flowerpower.php +++ b/scripts/lib/flowerpower.php @@ -1,7 +1,7 @@ 1467, 0 => 1468]; diff --git a/scripts/lib/freebox.php b/scripts/lib/freebox.php index e99a28d..c088c11 100644 --- a/scripts/lib/freebox.php +++ b/scripts/lib/freebox.php @@ -1,50 +1,26 @@ '; - sleep($p); - continue; - } - echo $key . "
"; - httpRequest('http://192.168.13.2/pub/remote_control', 'GET', ['code' => '42472024', 'key' => $key]); - } + unlink('app_token'); + $freeboxAPI = new \alphayax\freebox\utils\Application(FREEBOX_APP_ID, FREEBOX_APP_NAME, FREEBOX_APP_VERSION); + $freeboxAPI->authorize(); + $freeboxAPI->openSession(); + return $freeboxAPI->getAppToken(); } function getFreeboxAPIInstance() { global $freeboxAPI; if (!isset($freeboxAPI)) { - $freeboxAPI = new \alphayax\freebox\utils\Application('tortuga.home', 'Tortuga home', '0.0.1'); - $freeboxAPI->setAppToken('4mC9Si6L2UFREW9CAyAgcrsH5stP8Qk/TEk6rCAIzzSrp2G2C872NKdz3RC5VWiA'); + $freeboxAPI = new \alphayax\freebox\utils\Application(FREEBOX_APP_ID, FREEBOX_APP_NAME, FREEBOX_APP_VERSION); + $freeboxAPI->setAppToken('afcd7pJHR6fef3QNlBUysKWSpr5Axe1pTKa7+p9YGjYwGKYBP87xcnYE/hV+FYCb'); $freeboxAPI->openSession(); } return $freeboxAPI; @@ -59,4 +35,40 @@ function freeboxResetWifi() sleep(5); $wifi->setConfiguration(new \alphayax\freebox\api\v3\models\WiFi\GlobalConfig(['enabled' => true])); +} + +function freeboxAddMagnet($url) +{ + echo $url; + $download = new alphayax\freebox\api\v3\services\download\Download(getFreeboxAPIInstance()); + $download->addFromUrl($url); +} + +function freeboxWOL($mac, $password = '') +{ + $freebox = getFreeboxAPIInstance(); + $rest = new RestAuth($freebox->getFreeboxApiHost() . '/api/v4/lan/wol/pub/'); + $rest->setSessionToken($freebox->getSessionToken()); + $rest->POST(['mac' => $mac, 'password' => $password]); +} + +function freeboxWatchMagnets() +{ + $dir = '/nas/Téléchargements/Watch'; + $dr = opendir($dir); + while ($f = readdir($dr)) { + if ($f == '.' || $f == '..' || !stristr($f, '.magnet')) { + continue; + } + try { + $file = $dir . '/' . $f; + freeboxAddMagnet(file_get_contents($file)); + unlink($file); + } catch (Exception $e) { + if (stristr($e->getMessage(), '(exists)')) { + unlink($file); + } + echo $e->getMessage(); + } + } } \ No newline at end of file diff --git a/scripts/lib/harmony.php b/scripts/lib/harmony.php index 81b5eb9..66926c2 100644 --- a/scripts/lib/harmony.php +++ b/scripts/lib/harmony.php @@ -5,8 +5,7 @@ function harmonyRequest($uri, $method = 'GET', $hub = 'bureau') { global $harmonyClient; - $ip = '192.168.13.7'; - + $ip = 'harmonyapi.home.tortuga.enhydra.fr'; $uri = 'http://' . $ip . ':8282/hubs/' . $hub . '/' . ltrim($uri, '/'); if (null == $harmonyClient) { @@ -43,7 +42,7 @@ function harmonyActivity($activity) if ($activity !== 'off' && $activity !== 'poweroff') { ecoMode('0'); } - if ($activity === 'musique' || $activity === 'tv') { + if ($activity === 'tv') { shieldWakeup('bureau'); } $res = harmonyRequest('activities/' . $activity, 'POST'); diff --git a/scripts/lib/http.php b/scripts/lib/http.php index 9548190..6fb42c7 100644 --- a/scripts/lib/http.php +++ b/scripts/lib/http.php @@ -62,6 +62,5 @@ function httpRequest($url, $method = 'get', $data = [], $auth = null, $timeout = $options['headers'] = $headers; $res= $client->request($method, $url, $options); - print_r($res); return $res; } \ No newline at end of file diff --git a/scripts/lib/hue.php b/scripts/lib/hue.php index 5d00583..c20ac36 100644 --- a/scripts/lib/hue.php +++ b/scripts/lib/hue.php @@ -17,7 +17,7 @@ function getHueState() return array('groups' => $hue->getGroups(), 'scenes' => $hue->getScenes(), 'lights' => $hue->getLights()); } -function hueCommand($action, $transitionTime) +function hueCommand($action, $transitionTime = null) { $redis = connectRedis(); $queue = $redis->igbget('hue_queue'); diff --git a/scripts/lib/kodi.php b/scripts/lib/kodi.php index f211d52..4290178 100644 --- a/scripts/lib/kodi.php +++ b/scripts/lib/kodi.php @@ -1,6 +1,6 @@ '192.168.13.40', 'bureau' => '192.168.13.41', 'avion' => '192.168.13.5', 'cuisine' => '192.168.13.32']; +$kodiIP = ['salon' => '192.168.13.40', 'bureau' => '192.168.13.41', 'avion' => '192.168.13.5', 'cuisine' => '192.168.13.31', 'sdb' => '192.168.13.32']; $_tvshowallstatus = null; $_koditotmdb = null; @@ -9,7 +9,7 @@ function getKodiDBConnection() return mysqli_connect('kodidb.home.tortuga.enhydra.fr', "kodi", "atacama", "MyVideos119"); } -function kodiGetAllKodiToTmdb($force=false) +function kodiGetAllKodiToTmdb($force = false) { global $_koditotmdb; if ($force || null === $_koditotmdb) { @@ -32,7 +32,7 @@ function kodiGetAllKodiToTmdb($force=false) return $_koditotmdb; } -function kodiGetTVShowAllStatus($force=false) +function kodiGetTVShowAllStatus($force = false) { global $_tvshowallstatus; @@ -99,16 +99,30 @@ function kodiSyncPlayedStatus() $seen = connectRedis()->igbget('mediaseen'); $seenChanged = false; + $useen = []; + + foreach ($seen as $item => $true) { + $useen[_normalizeSeenFile($item)] = true; + } + + connectRedis()->igbset('mediaseen', $useen); + $seen = $useen; + $result = mysqli_query($con, 'SELECT * FROM path'); $paths = []; while ($path = $result->fetch_assoc()) { - $paths[$path['idPath']] = str_replace('nfs://192.168.13.3/', '/', $path['strPath']); + $p = _normalizeSeenFile($path['strPath']); + + $paths[$path['idPath']] = $p; } $result = mysqli_query($con, 'SELECT * FROM files'); $files = []; $playCounts = []; while ($file = $result->fetch_assoc()) { + if (!isset($paths[$file['idPath']])) { + continue; + } $filename = $paths[$file['idPath']] . $file['strFilename']; $files[$filename] = $file['idFile']; $playCounts[$filename] = $file['playCount']; @@ -142,6 +156,17 @@ function kodiSyncPlayedStatus() } } +function _normalizeSeenFile($p) +{ + $p = str_replace('nfs://192.168.13.3/', '/', $p); + $p = str_replace(NAS_ROOT, '/volume1/Share/', $p); + $p = str_replace(NAS_PWD_ROOT, '/volume1/Share/', $p); + $p = str_replace('smb://Share:dcfyjbcyckwydtgufjx@192.168.13.4/Share//', '/volume1/Share/', $p); + $p = str_replace('smb://nas.home.tortuga.enhydra.fr/1.42.6-25556/', '/volume1/Share/', $p); + $p = str_replace('.x264.', '.', $p); + return $p; +} + function tmdbToKodiId($tmdbId, $type = 'tvshow') { $result = mysqli_query(getKodiDBConnection(), 'SELECT `media_id` FROM `uniqueid` WHERE `value`="' . $tmdbId . '" AND `type`="tmdb"'); diff --git a/scripts/lib/lib.php b/scripts/lib/lib.php index 0fd8a87..a529cbd 100644 --- a/scripts/lib/lib.php +++ b/scripts/lib/lib.php @@ -48,6 +48,7 @@ require_once ROOT . '/scripts/lib/shield.php'; require_once ROOT . '/scripts/lib/kodi.php'; require_once ROOT . '/scripts/lib/climacell.php'; require_once ROOT . '/scripts/lib/homeconnect.php'; +require_once ROOT . '/scripts/lib/wol.php'; profile('Loaded libraries', __FILE__, __LINE__); @@ -72,6 +73,9 @@ function shutdown() function getCurrentConfig() { global $forceConfig; + + $ips = ['192.168.13.31' => 'cuisine', '192.168.13.30' => 'salon', '192.168.13.32' => 'sdb']; + if (!isset($forceConfig) && isset($_SERVER['HTTP_HOST']) && stristr($_SERVER['HTTP_HOST'], '.home.tortuga.enhydra.fr')) { $e = explode('.', $_SERVER['HTTP_HOST']); $_GET['c'] = array_shift($e); @@ -83,15 +87,23 @@ function getCurrentConfig() $expires = time() + 60 * 60 * 24 * 30; if (isset($_GET['c'])) { - setcookie('homeconfig', $_GET['c'], $expires, '/', 'enhydra.fr'); + if (!headers_sent()) { + setcookie('homeconfig', $_GET['c'], $expires, '/', 'enhydra.fr'); + } $_COOKIE['homeconfig'] = $_GET['c']; } if (!isset($_COOKIE['homeconfig'])) { + + if (isset($ips[$_SERVER['REMOTE_ADDR']])) { + $c = $ips[$_SERVER['REMOTE_ADDR']]; + } else { + $c = 'salon'; + } if (!headers_sent()) { - setcookie('homeconfig', 'salon', $expires, '/', 'enhydra.fr'); + setcookie('homeconfig', $c, $expires, '/', 'enhydra.fr'); } - $_COOKIE['homeconfig'] = 'salon'; + $_COOKIE['homeconfig'] = $c; } return $_COOKIE['homeconfig']; } @@ -439,7 +451,7 @@ function ping($ip, $timeout = 5, $port = 1817) function volume($volume, $increase = '', $device = null) { $d = $device === null ? config('VOLUME_DEVICE') : $device; - echo $d.';'.$volume.';'.$increase; + echo $d . ';' . $volume . ';' . $increase; if ($increase == ' ') { $increase = '+'; @@ -469,7 +481,7 @@ function volume($volume, $increase = '', $device = null) case 'squeezebox': return squeezeVolume($volume, $increase, config('SQUEEZEBOX_PLAYER')); case 'harmony': - $lastHarmonyVolume = getState('last_harmony_volume', 0); + $lastHarmonyVolume = min(time(), getState('last_harmony_volume', 0)); $limit = time() - 2; if ($lastHarmonyVolume > $limit) { return; @@ -486,11 +498,11 @@ function volume($volume, $increase = '', $device = null) case 'vlc': return VLCCmd(['command' => 'volume', 'val' => $increase . '20'], $device); case 'denonavr': - return denonAVRVolume($volume,$increase); + return denonAVRVolume($volume, $increase); } } -function phoneTask($task, $phone, $encode = false) +function phoneTask($task, $phone, $encode = true) { global $phones; $p = $phones[$phone]; @@ -595,7 +607,7 @@ function makeNav($nav) 'music' => '
Musique & Radio
', 'media' => '
Medias & TV
', 'coffee' => '
Cuisine / Café
', - 'fan' => 'Ventilateur', + 'fan' => 'Ventilateur', 'remote' => '
Télécommande
', 'switch' => '
Changer de pièce
', 'clock' => '
Réveil
', diff --git a/scripts/lib/mediarasp.php b/scripts/lib/mediarasp.php index 2b42cd6..5913a8b 100644 --- a/scripts/lib/mediarasp.php +++ b/scripts/lib/mediarasp.php @@ -147,6 +147,8 @@ function remoteCmdMedia($cmd, $device = null, $playing = null) $device = config('DEVICE'); } + profile('remote cmd ' . $cmd . ' on ' . $device); + $map = ['play' => 'pl_pause', 'pause' => 'pl_pause', 'stop' => 'pl_stop', @@ -251,9 +253,9 @@ function remoteCmdSalonMusique($cmd) function mediaRaspPlayMovie($movie, $device = null) { - stopPlayersIn($device); setPlaying('mediarasp:' . $movie, $device); - mediaRaspCommons($device); + + profile('mediaRaspPlayMovie ' . $movie, __FILE__, __LINE__); $m = explode('.', $movie); $ext = array_pop($m); @@ -263,25 +265,9 @@ function mediaRaspPlayMovie($movie, $device = null) $x264 = true; } $base = implode('.', $m); - $final = $base . '.srt'; - $srt = [$final, $base . '.fr.srt', $base . '.en.srt']; - - foreach ($srt as $srtfile) { - if (file_exists($srtfile)) { - $srtcontent = cleanUpSubtitle(file_get_contents($srtfile)); - - file_put_contents($final, $srtcontent); - - if ($x264) { - copy($final, $base . '.x264.srt'); - } - break; - } - } addSeen($movie); $res = VLCPlay($movie, $device); - mediaRaspPostPlay($device); setPlaying('mediarasp:' . $movie, $device); return $res; @@ -330,20 +316,11 @@ function mediaRaspCommons($device) } } -function mediaRaspPostPlay($device) -{ - $rasps = ['entree', 'bureausun', 'litvincent', 'litjerome', 'sdb']; - if (in_array($device, $rasps)) { - - } -} - function mediaRaspPlayStream($url, $device = null) { setPlaying('mediarasp:' . $url, $device); mediaRaspCommons($device); $res = VLCPlay($url, $device); - mediaRaspPostPlay($device); setPlaying('mediarasp:' . $url, $device); mediaRaspCommons($device); return $res; @@ -367,7 +344,6 @@ function mediaRaspPlayCast($castURL, $device = null) $dest = downloadYoutubeDL($castURL, $height, true, 'mkv'); getYoutubeDLMeta($castURL); $res = VLCPlay($dest, $device); - mediaRaspPostPlay($device); setPlaying('mediarasp:cast:' . $castURL); return $res; } diff --git a/scripts/lib/off.php b/scripts/lib/off.php index 6fb734c..6a44615 100644 --- a/scripts/lib/off.php +++ b/scripts/lib/off.php @@ -5,6 +5,7 @@ function off($device = null) if (null === $device) { $device = config('DEVICE'); } + profile('OFF ' . $device); commonOff($device); if ($device == 'bureau' || $device == 'bureausun') { offBureau(); diff --git a/scripts/lib/pc.php b/scripts/lib/pc.php index ce2a07e..6fe04fa 100644 --- a/scripts/lib/pc.php +++ b/scripts/lib/pc.php @@ -4,21 +4,25 @@ function wakeupPC($device) global $devices; $s = 'device_' . $device . '_awake'; - $ip = $devices[$device]['host']; - $mac = $devices[$device]['mac']; - `wakeonlan -i $ip $mac`; - if (getState($s) === '1') { - return; + wol($device); + + if (getState($s) == '0') { + sleep(10); } setState($s, '1'); - sleep(10); - sshCommand('"C:\Program Files\Scripts\wakeup.bat"', $device, false); + sshCommand('"C:\Program Files\Scripts\wakeup.bat"', $device, false, false); setState($s, '1'); } -function sleepPC($device,$force=false) +function shutdownPC($device, $force = false, $blocking = false) +{ + return sleepPC($device, $force, $blocking, 'shutdown'); +} + + +function sleepPC($device, $force = false, $blocking = false, $action = 'sleep') { $s = 'device_' . $device . '_awake'; if (!$force && getState($s) == '0') { @@ -26,12 +30,35 @@ function sleepPC($device,$force=false) return; } setState($s, '0'); - $res = sshCommand('"C:\Program Files\Scripts\sleep.bat"', $device, true,true); + $cmd = "C:\\Program Files\\Scripts\\$action.bat"; + $res = sshCommand('"' . $cmd . '"', $device, $blocking, false); setState($s, '0'); return $res; } function pcScreensProfile($profile, $device) { - sshCommand('"C:\Program Files (x86)\DisplayFusion\DisplayFusionCommand.exe" -monitorloadprofile "' . $profile . '"', $device, false, true); + sshCommand('"C:\Program Files (x86)\DisplayFusion\DisplayFusionCommand.exe" -monitorloadprofile "' . $profile . '"', $device, false, false); +} + +function listWindows($device, $tries = 1) +{ + $file = '/nas/Cache/Avion/windowslist.csv'; + for ($i = 0; $i < $tries; $i++) { + if (file_exists($file)) { + $r = @file_get_contents($file); + if ($r) { + setState('listwindows_avion', $r); + return $r; + } + } + sleep(3); + } + return getState('listwindows_avion'); +} + +function inWinsowsList($str, $device, $tries = 1) +{ + $list = listWindows($device, $tries); + return stristr($list, $str) !== false; } \ No newline at end of file diff --git a/scripts/lib/proc.php b/scripts/lib/proc.php index a039193..e86e348 100644 --- a/scripts/lib/proc.php +++ b/scripts/lib/proc.php @@ -128,8 +128,7 @@ class proc $t = mktime($hour, $min, $sec, $month, $day, date('Y')); $c = time(); - - $res = $t < $c - 5 || $t > $c; + $res = $t < $c - 15 || $t > $c; if ($res) { echo $c - $t . "\n"; } diff --git a/scripts/lib/profile.php b/scripts/lib/profile.php index 9f468df..d1084dd 100644 --- a/scripts/lib/profile.php +++ b/scripts/lib/profile.php @@ -1,17 +1,21 @@ '', 'artwork' => '']; - $file = str_replace('smb://Share:dcfyjbcyckwydtgufjx@192.168.13.4/Share/', '/volume1/Share', $source); - $file = str_replace('/nas', '/volume1/Share', $file); + $file = str_replace(NAS_ROOT, '/volume1/Share/', $source); + $file = str_replace(NAS_PWD_ROOT, '/volume1/Share/', $file); + $file = str_replace('/nas/', '/volume1/Share/', $file); + $res['title'] = $file; + if (file_exists($file . '.tmdb.id')) { $id = file_get_contents($file . '.tmdb.id'); if (intval($id) > 0) { diff --git a/scripts/lib/router.php b/scripts/lib/router.php index eeb8445..41b50d8 100644 --- a/scripts/lib/router.php +++ b/scripts/lib/router.php @@ -2,17 +2,17 @@ function routerDevicesList() { - try { - $res = httpRequest('http://192.168.13.1/status-devices.asp', 'get', ['_' => time()], ['admin', 'BDQw479qbJST4u']); - } catch (Exception $e) { - return []; - } - // echo $res->getBody(); - if (preg_match('/dhcpd_lease = ([^;]+);/m', $res->getBody(), $dhcp)) { - if (preg_match_all('/192\.168\.13\.[0-9]{1,3}/', $dhcp[1], $matches)) { - return $matches[0]; - } - } +// try { +// $res = httpRequest('http://192.168.13.1/status-devices.asp', 'get', ['_' => time()], ['admin', 'BDQw479qbJST4u']); +// } catch (Exception $e) { +// return []; +// } +// // echo $res->getBody(); +// if (preg_match('/dhcpd_lease = ([^;]+);/m', $res->getBody(), $dhcp)) { +// if (preg_match_all('/192\.168\.13\.[0-9]{1,3}/', $dhcp[1], $matches)) { +// return $matches[0]; +// } +// } return []; } diff --git a/scripts/lib/scenes.php b/scripts/lib/scenes.php index ddd0537..e513067 100644 --- a/scripts/lib/scenes.php +++ b/scripts/lib/scenes.php @@ -21,7 +21,7 @@ $bedlowscreenbrightness = 12; $home = 15; $alert = 16; -$chambrefan = 2724; +$chambrefan = 4616; $scenes = [ 'chambre/matin' => [ @@ -61,7 +61,7 @@ $scenes = [ ['type' => 'nightmode', 'mode' => '1'], ['type' => 'ecomode', 'mode' => '1'], ['type' => 'state', 'key' => 'chambre', 'value' => 0], - ['type' => 'scene', 'scene' => 'chambre/rideaux/close'], + ['type' => 'function', 'function' => 'chambreRideaux', 'args' => [false]], //['type' => 'insteon', 'command' => '0?1131=I=0=0'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [$bedlowscreenbrightness]], ['type' => 'scene', 'scene' => 'chambre/deshumidificateur/off'], @@ -82,6 +82,7 @@ $scenes = [ ['type' => 'scene', 'scene' => 'chambre/deshumidificateur/off'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [$bedlowscreenbrightness]], ['type' => 'scene', 'scene' => 'chambre/cheminee/off'], + ['type' => 'scene', 'scene' => 'chambre/cheminee/off', 'delay' => 2], ], 'chambre/sleep/off' => [ ['type' => 'scene', 'scene' => 'chambre/bed/base'], @@ -94,7 +95,7 @@ $scenes = [ ['type' => 'state', 'key' => 'chambre', 'value' => 0], //['type' => 'insteon', 'command' => '0?1332=I=0=0'], // Lustre et tableau off ['type' => 'function', 'function' => 'bedbrightness', 'args' => [$bedlowscreenbrightness]], - ['type' => 'scene', 'scene' => 'chambre/rideaux/close'], + ['type' => 'function', 'function' => 'chambreRideaux', 'args' => [false]], ['type' => 'scene', 'scene' => 'sdb/off'], ['type' => 'scene', 'scene' => 'chambre/planetarium/on'], // Planétarium on ['type' => 'scene', 'scene' => 'chambre/deshumidificateur/off'], @@ -285,31 +286,22 @@ $scenes = [ ['type' => 'hue', 'light' => $litvincent, 'scene' => array('on' => true, 'brightness' => 0, 'hue' => '46920', 'saturation' => 255, 'transitionTime' => 0)], ['type' => 'hue', 'light' => $litvincent, 'scene' => array('brightness' => 128, 'colorTemp' => 156, 'transitionTime' => 60 * 60)], ], -// 'chambre/rideaux/west/open' => [ -// ['type' => 'insteon', 'command' => '3?02622013CB0F11FF=I=3'], -// ], -// 'chambre/rideaux/west/close' => [ -// ['type' => 'insteon', 'command' => '3?02622013CB0F1300=I=3'], -// ], -// 'chambre/rideaux/east/open' => [ -// ['type' => 'insteon', 'command' => '3?02622014690F1300=I=3'], -// ], -// 'chambre/rideaux/east/close' => [ -// ['type' => 'insteon', 'command' => '3?02622014690F11FF=I=3'], -// ], + 'chambre/rideaux/open' => [ - //['type' => 'domoticz', 'scene' => '3', 'command' => false, 'priority' => true], - ['type' => 'domoticz', 'device' => '1756', 'command' => 'Group Off', 'priority' => true], + ['type' => 'function', 'function' => 'chambreRideaux'], ], 'chambre/rideaux/close' => [ - //['type' => 'domoticz', 'scene' => '3', 'command' => true, 'priority' => true], - ['type' => 'domoticz', 'device' => '1756', 'command' => 'Group On', 'priority' => true], + ['type' => 'function', 'function' => 'chambreRideaux', 'args' => [false]], ], 'home/alert' => [ + ['type' => 'function', 'function' => 'alert',], + ], + 'home/doalert' => [ ['type' => 'domoticz', 'device' => '4207', 'command' => true, 'priority' => true], ['type' => 'hue', 'group' => $alert, 'scene' => ['alert' => 'lselect']], - ['type' => 'hue', 'group' => $alert, 'delay' =>3, 'scene' => ['alert' => 'none']], + ['type' => 'hue', 'group' => $alert, 'delay' => 3, 'scene' => ['alert' => 'none']], ['type' => 'phonetask', 'phone' => 'vincent', 'task' => 'Tortuga Alerte'], + ['type' => 'phonetask', 'phone' => 'sdb', 'task' => 'Tortuga Alerte'], ], 'home/aulit' => [ ['type' => 'scene', 'scene' => 'chambre/bed'], @@ -370,7 +362,7 @@ $scenes = [ ['type' => 'scene', 'scene' => 'salon/fan/off'], ], 'salon/cinemabase' => [ - // ['type' => 'scene', 'scene' => 'cuisine/tamise'], + // ['type' => 'scene', 'scene' => 'cuisine/tamise'], // ['type' => 'ecomode', 'mode' => '0'], // ['type' => 'insteon', 'command' => '0?1111=I=0=0'], ], @@ -418,12 +410,15 @@ $scenes = [ 'salon/fan/toggle' => [ ['type' => 'domoticz', 'device' => '478', 'command' => 'Toggle', 'priority' => true], ], - 'bureau/wakeuppc' => [ + 'bureau/pc/wakeup' => [ ['type' => 'function', 'function' => 'wakeupPC', 'args' => ['avion']], ], - 'bureau/sleeppc' => [ + 'bureau/pc/sleep' => [ ['type' => 'function', 'function' => 'sleepPC', 'args' => ['avion']], ], + 'bureau/pc/shutdown' => [ + ['type' => 'function', 'function' => 'shutdownPC', 'args' => ['avion']], + ], 'bureau/screens/off' => [ ['type' => 'function', 'function' => 'pcScreensProfile', 'args' => ['Games', 'avion']] ], @@ -437,21 +432,19 @@ $scenes = [ ['type' => 'domoticz', 'device' => '3529', 'command' => true, 'priority' => true], ], 'bureau/fan/toggle' => [ - ['type' => 'domoticz', 'device' => '3529', 'command' => 'Toggle', 'priority' => true], + ['type' => 'function', 'function' => 'harmonyDeviceCommand', 'args' => ['klarstein-whisperwind', 'power-toggle']], ], - 'bureau/auto' => [ ['type' => 'function', 'function' => 'bureauAuto', 'args' => [true]], ], 'bureau/base/on' => [ ['type' => 'ecomode', 'mode' => '0'], - ['type' => 'function', 'function' => 'wakeupPC', 'args' => ['avion']], + ['type' => 'scene', 'scene' => 'bureau/pc/wakeup'], ], 'bureau/cinema' => [ ['type' => 'scene', 'scene' => 'bureau/base/off'], ['type' => 'hue', 'group' => $bureau, 'scene' => '7mofVclWdtvpVyt'], ['type' => 'domoticz', 'scene' => 25, 'command' => true, 'priority' => true], - ], 'bureau/lumineux' => [ ['type' => 'hue', 'group' => $bureau, 'scene' => 'SdXwtZu5PCDjK2h'], @@ -583,15 +576,15 @@ $scenes = [ ], 'bureau/base/off' => [ + ['type' => 'domoticz', 'scene' => 42, 'command' => false, 'priority' => true], ['type' => 'function', 'function' => 'bureauAuto', 'args' => [false]], ['type' => 'state', 'key' => 'bureau_gradient', 'value' => 'off'], - ['type' => 'state', 'key' => 'bureau_gradient', 'value' => 'off'], - ['type' => 'scene', 'scene' => 'bureau/sleeppc'], + ['type' => 'hue', 'group' => $bureau, 'scene' => array('on' => false, 'brightness' => 0)], + ['type' => 'hue', 'light' => 23, 'scene' => array('on' => false, 'brightness' => 0)], ], 'bureau/off' => [ - ['type' => 'hue', 'group' => $bureau, 'scene' => array('on' => false, 'brightness' => 0)], - ['type' => 'domoticz', 'scene' => 42, 'command' => false, 'priority' => true], ['type' => 'scene', 'scene' => 'bureau/base/off'], + ['type' => 'scene', 'scene' => 'bureau/pc/sleep'], ], 'bureau/sound/on' => [ ['type' => 'domoticz', 'device' => 24, 'switchtype' => 'scene', 'command' => true, 'priority' => true], @@ -642,7 +635,7 @@ $scenes = [ //['type' => 'scene', 'scene' => 'cuisine/off'], ['type' => 'scene', 'scene' => 'salon/off'], ['type' => 'scene', 'scene' => 'cour/off'], - ['type' => 'scene', 'scene' => 'bureau/off'], + ['type' => 'scene', 'scene' => 'bureau/base/off'], ['type' => 'scene', 'scene' => 'chambre/off'], ['type' => 'scene', 'scene' => 'sdb/off'], ['type' => 'scene', 'scene' => 'wc/off'], @@ -653,6 +646,7 @@ $scenes = [ ['type' => 'phonetask', 'phone' => 'vincent', 'task' => 'Stop All Sounds'], ['type' => 'scene', 'scene' => 'chambre/planetarium/off'], ['type' => 'scene', 'scene' => 'cuisine/coffee/off'], + ['type' => 'scene', 'scene' => 'bureau/pc/shutdown'], ['type' => 'scene', 'scene' => 'home/hueoff'], ['type' => 'scene', 'scene' => 'salon/media/off'], ['type' => 'scene', 'scene' => 'salon/off', 'delay' => 2], @@ -662,7 +656,6 @@ $scenes = [ ['type' => 'scene', 'scene' => 'salon/on'], ['type' => 'scene', 'scene' => 'bureau/auto'], ['type' => 'scene', 'scene' => 'chambre/auto'], - ['type' => 'scene', 'scene' => 'chambre/rideaux/open'], ['type' => 'scene', 'scene' => 'sdb/on'], ['type' => 'scene', 'scene' => 'cour/auto'], ['type' => 'scene', 'scene' => 'chambre/deshumidificateur/on'], @@ -676,19 +669,19 @@ $scenes = [ ], 'wc/morning' => [ ['type' => 'hue', 'group' => $wc, 'scene' => 'NC5ejamHGUNURj8'], - ['type' => 'function', 'function' => 'squeezePlayByName', 'args' => ['FIP', $squeezeboxPlayers['WC'], 70, false]], + ['type' => 'function', 'function' => 'wcMusic', 'args' => [70]], ], 'wc/day' => [ ['type' => 'hue', 'group' => $wc, 'scene' => 'qfuu8z5QaJ6J26W'], - ['type' => 'function', 'function' => 'squeezePlayByName', 'args' => ['FIP', $squeezeboxPlayers['WC'], 80, false]], + ['type' => 'function', 'function' => 'wcMusic', 'args' => [80]], ], 'wc/evening' => [ ['type' => 'hue', 'group' => $wc, 'scene' => 'h82j28eNu6ZHVhM'], - ['type' => 'function', 'function' => 'squeezePlayByName', 'args' => ['FIP', $squeezeboxPlayers['WC'], 80, false]], + ['type' => 'function', 'function' => 'wcMusic', 'args' => [80]], ], 'wc/late' => [ ['type' => 'hue', 'group' => $wc, 'scene' => 'IGo4F5jRQXc1H95'], - ['type' => 'function', 'function' => 'squeezePlayByName', 'args' => ['FIP', $squeezeboxPlayers['WC'], 70, false]], + ['type' => 'function', 'function' => 'wcMusic', 'args' => [70]], ], 'wc/night' => [ ['type' => 'hue', 'group' => $wc, 'scene' => 'eJy09JTEzCiIL1P'], @@ -717,10 +710,10 @@ $scenes = [ ], 'sdb/ampli/on' => [ - ['type' => 'domoticz', 'device' => '1438', 'command' => true, 'priority' => true], + ['type' => 'domoticz', 'device' => '476', 'command' => true, 'priority' => true], ], 'sdb/ampli/off' => [ - ['type' => 'domoticz', 'device' => '1438', 'command' => false, 'priority' => true], + ['type' => 'domoticz', 'device' => '476', 'command' => false, 'priority' => true], ], 'sdb/off' => [ ['type' => 'state', 'key' => 'sdb', 'value' => 0], @@ -728,6 +721,7 @@ $scenes = [ ['type' => 'function', 'function' => 'stopSqueezeboxPlayer', 'args' => [$squeezeboxPlayers['Salle de bains'], false]], ], 'sdb/on' => [ + ['type' => 'state', 'key' => 'sdb', 'value' => 1], ['type' => 'state', 'key' => 'sdb', 'value' => 1], ['type' => 'domoticz', 'scene' => 20, 'command' => true, 'priority' => true], ], @@ -828,11 +822,30 @@ $scenes = [ ]; +function chambreRideaux($ouvre = true) +{ + $device = 1756; + $priority = true; + // ['type' => 'domoticz', 'device' => '1756', 'command' => 'Group Off', 'priority' => 'sync'], + if ($ouvre && getDomoticzDeviceStatus($device) === 'Off') { + return; + } + $cmd = $ouvre ? 'Group Off' : 'Group On'; + domoticzSwitch($device, $cmd, 'light', $priority); + if ($ouvre) { + usleep(1000000 * 4.7); + domoticzSwitch($device, $cmd, 'light', $priority); + } +} + function execScene($name, $fromUserAction = false, $transitionTime = null) { global $scenes; + $scene = $scenes[$name]; + profile('Exec scene ' . $name . '/' . $fromUserAction, __FILE__, __LINE__); + $e = explode('/', $name); if ($fromUserAction && $e[1] !== 'auto' && count($e) == 2) { @@ -900,7 +913,7 @@ function execScene($name, $fromUserAction = false, $transitionTime = null) $action['device'] = $action['scene']; $action['switchtype'] = 'scene'; } - domoticzSwitch($action['device'], $action['command'], isset($action['switchtype']) ? $action['switchtype'] : 'light', isset($action['priority']) && $action['priority']); + domoticzSwitch($action['device'], $action['command'], isset($action['switchtype']) ? $action['switchtype'] : 'light', $action['priority'] ?? false); } else if ($action['type'] == 'ir') { irsend($action['room'], $action['device'], $action['command']); } else if ($action['type'] == 'ifttt') { @@ -920,6 +933,17 @@ function chambreToggle() } } +function wcMusic($volume) +{ + if (date('w') == '5') { + $music = 'Samba'; + //$volume += 10; + } else { + $music = 'FIP'; + } + squeezePlayByName($music, 'WC', $volume, false); +} + function wcToggle() { if (getState('wc') == 1) { @@ -971,9 +995,13 @@ function planetarium($on) function checkPlanetarium($periodicOffCheck = true) { - $device = 1452; + $device = 4617; $on = getState('planetarium') == '1'; + $h = date('G'); + if ($h >= 2 && $h <= 20) { + $on = false; + } if ($on) { if ($periodicOffCheck) { $min = intval(date('i')); @@ -1079,17 +1107,6 @@ function chambreAuto($on = true, $transitionTime = null) updateChambreAuto($transitionTime); } else if (getState('chambreAutoMode') === '1') { setState('chambreAutoMode', '0'); - try { - if (isset($_SERVER['REQUEST_URI'])) { - $r = $_SERVER['REQUEST_URI']; - } else if (php_sapi_name() === 'cli') { - $r = 'cli '; - } - throw new Error('Setting chambre auto mode to false in ' . $r); - } catch (Error $e) { - $log = ROOT . '/log/chambreautooff.log'; - file_put_contents($log, file_get_contents($log) . "\n\n" . date('Y-m-d H:i:s') . "\n" . $e->getMessage() . "\n" . $e->getTraceAsString()); - } } } @@ -1214,4 +1231,54 @@ function delayScene($scene, $delay) $timeout = $delay + 30; $url = WEB_ROOT . 'scripts/light.php?delay=' . $delay . '&scene=' . $scene . '&sid=' . session_id(); return delayHttpCall($url, $timeout); +} + +function alert() +{ + if (getNightMode()) { + return; + } + + execScene('home/doalert'); + + $rep = 1 * 2; + $domoticzDevices = [4016, 4017, 4033, 4201, 4202, 4203, 4204, 4205, 4614, 4622]; + $domoticzStates = []; + + foreach ($domoticzDevices as $domoticzDevice) { + $domoticzStates[$domoticzDevice] = getDomoticzDeviceStatus($domoticzDevice); + } + + for ($i = 0; $i < $rep; $i++) { + foreach ($domoticzDevices as $device) { + domoticzSwitch($device, 'Toggle', 'light', true); + } + } + + $hue = getHueInstance(); + $group = $hue->getGroups()[18]; + $allLights = $hue->getLights(); + $lights = []; + + foreach ($group->getLightIds() as $lightId) { + $lights[$lightId] = $allLights[$lightId]->isOn(); + } + + for ($i = 0; $i < $rep; $i++) { + $reverse = $i % 2 === 0; + foreach ($lights as $light => $state) { + hueCommand(['light' => $light, 'scene' => ['on' => $reverse ? !$state : $state]]); + } + } + + sleep(15); + + foreach ($lights as $lightId => $state) { + hueCommand(['light' => $lightId, 'scene' => ['on' => $state]]); + } + + foreach ($domoticzStates as $domoticzDevice => $domoticzState) { + domoticzSwitch($domoticzDevice, $domoticzState); + } + } \ No newline at end of file diff --git a/scripts/lib/shield.php b/scripts/lib/shield.php index 94aeb3c..ae733bb 100644 --- a/scripts/lib/shield.php +++ b/scripts/lib/shield.php @@ -38,11 +38,13 @@ function shieldRunActivity($device = null, $force = false) $device = getDevice($device); $onlySound = in_array(shieldGetCurrentApp($device), ['spotify']); + profile('Run activity for shield ' . $device); + if ($device['id'] === 'salon') { stopPlayersIn('salon', true, false); denonAVROn('Media Player', $force); - epson(true); execScene('salon/cinema'); + epson(true); } else if ($device['id'] === 'bureau' || $device['id'] === 'bureausun') { stopPlayersIn('bureau', true, false); if ($onlySound) { @@ -203,16 +205,18 @@ function shieldMyCanal($channel = false, $type = 'live', $device = null) function shieldKodi($file, $device = null) { + $url = shieldNormalizeURL($file); + profile('shield kodi ' . $file . '//' . $url, __FILE__, __LINE__); shieldRunActivity($device); shieldHome($device); - shieldCommand('shell am start', '-a android.intent.action.VIEW -d \'"' . shieldNormalizeURL($file) . '"\' -n org.xbmc.kodi/.Splash', $device); + shieldCommand('shell am start', '-a android.intent.action.VIEW -d \'"' . $url . '"\' -n org.xbmc.kodi/.Splash', $device); } function shieldNormalizeURL($input) { if (strpos($input, '/nas') === 0) { $input = str_replace('/nas/', '/', $input); - return 'smb://Share:dcfyjbcyckwydtgufjx@192.168.13.4/Share/' . $input; + return NAS_ROOT . $input; } return $input; } @@ -267,6 +271,8 @@ function shieldGetApps() 'sbplayer' => 'com.angrygoat.android.sbplayer', 'spotify' => 'com.spotify.tv.android', 'steamlink' => 'com.valvesoftware.steamlink', + 'squeezeplayer' => 'de.bluegaspode.squeezeplayer', + 'tortuga' => 'fr.enhydra.tortuga.home', ]; } @@ -280,9 +286,8 @@ function shieldRunAppAndBackHome($app, $device = null, $waitBeforeBack = 1, $bac { if (shieldIsAwake($device)) { $backToSleep = false; - } else { - shieldWakeup($device); } + shieldWakeup($device); if ($backToSleep) { $d = getDevice($device); $s = 'maskShield' . ucfirst($d['id']) . 'Wakeup'; @@ -328,9 +333,12 @@ function shieldShareIntent($content, $device = null) function shieldLogcat($cases = [], $device = null) { + $cmd = _adbcmd('logcat', '', $device); + + `pkill -f "$cmd"`; shieldConnect(false, $device); $proc = new proc(); - $cmd = _adbcmd('logcat', '', $device); + echo $cmd . "\n"; $proc->open($cmd); $proc->on($cases); @@ -363,6 +371,7 @@ function _adb($command, $params = '', $device = null) return $output; } + function _adbcmd($command, $params, $device = null) { $device = getDevice($device); diff --git a/scripts/lib/squeezebox.php b/scripts/lib/squeezebox.php index cd0ca34..b2a98a6 100644 --- a/scripts/lib/squeezebox.php +++ b/scripts/lib/squeezebox.php @@ -8,6 +8,7 @@ function stopSqueezeboxPlayer($player, $stopIfSync = true, $devices = true) return; } + squeezeRequest('sync -', $player); squeezeRequest('stop', $player); squeezeRequest('power 0', $player); @@ -15,7 +16,7 @@ function stopSqueezeboxPlayer($player, $stopIfSync = true, $devices = true) if ($devices) { $room = getRoomBySqueezeboxPlayer($player); if ($room == 'salon') { - + denonAVROff(); } else if ($room === 'sdb') { execScene('sdb/ampli/off'); } else if ($room === 'bureau') { @@ -26,6 +27,7 @@ function stopSqueezeboxPlayer($player, $stopIfSync = true, $devices = true) denon(false); } } + profile('stopped squeezebox player ' . $player); } function getRoomBySqueezeboxPlayer($player) @@ -58,8 +60,9 @@ function getSqueezePlayerStatus($player = '') return -1; } + print_r($res); if (!isset($res['result']) || !isset($res['result']['_mode'])) { - return false; + return -2; } return $res['result']['_mode'] == 'play' ? 1 : 0; } @@ -145,13 +148,21 @@ function squeezePlayerOn($player) global $squeezeboxPlayers; $player = _player($player); if ($player == $squeezeboxPlayers['Salon']) { - denonAVROn('HEOS Music'); + $state=denonAVRGetPowerState(); + denonAVROn('HEOS Music', false); + sleep(4); + if(!$state){ + denonAVROff(); + denonAVROn('HEOS Music', true); + } } else if ($player == $squeezeboxPlayers['Salle de bains']) { execScene('sdb/ampli/on'); + if (getSqueezePlayerStatus($player) < 0) { + phoneTask('Tortuga', 'sdb'); + } + } else if ($player == $squeezeboxPlayers['Bureau']) { - setState('maskShieldBureauWakeup', time() + 15); harmonyActivity('musique'); - shieldRunAppAndBackHome('sbplayer', 'bureau', 1, false); } else if ($player == $squeezeboxPlayers['Chambre']) { denon(true); } diff --git a/scripts/lib/ssh.php b/scripts/lib/ssh.php index d0a7d6a..cd37c80 100644 --- a/scripts/lib/ssh.php +++ b/scripts/lib/ssh.php @@ -55,7 +55,6 @@ function sshCommand($command, $device = null, $blocking = true, $sudo = false) function sshRunCommand($command, $device = null, $blocking = true, $sudo = false) { $ssh = getSSHInstance($device, $sudo); - print_r($ssh); if ($ssh) { $stream = @ssh2_exec($ssh, $command); if (!$stream) { diff --git a/scripts/lib/tmdb.php b/scripts/lib/tmdb.php index 2fcf0fa..83dc3bc 100644 --- a/scripts/lib/tmdb.php +++ b/scripts/lib/tmdb.php @@ -493,27 +493,56 @@ class moviesLibrary extends mediaLibrary public function getAlphaShortcuts() { $letters = []; + foreach (str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ') as $l) { + $letters[$l] = []; + } + foreach ($this->movies as $movie) { - $firstLetter = $this->_firstLetter($movie['data']['title']); - if (!isset($letters[$firstLetter])) { - $letters[$firstLetter] = []; + $firstLetters = $this->_firstLetters([$movie['data']['title'], $movie['data']['original_title']]); + foreach ($firstLetters as $firstLetter) { + if (!isset($letters[$firstLetter])) { + continue; + } + $letters[$firstLetter][] = $movie; } - $letters[$firstLetter][] = $movie; } - ksort($letters); - return $this->_makeSub($letters, 'movies-alpha-', 'Films par titre', 'poster'); } - protected function _firstLetter($title) + protected function _firstLetters($titles) { - $res = $this->remove_accents($title); - $res = trim($res, '\''); - $res = mb_substr($res, 0, 1); - $res = mb_strtoupper($res); - $res = preg_replace('|\d|', '#', $res); + $res = []; + $allTitles = []; + foreach ($titles as $title) { + $title = mb_strtolower($title); + $title = $this->remove_accents($title); + $title = trim($title, '\' '); + $allTitles[] = $title; + $allTitles[] = $this->_removeMeanlessWords($title); + } - return $res; + $allTitles = array_unique($allTitles); + foreach ($allTitles as $title) { + $letter = mb_substr($title, 0, 1); + $letter = mb_strtoupper($letter); + $letter = preg_replace('|\d|', '#', $letter); + $res[] = $letter; + } + + return array_unique($res); + } + + protected function _removeMeanlessWords($title) + { + $remove = ['un', 'une', 'le', 'la', 'l', 'the', 'a', 'der', 'die', 'das', 'ein', 'el', 'una']; + $e = preg_split('/(\s|\')/', mb_strtolower($title)); + $res = []; + foreach ($e as $item) { + if (!in_array($item, $remove)) { + $res[] = $item; + } + } + return implode(' ', $res); } protected function remove_accents($string) diff --git a/scripts/lib/weatherstation.php b/scripts/lib/weatherstation.php index 10d8650..b8ebd8e 100644 --- a/scripts/lib/weatherstation.php +++ b/scripts/lib/weatherstation.php @@ -29,8 +29,9 @@ function weatherStationScreenSaver() $res .= '' . $weather['livingroom_temp'] . ' °C' . $weather['livingroom_humidity'] . '%'; $res .= '' . $weather['office_temp'] . ' °C' . $weather['office_humidity'] . '%'; $res .= '' . $weather['wc_temp'] . ' °C' . $weather['wc_humidity'] . '%'; - $res .= '' . $weather['bedroom_temp'] . ' °C' . $weather['bedroom_humidity'] . '%'; - $res .= '' . $weather['bathroom_temp'] . ' °C' . $weather['bathroom_humidity'] . '%'; + $res .= '' . $weather['bedroom_temp'] . ' °C' . $weather['bedroom_humidity'] . '%'; + $res .= '' . $weather['bathroom_temp'] . ' °C' . $weather['bathroom_humidity'] . '%'; + $res .= '' . $weather['cellar_temp'] . ' °C' . $weather['cellar_humidity'] . '%'; $res .= ''; $res .= ''; $res .= '
'; diff --git a/scripts/mediarasp.php b/scripts/mediarasp.php index d6d7687..d5fecb3 100644 --- a/scripts/mediarasp.php +++ b/scripts/mediarasp.php @@ -16,7 +16,7 @@ if ($_GET['action'] == 'play') { echo getPlaying($_GET['device']); } -if ($_GET['small'] == 1) { +if (isset($_GET['small']) && $_GET['small'] == 1) { sleep(3); moveVLC(false); } \ No newline at end of file diff --git a/scripts/shield.php b/scripts/shield.php index b5969d7..7966ec5 100644 --- a/scripts/shield.php +++ b/scripts/shield.php @@ -1,38 +1,31 @@ '; if (isset($_GET['key'])) { - shieldKey($_GET['key']); + shieldKey($_GET['key'], $device); } else if (isset($_GET['netflix'])) { - shieldNetflix($_GET['netflix']); + shieldNetflix($_GET['netflix'], $device); } else if (isset($_GET['text'])) { - shieldText($_GET['text']); + shieldText($_GET['text'], $device); } else if (isset($_GET['action'])) { if ($_GET['action'] == 'apps') { - shieldListApps(); + shieldListApps($device); } else if ($_GET['action'] == 'currentApp') { - shieldGetCurrentApp(); + shieldGetCurrentApp($device); } } else if (isset($_GET['intents'])) { - shieldFindIntents($_GET['intents']); -} elseif (isset($_GET['tv'])) { - shieldTv($_GET['tv']); -} elseif (isset($_GET['live'])) { - shieldTv($_GET['live']); -} else if (isset($_GET['replay'])) { - shieldTv($_GET['replay'], 'replay'); + shieldFindIntents($_GET['intents'], $device); } else if (isset($_GET['vlc'])) { - shieldVLC($_GET['vlc']); + shieldVLC($_GET['vlc'], $device); } else if (isset($_GET['kodi'])) { - shieldKodi($_GET['kodi']); + shieldKodi($_GET['kodi'], $device); } else if (isset($_GET['mycanal'])) { $e = explode(':', $_GET['mycanal']); - shieldMyCanal($e[1], $e[0]); + shieldMyCanal($e[1], $e[0], $device); } else if (isset($_GET['runappback'])) { - shieldRunAppAndBackHome($_GET['runappback']); -}else if(isset($_GET['netflix'])){ - shieldNetflix(); + shieldRunAppAndBackHome($_GET['runappback'], $device); } echo ''; \ No newline at end of file diff --git a/scripts/sleeppc.php b/scripts/sleeppc.php index eb93ed2..8d2a208 100644 --- a/scripts/sleeppc.php +++ b/scripts/sleeppc.php @@ -1,3 +1,3 @@ function () use ($device) { echo 'wakeup ' . $device . "\n"; - if ($device == 'salon') { - $state = 'maskShieldSalonWakeup'; - $squeezePlayer = 'Salon'; - } else if ($device === 'bureau') { - $state = 'maskShieldBureauWakeup'; - $squeezePlayer = 'Bureau'; - } - if (getState($state, '0') < time() && getSqueezePlayerStatus($squeezePlayer) <= 0) { - shieldRunActivity($device,true); - } + shieldRunActivity(null, true); }, 'WindowManager: handleComboKeys keyCode: 25, keyAction: 1' => function () use ($device) { echo 'volume-down ' . $device . "\n"; - if ($device === 'bureau') { - volume('3', '-', 'harmony'); - } else if ($device === 'salon') { - volume('2', '-', 'denonavr'); - } + volume(config('VOLUME_STEP'), '-'); }, 'WindowManager: handleComboKeys keyCode: 24, keyAction: 1' => function () use ($device) { echo 'volume-up ' . $device . "\n"; - if ($device === 'bureau') { - volume('3', '+', 'harmony'); - } else if ($device === 'salon') { - volume('2', '+', 'denonavr'); - } + volume(config('VOLUME_STEP'), '+'); } ]; echo 'Run home server logcat ' . $device . "\n"; -while (true) { - shieldLogcat($cases, $device); - echo 'Logcat ended' . "\n----\n"; -} +shieldLogcat($cases, $device); +echo 'Logcat ended' . "\n----\n"; diff --git a/servers/logcatb.php b/servers/logcatb.php index 8b70ef8..ae915cc 100644 --- a/servers/logcatb.php +++ b/servers/logcatb.php @@ -1,4 +1,4 @@ -#!/usr/bin/php7.4 +#!/usr/bin/php