]> _ Git - tortuga-home.git/commitdiff
.
authorVincent <vincent@enhydra.fr>
Sat, 6 Feb 2021 19:34:20 +0000 (20:34 +0100)
committerVincent <vincent@enhydra.fr>
Sat, 6 Feb 2021 19:34:20 +0000 (20:34 +0100)
13 files changed:
.idea/workspace.xml
config/global.php
config/salon.php
scripts/denon.php
scripts/domoticz_device_event.php
scripts/lib/denon.php
scripts/lib/domoticz.php
scripts/lib/lib.php
scripts/lib/off.php
scripts/lib/proc.php
scripts/lib/shield.php
scripts/shield.php
servers/logcat.php

index 5bd1505adcd3e66ed812015050223bbc307c2ca3..c01197450626df77eabbef33db05a59f93552777 100644 (file)
@@ -3,8 +3,18 @@
   <component name="ChangeListManager">
     <list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
       <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$/scripts/lib/scenes.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/scenes.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/config/global.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/global.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/config/salon.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/salon.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/denon.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/denon.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/domoticz_device_event.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/domoticz_device_event.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/denon.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/denon.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/domoticz.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/domoticz.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/lib.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/lib.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/off.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/off.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/proc.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/proc.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/shield.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/shield.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/shield.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/shield.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/servers/logcat.php" beforeDir="false" afterPath="$PROJECT_DIR$/servers/logcat.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
       <workItem from="1611911107099" duration="542000" />
       <workItem from="1611951034456" duration="1202000" />
       <workItem from="1612025389189" duration="578000" />
-      <workItem from="1612099867183" duration="8220000" />
-    </task>
-    <task id="LOCAL-00397" summary=".">
-      <created>1605433424911</created>
-      <option name="number" value="00397" />
-      <option name="presentableId" value="LOCAL-00397" />
-      <option name="project" value="LOCAL" />
-      <updated>1605433424911</updated>
+      <workItem from="1612099867183" duration="8228000" />
+      <workItem from="1612347206766" duration="685000" />
+      <workItem from="1612620373278" duration="26000" />
+      <workItem from="1612620424202" duration="11592000" />
     </task>
     <task id="LOCAL-00398" summary=".">
       <created>1605436590375</created>
       <option name="project" value="LOCAL" />
       <updated>1612123146249</updated>
     </task>
-    <option name="localTasksCounter" value="446" />
+    <task id="LOCAL-00446" summary=".">
+      <created>1612199517377</created>
+      <option name="number" value="00446" />
+      <option name="presentableId" value="LOCAL-00446" />
+      <option name="project" value="LOCAL" />
+      <updated>1612199517377</updated>
+    </task>
+    <option name="localTasksCounter" value="447" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
index 596750a9374d97779c09b6aa12d7d113f63be954..b39776ca75a61078ccb9a62b8b5900877ae937c5 100644 (file)
@@ -17,7 +17,8 @@ $squeezeboxPlayers = array(
     'Salle de bains' => 'b8:27:eb:ab:b4:50',
     //'Salon' => 'dc:a6:32:02:47:c1',
     //'Salon' => 'cc:cc:2d:15:82:0e',
-    'Salon' => '5a:a1:4c:5c:e7:5e',
+    //'Salon' => '5a:a1:4c:5c:e7:5e',
+    'Salon' => 'bb:bb:78:49:8f:a4s',
     'Chambre' => 'b8:27:eb:31:e1:44',
     //'WC' => '00:04:20:2a:05:2e',
     //'WC' => 'b8:27:eb:78:f6:88',
index 96cbdc94164181ef0f946cb4502909a37674bd53..a24d718218ece62ed9548a9526223ab313bdeb68 100644 (file)
@@ -4,7 +4,7 @@ config('ROOM', 'salon');
 config('SQUEEZEBOX_PLAYER', 'Salon');
 config('VIDEOPLAYER', 'shield');
 config('TVPLAYER', 'shield');
-config('VOLUME_DEVICE', 'harmony');
+config('VOLUME_DEVICE', 'DenonAVR');
 config('VIDEOPLAYER_DEVICE', 'salon');
 config('HIDEMASK_TIMEOUT', 250);
 config('THEME','#7a6854');
index 13cb6615e0e6ccefe84681433fb8452a08c29c51..4cc566766d78fc20823f81d17bc3da7b28d6dff6 100644 (file)
@@ -1,3 +1,9 @@
 <?php
 require_once "import.php";
-setState('denon', '0');
\ No newline at end of file
+if(isset($_GET['avroff'])){
+    denonAVROff();
+}else if(isset($_GET['avron'])){
+    denonAVROn();
+}else {
+    setState('denon', '0');
+}
\ No newline at end of file
index 8b6a09fbfcdf64cbbf92e5c36a9f231a06bf9b21..35019034f51af13e0ab359528fab8d91fc354a17 100644 (file)
@@ -36,10 +36,10 @@ if ($_GET['device'] == 480) {
             _remoteCmd('pause', 'salon');
             break;
         case 'Clock_Wise':
-            volume(3, '+');
+            volume(2, '+');
             break;
         case 'Anti_Clock_Wise':
-            volume(3, '-');
+            volume(2, '-');
             break;
         case 'Tap':
             squeezePlayByName('FIP', $squeezeboxPlayers['Salon']);
@@ -82,9 +82,9 @@ if ($_GET['device'] == 480) {
             off('bureau');
             break;
         case 'Move':
-            if(getCurrentHarmonyActivity()==='tv'){
+            if (getCurrentHarmonyActivity() === 'tv') {
                 _remoteCmd('pause', 'bureau');
-            }else{
+            } else {
                 stopPlayersIn('bureau');
                 stopHarmony();
             }
index 3b83f210bd211feabb967f261c1a73d8abf4cfa8..b9c03d85ab428733e72320bd66d607b9570928c6 100644 (file)
@@ -7,4 +7,58 @@ function denon($on = false)
     }
     sshCommand('/usr/local/bin/denon-toggle', 'lit', true, true);
     setState('denon', $on ? '1' : '0');
+}
+
+function _denonAVR($command)
+{
+    $context = ['http' => ['method' => 'GET'], 'ssl' => ['verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true]];
+    $context = stream_context_create($context);
+    return file_get_contents('https://192.168.13.42:10443/ajax/globals/' . $command . '&_' . time(), false, $context);
+}
+
+function denonAVRVolume($volume, $increase = '')
+{
+    $device = 2894;
+    $current = domoticzGetLevel($device);
+    if ($increase === '+' || $increase === '-') {
+        if ($increase === '+') {
+            $volume += $current;
+        } else {
+            $volume = $current - $volume;
+        }
+    }
+    $volume = min(80, $volume);
+    domoticzSetLevel($device, $volume, true);
+    return $current . '->' . $volume;
+}
+
+function denonAVROn($input = 'Media Player')
+{
+    _denonAVR('set_config?type=4&data=' . rawurlencode('<MainZone><Power>1</Power></MainZone>'));
+    denonAVRInput($input);
+}
+
+function denonAVRInput($input)
+{
+    $map = ['Media Player' => 5, 'CD' => 9, 'HEOS Music' => 13];
+    $volumes = ['Media Player' => 40, 'HEOS Music' => 50, 'CD' => 30];
+    if (isset($map[$input])) {
+        _denonAVR('set_config?type=7&data=' . rawurlencode('<Source zone="1" index="' . $map[$input] . '"></Source>'));
+        sleep(1);
+    }
+    if (isset($volumes[$input])) {
+        denonAVRVolume($volumes[$input]);
+        sleep(1);
+    }
+}
+
+function denonAVROff()
+{
+    _denonAVR('set_config?type=4&data=' . rawurlencode('<MainZone><Power>3</Power></MainZone>'));
+}
+
+function epson($on = true)
+{
+    $cmd = $on ? 'PowerOn' : 'PowerOff';
+    sshCommand('/usr/local/bin/ir Epson ' . $cmd, 'salon');
 }
\ No newline at end of file
index 8dfd12b49a2e54b4a305a536f1f45eac80a481f6..d92df817c3453a4c49178d664f67405999496480 100644 (file)
@@ -23,12 +23,22 @@ function domoticzSwitch($device, $cmd, $type = 'light', $priority = false, $dela
     if ($cmd === 'Toogle' || $cmd === 'toogle' || $cmd === 'Toggle' || $cmd === 'toggle') {
         $cmd = 'Toggle';
     }
-    if(is_bool($cmd)) {
+    if (is_bool($cmd)) {
         $cmd = $cmd ? 'On' : 'Off';
     }
     return domoticzCmd(['idx' => $device, 'switchcmd' => $cmd, 'param' => 'switch' . $type, 'level' => '0', 'delay' => $delay], $priority);
 }
 
+function domoticzSetLevel($device, $level, $priority = false)
+{
+    return domoticzCmd(['idx' => $device, 'switchcmd' => 'Set Level', 'param' => 'switchlight', 'level' => max(0, min(100, $level))], $priority);
+}
+
+function domoticzGetLevel($device)
+{
+    return getDomoticzDeviceStatus($device, true, 'LevelInt');
+}
+
 function domoticzCmd($command, $priority = false)
 {
     $redis = connectRedis();
@@ -48,10 +58,12 @@ function domoticzCmd($command, $priority = false)
     return true;
 }
 
-function getDomoticzDeviceStatus($device, $force = false)
+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();
@@ -60,5 +72,5 @@ function getDomoticzDeviceStatus($device, $force = false)
         }
     } catch (Exception $e) {
     }
-    return $res['result'][0]['Data'];
+    return $res['result'][0][$key];
 }
index 61c834e1368306da644fb9b89f6e3ebedd66b976..1ff58cc5a733be0946a25a0451f3acc87912ee99 100644 (file)
@@ -437,6 +437,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;
 
     if ($increase == ' ') {
         $increase = '+';
@@ -482,6 +483,8 @@ function volume($volume, $increase = '', $device = null)
             }
         case 'vlc':
             return VLCCmd(['command' => 'volume', 'val' => $increase . '20'], $device);
+        case 'denonavr':
+            return denonAVRVolume($volume,$increase);
     }
 }
 
index 548f65caae3194d57aef7010657eb78dcc6f2ae0..f3d2d30d472481d0d5f13eaa9093246feaefc4cd 100644 (file)
@@ -25,6 +25,8 @@ function commonOff($device)
 
 function offSalon()
 {
+    epson(false);
+    denonAVROff();
     shieldKillAll('salon');
     shieldSleep('salon');
 }
index 733eacd9a7732155bbd05d6460fa3b9b99664e5d..a0391935d69b81c7ff7c30da8e7279aba5d80d6f 100644 (file)
@@ -103,12 +103,14 @@ class proc
 
     protected function _parseLine($line)
     {
-        if ($this->tooLate($line)) {
-            return;
-        }
+
 
         foreach ($this->_cases as $expected_text => $closure) {
             if (strpos($line, $expected_text)) {
+                if ($this->tooLate($line)) {
+                    echo 'too late ' . $line . "\n";
+                    return;
+                }
                 $closure();
             }
         }
@@ -126,6 +128,11 @@ class proc
         $t = mktime($hour, $min, $sec, $month, $day, date('Y'));
         $c = time();
 
-        return $t < $c - 5 || $t > $c;
+
+        $res = $t < $c - 5 || $t > $c;
+        if ($res) {
+            echo $c - $t . "\n";
+        }
+        return $res;
     }
 }
\ No newline at end of file
index 7c39ac3c940908b61679f28fb69aae0f22ec33f9..b69a7c0011a9dacc8027ca12d76973ea9a96ddf3 100644 (file)
@@ -40,7 +40,8 @@ function shieldRunActivity($device = null)
 
     if ($device['id'] === 'salon') {
         stopPlayersIn('salon', true, false);
-
+        epson(true);
+        denonAVROn();
     } else if ($device['id'] === 'bureau' || $device['id'] === 'bureausun') {
         stopPlayersIn('bureau', true, false);
         if ($onlySound) {
index 4c5d3668eb4c61fcdd6d5c81b6b0553b405f43ce..b5969d7e065ee391df7f1e668f95d2120f4bd7d3 100644 (file)
@@ -32,5 +32,7 @@ if (isset($_GET['key'])) {
     shieldMyCanal($e[1], $e[0]);
 } else if (isset($_GET['runappback'])) {
     shieldRunAppAndBackHome($_GET['runappback']);
+}else if(isset($_GET['netflix'])){
+    shieldNetflix();
 }
 echo '</pre>';
\ No newline at end of file
index ff6f8a9e6154b3e72116bed82f93fca3857a08e6..20b16a6a4500e7be4bfdafcfa1fab73484703c69 100644 (file)
@@ -28,15 +28,19 @@ $cases = [
         }
     },
     'WindowManager: handleComboKeys keyCode: 25, keyAction: 1' => function () use ($device) {
+        echo 'volume-down' . "\n";
         if ($device === 'bureau') {
-            echo 'volume-down' . "\n";
             volume('3', '-', 'harmony');
+        }else if($device==='salon'){
+            volume('2', '-', 'denonavr');
         }
     },
     'WindowManager: handleComboKeys keyCode: 24, keyAction: 1' => function () use ($device) {
+        echo 'volume-up' . "\n";
         if ($device === 'bureau') {
-            echo 'volume-up' . "\n";
             volume('3', '+', 'harmony');
+        }else if($device==='salon'){
+            volume('2', '+', 'denonavr');
         }
     }
 ];