]> _ Git - tortuga-home.git/commitdiff
.
authorVincent <vincent@enhydra.fr>
Thu, 3 Jun 2021 07:50:11 +0000 (09:50 +0200)
committerVincent <vincent@enhydra.fr>
Thu, 3 Jun 2021 07:50:11 +0000 (09:50 +0200)
.idea/workspace.xml
composer.json
scripts/lib/ecomode.php
scripts/lib/homeconnect.php
scripts/lib/http.php
scripts/lib/pc.php
scripts/lib/ssh.php
scripts/sleeppc.php

index 364a4178f84e4618311dfe6504e49b9946736955..f777a34b511f6c6a8df860d8a901253b15b9ae3d 100644 (file)
@@ -2,15 +2,14 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
-      <change beforePath="$PROJECT_DIR$/.htaccess" beforeDir="false" afterPath="$PROJECT_DIR$/.htaccess" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/.idea/deployment.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/deployment.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/config/tv.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/tv.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$/composer.json" beforeDir="false" afterPath="$PROJECT_DIR$/composer.json" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/ecomode.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/ecomode.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/homeconnect.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/homeconnect.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/http.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/http.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/pc.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/pc.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/scripts/lib/ssh.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/ssh.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/servers/startdaemon" beforeDir="false" afterPath="$PROJECT_DIR$/servers/startdaemon" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/servers/startserver" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/servers/stopserver" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/sleeppc.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/sleeppc.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
         <option name="Make" enabled="true" />
       </method>
     </configuration>
-    <configuration default="true" type="ArquillianJUnit" factoryName="" nameIsGenerated="true">
-      <option name="arquillianRunConfiguration">
-        <value>
-          <option name="containerStateName" value="" />
-        </value>
-      </option>
-      <option name="TEST_OBJECT" value="class" />
-      <method v="2">
-        <option name="Make" enabled="true" />
-      </method>
-    </configuration>
     <configuration default="true" type="ArquillianTestNG" factoryName="">
       <option name="arquillianRunConfiguration">
         <value>
       <workItem from="1622185202332" duration="1711000" />
       <workItem from="1622440150420" duration="1374000" />
       <workItem from="1622659686189" duration="138000" />
-      <workItem from="1622659989891" duration="3179000" />
-    </task>
-    <task id="LOCAL-00440" summary=".">
-      <created>1611655420798</created>
-      <option name="number" value="00440" />
-      <option name="presentableId" value="LOCAL-00440" />
-      <option name="project" value="LOCAL" />
-      <updated>1611655420798</updated>
+      <workItem from="1622659989891" duration="3855000" />
+      <workItem from="1622676912583" duration="2362000" />
     </task>
     <task id="LOCAL-00441" summary=".">
       <created>1611656702791</created>
       <option name="project" value="LOCAL" />
       <updated>1622441173734</updated>
     </task>
-    <option name="localTasksCounter" value="489" />
+    <task id="LOCAL-00489" summary=".">
+      <created>1622664420441</created>
+      <option name="number" value="00489" />
+      <option name="presentableId" value="LOCAL-00489" />
+      <option name="project" value="LOCAL" />
+      <updated>1622664420442</updated>
+    </task>
+    <option name="localTasksCounter" value="490" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
index 78a5134b6e8e99b7b525f471e6349370503c185a..8a4750e8b01c2ae663123706bccfeaac4044d775 100644 (file)
@@ -22,6 +22,7 @@
     "zendframework/zend-i18n-resources": "^2.6",
     "ext-json": "*",
     "ext-mysqli": "*",
-    "graze/telnet-client": "^2.3"
+    "graze/telnet-client": "^2.3",
+    "ext-ssh2": "*"
   }
 }
index 7c13c22d176344fcb5c8e740f283bdcfdec3edb4..a6fa4837bcd082e6684129a1cc4cc5b959d1a5b4 100644 (file)
@@ -32,13 +32,19 @@ function nightmode($mode)
 
 function getNightMode()
 {
+    if(config('DEVICE')==='sdb'){
+        $h=date('G');
+        if($h>6 && $h<21){
+            return false;
+        }
+    }
     return getState('night') == '1';
 }
 
 function getEcoMode()
 {
     $res = getState('ecomode','0');
-    if ($res == '0' && getState('night') == '1') {
+    if ($res == '0' && getNightMode()) {
         $res = '1';
     }
     return (string)$res;
index 543a6505c0a744eb3da0ff247a68f10727b231d2..f4b50f179a07bc1eb0275fc86d047d3817985c20 100644 (file)
@@ -12,9 +12,11 @@ function _hc_cmd($cmd, $data = [], $method = 'get', $auth = true)
     try {
         $res = httpRequest($uri, $method, $data, null, 10, true, $headers);
     } catch (Exception $e) {
-        if (stristr($e->getMessage(), 'The access token expired')) {
+        if (stristr($e->getMessage(), 'token')) {
             hc_connect(true);
             return _hc_cmd($cmd, $data, $method, $auth);
+        }else{
+            echo $e->getMessage();
         }
     }
     $c = $res->getBody()->getContents();
index 6db16645865d1afc9371063eee9bcd0ccba8b559..9548190653a83280f6c822807435b2fd0a6c7472 100644 (file)
@@ -60,6 +60,8 @@ function httpRequest($url, $method = 'get', $data = [], $auth = null, $timeout =
         }
     }
     $options['headers'] = $headers;
+    $res= $client->request($method, $url, $options);
 
-    return $client->request($method, $url, $options);
+    print_r($res);
+    return $res;
 }
\ No newline at end of file
index e30f41ffd158c5dbb0eac86da1411ebd1a7ed423..ce2a07ebc1110c441a922e48f1c42e31d6fef2c3 100644 (file)
@@ -18,20 +18,20 @@ function wakeupPC($device)
     setState($s, '1');
 }
 
-function sleepPC($device)
+function sleepPC($device,$force=false)
 {
     $s = 'device_' . $device . '_awake';
-    if (getState($s) == '0') {
+    if (!$force && getState($s) == '0') {
         echo 'already sleeping ' . $device . ' :: ' . $s;
         return;
     }
     setState($s, '0');
-    $res = sshCommand('"C:\Program Files\Scripts\sleep.bat"', $device, false);
+    $res = sshCommand('"C:\Program Files\Scripts\sleep.bat"', $device, true,true);
     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, true);
 }
\ No newline at end of file
index acbfb0a151b623c80fe48d149f99541242d62030..d0a7d6a048c0f00b83387fa4ed34a1e71dad2e0d 100644 (file)
@@ -24,6 +24,7 @@ function getSSHInstance($device = null, $sudo = false, $force = false)
             }
             $user = $sudo ? 'root' : $d['user'];
             //if (getState('device_' . $device . '_awake') == '1') {
+            print_r($d);
             $ssh[$instance_key] = ssh2_connect($d['host'], 22);
             if ($ssh[$instance_key]) {
                 if (!ssh2_auth_password($ssh[$instance_key], $user, $d['password'])) {
@@ -54,6 +55,7 @@ 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) {
index 5b68eca54d5112d51dc44929e36113ac83b96dfe..eb93ed252db13d681ab7caec99dd40d22c938ea7 100644 (file)
@@ -1,3 +1,3 @@
 <?php
 require_once "import.php";
-print_r(sleepPC('avion'));
\ No newline at end of file
+print_r(sleepPC('avion', true));
\ No newline at end of file