]> _ Git - tortuga-home.git/commitdiff
.
authorVincent <vincent@enhydra.fr>
Wed, 21 Apr 2021 07:17:43 +0000 (09:17 +0200)
committerVincent <vincent@enhydra.fr>
Wed, 21 Apr 2021 07:17:43 +0000 (09:17 +0200)
.idea/workspace.xml
scripts/homeconnect.php
scripts/lib/homeconnect.php
scripts/lib/remoteinfos.php
scripts/lib/scenes.php
servers/domoticz.php

index 31199d3db44fdc4f7bcf8d87ea7b72029ca97fe0..984e41370341aec930b9e851febc53a02e930bd6 100644 (file)
@@ -3,8 +3,11 @@
   <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$/config/coffee.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/coffee.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/homeconnect.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/homeconnect.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/remoteinfos.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/remoteinfos.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$/servers/domoticz.php" beforeDir="false" afterPath="$PROJECT_DIR$/servers/domoticz.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="1618426400216" duration="1138000" />
       <workItem from="1618656192286" duration="2313000" />
       <workItem from="1618682288258" duration="2117000" />
-      <workItem from="1618740509693" duration="12495000" />
-    </task>
-    <task id="LOCAL-00421" summary=".">
-      <created>1607933724635</created>
-      <option name="number" value="00421" />
-      <option name="presentableId" value="LOCAL-00421" />
-      <option name="project" value="LOCAL" />
-      <updated>1607933724636</updated>
+      <workItem from="1618740509693" duration="14198000" />
+      <workItem from="1618947923152" duration="1999000" />
     </task>
     <task id="LOCAL-00422" summary=".">
       <created>1607938357925</created>
       <option name="project" value="LOCAL" />
       <updated>1618861174900</updated>
     </task>
-    <option name="localTasksCounter" value="470" />
+    <task id="LOCAL-00470" summary=".">
+      <created>1618909856303</created>
+      <option name="number" value="00470" />
+      <option name="presentableId" value="LOCAL-00470" />
+      <option name="project" value="LOCAL" />
+      <updated>1618909856304</updated>
+    </task>
+    <option name="localTasksCounter" value="471" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
index 50363f8f7220761b18eb0ba4c71d68b21a711471..4522c5577d8b92fffc94f77a2455ded9a0c71f1d 100644 (file)
@@ -1,4 +1,4 @@
 <?php
 require_once "import.php";
 echo '<pre>';
-hc_setpower_state('Machine à café',false);
\ No newline at end of file
+hc_setpower_state('Machine à café',true);
\ No newline at end of file
index 94e88e972979d240fb5b5567dee73c1d0110651b..543a6505c0a744eb3da0ff247a68f10727b231d2 100644 (file)
@@ -9,7 +9,14 @@ function _hc_cmd($cmd, $data = [], $method = 'get', $auth = true)
         $headers['Authorization'] = 'Bearer ' . getState('hc_access_token');
         $headers['Accept'] = 'application/vnd.bsh.sdk.v1+json';
     }
-    $res = httpRequest($uri, $method, $data, null, 10, true, $headers);
+    try {
+        $res = httpRequest($uri, $method, $data, null, 10, true, $headers);
+    } catch (Exception $e) {
+        if (stristr($e->getMessage(), 'The access token expired')) {
+            hc_connect(true);
+            return _hc_cmd($cmd, $data, $method, $auth);
+        }
+    }
     $c = $res->getBody()->getContents();
 
     if ($decoded = json_decode($c)) {
@@ -70,24 +77,26 @@ function hc_setpower_state($appliance, $state)
         'type' => 'BSH.Common.EnumType.PowerState',
         'contraints' => ['allowedvalues' => ['BSH.Common.EnumType.Powerstate.' . $states[0], 'BSH.Common.EnumType.Powerstate.' . $states[1]]]];
 
-    return _hc_cmd("api/homeappliances/" . hc_haid($appliance) . "/settings/BSH.Common.Setting.PowerState", ['data'=>$data], 'put');
+    return _hc_cmd("api/homeappliances/" . hc_haid($appliance) . "/settings/BSH.Common.Setting.PowerState", ['data' => $data], 'put');
 }
 
-function coffee_on(){
-    hc_setpower_state('Machine à café',true);
+function coffee_on()
+{
+    hc_setpower_state('Machine à café', true);
 }
 
-function coffee_off(){
-    hc_setpower_state('Machine à café',false);
+function coffee_off()
+{
+    hc_setpower_state('Machine à café', false);
 }
 
-function hc_connect()
+function hc_connect($refresh = false)
 {
     $scope = 'IdentifyAppliance Monitor Settings';
     $appName = 'Tortuga';
     $locale = 'fr';
 
-    if (null === getStateIfMoreRecent('hc_access_token', null, time() - 86400)) {
+    if ($refresh || null === getStateIfMoreRecent('hc_access_token', null, time() - 86400)) {
         // Init connection
         $connect = _hc_cmd('security/oauth/device_authorization', [
             'client_id' => HOMECONNECT_CLIENT_ID,
index c20f61915b35d768adb3ce73371913f25ecb697c..ac39839793f0f43aa2df45f9c1c9fb5e202bbd82 100644 (file)
@@ -20,7 +20,16 @@ function remoteInfos()
         if (config('TVPLAYER') === 'shield') {
             if (shieldGetCurrentApp() === 'kodi') {
                 $res = ['type' => 'shieldmedia', 'can_seek' => true];
-                $p = json_decode(httpRequest('http://' . getDevice()['shield'] . ':8754/jsonrpc?Base=1', 'post', '[{"jsonrpc":"2.0","method":"Player.GetProperties","params":[1,["playlistid","speed","position","totaltime","time","percentage","shuffled","repeat","canrepeat","canshuffle","canseek","partymode"]],"id":1},{"jsonrpc":"2.0","method":"Player.GetItem","params":[1,["title","thumbnail","file","artist","genre","year","rating","album","track","duration","playcount","dateadded","episode","artistid","albumid","tvshowid","fanart"]],"id":2}]', ['kodi', 'atacama'], 10, true, ['X-Requested-With' => 'XMLHttpRequest', 'Content-type' => 'application/json'])->getBody(), true);
+                while (true) {
+                    try {
+                        $req = httpRequest('http://' . getDevice()['shield'] . ':8754/jsonrpc?Base=1', 'post', '[{"jsonrpc":"2.0","method":"Player.GetProperties","params":[1,["playlistid","speed","position","totaltime","time","percentage","shuffled","repeat","canrepeat","canshuffle","canseek","partymode"]],"id":1},{"jsonrpc":"2.0","method":"Player.GetItem","params":[1,["title","thumbnail","file","artist","genre","year","rating","album","track","duration","playcount","dateadded","episode","artistid","albumid","tvshowid","fanart"]],"id":2}]', ['kodi', 'atacama'], 10, true, ['X-Requested-With' => 'XMLHttpRequest', 'Content-type' => 'application/json']);
+                        break;
+                    } catch (Exception $e) {
+
+                    }
+                    sleep(2);
+                }
+                $p = json_decode($req->getBody(), true);
                 $res['duration'] = '';
                 $res['time'] = '';
                 $res['title'] = '';
index 142e7909a1f98696a9ae7f411f3bde33c3f4f96e..8591f0d8d349eecd7983a2b42107ad2dfff57fce 100644 (file)
@@ -252,7 +252,7 @@ $scenes = [
         ['type' => 'domoticz', 'scene' => 43, 'command' => true, 'priority' => true],
     ],
     'chambre/cheminee/smallfire' => [
-        ['type' => 'domoticz', 'scene' => 43, 'command' => true, 'priority' => true],
+        ['type' => 'domoticz', 'scene' => 44, 'command' => true, 'priority' => true],
     ],
     'chambre/cheminee/cold' => [
         ['type' => 'domoticz', 'scene' => 43, 'command' => true, 'priority' => true],
index 0c635fa12358ddb7499f1a38c5b703de91089a0d..65b2b655a99a366ebc457d23909887c1858f43c9 100644 (file)
@@ -34,6 +34,6 @@ function handleDomoticzQueue()
         $redis->igbset($q, $queue);
         echo 'Run command ' . json_encode($command) . "\n";
         runDomoticzCommand($command);
-        usleep(1000000 * 0.5);
+        usleep(1000000 * 0.25);
     }
 }
\ No newline at end of file