]> _ Git - tortuga-home.git/commitdiff
.
authorVincent <vincent@enhydra.fr>
Sat, 6 Jul 2019 16:35:25 +0000 (18:35 +0200)
committerVincent <vincent@enhydra.fr>
Sat, 6 Jul 2019 16:35:25 +0000 (18:35 +0200)
.idea/workspace.xml
scripts/lib/domoticz.php
scripts/lib/scenes.php
servers/domoticz.php

index c3d67885257cfd901455abaf0541bd96ff73c649..97ddca3c5c14b1e2f26763ee01c0ca6a6434c3d0 100644 (file)
@@ -2,16 +2,10 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
-      <change afterPath="$PROJECT_DIR$/servers/domoticz.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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/medialibrary.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/medialibrary.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/scripts/lib/mediarasp.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/mediarasp.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$/scripts/lib/tmdb.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/tmdb.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/scripts/raspberrycast.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/raspberrycast.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/servers/insteon.php" beforeDir="false" afterPath="$PROJECT_DIR$/servers/insteon.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/servers/domoticz.php" beforeDir="false" afterPath="$PROJECT_DIR$/servers/domoticz.php" afterDir="false" />
     </list>
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
     <option name="SHOW_DIALOG" value="false" />
@@ -50,8 +44,8 @@
       <file pinned="false" current-in-tab="false">
         <entry file="file://$PROJECT_DIR$/scripts/lib/scenes.php">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="198">
-              <caret line="770" column="12" selection-start-line="770" selection-start-column="12" selection-end-line="770" selection-end-column="12" />
+            <state relative-caret-position="357">
+              <caret line="556" column="22" lean-forward="true" selection-start-line="556" selection-start-column="22" selection-end-line="556" selection-end-column="22" />
             </state>
           </provider>
         </entry>
@@ -68,8 +62,8 @@
       <file pinned="false" current-in-tab="true">
         <entry file="file://$PROJECT_DIR$/servers/domoticz.php">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="374">
-              <caret line="30" column="19" lean-forward="true" selection-start-line="30" selection-start-column="19" selection-end-line="30" selection-end-column="19" />
+            <state relative-caret-position="226">
+              <caret line="42" column="5" lean-forward="true" selection-start-line="42" selection-start-column="5" selection-end-line="42" selection-end-column="5" />
             </state>
           </provider>
         </entry>
@@ -77,8 +71,8 @@
       <file pinned="false" current-in-tab="false">
         <entry file="file://$PROJECT_DIR$/scripts/insteon.php">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="136">
-              <caret line="8" column="5" selection-start-line="8" selection-start-column="5" selection-end-line="8" selection-end-column="5" />
+            <state relative-caret-position="51">
+              <caret line="3" column="8" selection-start-line="3" selection-start-column="8" selection-end-line="3" selection-end-column="8" />
             </state>
           </provider>
         </entry>
       <file pinned="false" current-in-tab="false">
         <entry file="file://$PROJECT_DIR$/scripts/lib/domoticz.php">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="17">
-              <caret line="1" column="36" lean-forward="true" selection-start-line="1" selection-start-column="36" selection-end-line="1" selection-end-column="36" />
+            <state relative-caret-position="238">
+              <caret line="14" column="9" selection-start-line="14" selection-start-column="9" selection-end-line="14" selection-end-column="9" />
             </state>
           </provider>
         </entry>
   </component>
   <component name="FindInProjectRecents">
     <findStrings>
-      <find>home/of</find>
       <find>wc/</find>
       <find>cronWeather</find>
       <find>deshumidificateur</find>
-      <find>domoticz</find>
       <find>hide</find>
       <find>#mask</find>
       <find>hideMaskTimeout</find>
       <find>cheminee</find>
       <find>sudo at</find>
       <find>sudo</find>
+      <find>domoticzCmd</find>
+      <find>domoticz</find>
     </findStrings>
     <replaceStrings>
       <replace />
         <option value="$PROJECT_DIR$/scripts/lib/remoteinfos.php" />
         <option value="$PROJECT_DIR$/scripts/lib/mediarasp.php" />
         <option value="$PROJECT_DIR$/scripts/lib/medialibrary.php" />
-        <option value="$PROJECT_DIR$/scripts/lib/scenes.php" />
-        <option value="$PROJECT_DIR$/scripts/lib/domoticz.php" />
-        <option value="$PROJECT_DIR$/servers/domoticz.php" />
         <option value="$PROJECT_DIR$/servers/insteon.php" />
         <option value="$PROJECT_DIR$/scripts/lib/tmdb.php" />
+        <option value="$PROJECT_DIR$/scripts/lib/domoticz.php" />
+        <option value="$PROJECT_DIR$/scripts/lib/scenes.php" />
+        <option value="$PROJECT_DIR$/servers/domoticz.php" />
       </list>
     </option>
   </component>
       <workItem from="1561964740224" duration="5531000" />
       <workItem from="1562139612183" duration="879000" />
       <workItem from="1562187458066" duration="10928000" />
-      <workItem from="1562315270549" duration="2203000" />
-    </task>
-    <task id="LOCAL-00137" summary=".">
-      <created>1549794720705</created>
-      <option name="number" value="00137" />
-      <option name="presentableId" value="LOCAL-00137" />
-      <option name="project" value="LOCAL" />
-      <updated>1549794720705</updated>
+      <workItem from="1562315270549" duration="3917000" />
     </task>
     <task id="LOCAL-00138" summary=".">
       <created>1549795030567</created>
       <option name="project" value="LOCAL" />
       <updated>1562139892306</updated>
     </task>
-    <option name="localTasksCounter" value="186" />
+    <task id="LOCAL-00186" summary=".">
+      <created>1562398828376</created>
+      <option name="number" value="00186" />
+      <option name="presentableId" value="LOCAL-00186" />
+      <option name="project" value="LOCAL" />
+      <updated>1562398828377</updated>
+    </task>
+    <option name="localTasksCounter" value="187" />
     <servers />
   </component>
   <component name="TimeTrackingManager">
-    <option name="totallyTimeSpent" value="1234846000" />
+    <option name="totallyTimeSpent" value="1236560000" />
   </component>
   <component name="TodoView">
     <todo-panel id="selected-file">
       <window_info id="Designer" order="3" />
       <window_info id="UI Designer" order="4" />
       <window_info id="Favorites" order="5" sideWeight="0.4576547" side_tool="true" weight="0.22506666" />
-      <window_info content_ui="combo" id="Project" order="6" sideWeight="0.49456522" visible="true" weight="0.2182035" />
+      <window_info active="true" content_ui="combo" id="Project" order="6" sideWeight="0.49456522" visible="true" weight="0.2182035" />
       <window_info anchor="bottom" id="Message" order="0" />
       <window_info anchor="bottom" id="Find" order="1" sideWeight="0.48251194" visible="true" weight="0.30444205" />
       <window_info anchor="bottom" id="Run" order="2" sideWeight="0.4674086" weight="0.3217768" />
       <window_info anchor="right" id="Palette&#9;" order="7" />
       <window_info anchor="right" id="Capture Analysis" order="8" />
       <window_info anchor="right" id="Theme Preview" order="9" />
-      <window_info active="true" anchor="right" id="Remote Host" order="10" sideWeight="0.48753893" visible="true" weight="0.0918124" />
+      <window_info anchor="right" id="Remote Host" order="10" sideWeight="0.48753893" visible="true" weight="0.0918124" />
       <window_info anchor="right" id="SciView" order="11" weight="0.3298887" />
       <window_info anchor="right" id="Structure" order="12" sideWeight="0.51246107" side_tool="true" visible="true" weight="0.0918124" />
       <window_info anchor="right" id="Data View" order="13" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/scripts/insteon.php">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="136">
-          <caret line="8" column="5" selection-start-line="8" selection-start-column="5" selection-end-line="8" selection-end-column="5" />
-        </state>
-      </provider>
-    </entry>
     <entry file="file://$PROJECT_DIR$/scripts/lib/insteon.php">
       <provider selected="true" editor-type-id="text-editor">
         <state relative-caret-position="1">
     <entry file="file://$PROJECT_DIR$/scripts/domoticz_device_event.php">
       <provider selected="true" editor-type-id="text-editor" />
     </entry>
-    <entry file="file://$PROJECT_DIR$/scripts/lib/scenes.php">
+    <entry file="file://$PROJECT_DIR$/servers/insteon.php">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="198">
-          <caret line="770" column="12" selection-start-line="770" selection-start-column="12" selection-end-line="770" selection-end-column="12" />
+        <state relative-caret-position="-273">
+          <caret line="9" column="38" selection-start-line="9" selection-start-column="38" selection-end-line="9" selection-end-column="38" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/scripts/lib/domoticz.php">
+    <entry file="file://$PROJECT_DIR$/scripts/lib/tmdb.php">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="17">
-          <caret line="1" column="36" lean-forward="true" selection-start-line="1" selection-start-column="36" selection-end-line="1" selection-end-column="36" />
+        <state relative-caret-position="385">
+          <caret line="448" column="9" selection-start-line="448" selection-start-column="9" selection-end-line="448" selection-end-column="9" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/servers/insteon.php">
+    <entry file="file://$PROJECT_DIR$/scripts/insteon.php">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-273">
-          <caret line="9" column="38" selection-start-line="9" selection-start-column="38" selection-end-line="9" selection-end-column="38" />
+        <state relative-caret-position="51">
+          <caret line="3" column="8" selection-start-line="3" selection-start-column="8" selection-end-line="3" selection-end-column="8" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/scripts/lib/tmdb.php">
+    <entry file="file://$PROJECT_DIR$/scripts/lib/domoticz.php">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="385">
-          <caret line="448" column="9" selection-start-line="448" selection-start-column="9" selection-end-line="448" selection-end-column="9" />
+        <state relative-caret-position="238">
+          <caret line="14" column="9" selection-start-line="14" selection-start-column="9" selection-end-line="14" selection-end-column="9" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/scripts/lib/scenes.php">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="357">
+          <caret line="556" column="22" lean-forward="true" selection-start-line="556" selection-start-column="22" selection-end-line="556" selection-end-column="22" />
         </state>
       </provider>
     </entry>
     <entry file="file://$PROJECT_DIR$/servers/domoticz.php">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="374">
-          <caret line="30" column="19" lean-forward="true" selection-start-line="30" selection-start-column="19" selection-end-line="30" selection-end-column="19" />
+        <state relative-caret-position="226">
+          <caret line="42" column="5" lean-forward="true" selection-start-line="42" selection-start-column="5" selection-end-line="42" selection-end-column="5" />
         </state>
       </provider>
     </entry>
index 5c81668a72d9c5891d59d62e3166090b64a3c77a..a73fa2e00404b977f364d201a01fcd16400ba2d2 100644 (file)
@@ -7,18 +7,22 @@ function runDomoticzCommand($params)
     return httpRequest('http://192.168.1.60:8084/json.htm', 'GET', $params);
 }
 
-function domoticzSwitch($device, $cmd, $type = 'light')
+function domoticzSwitch($device, $cmd, $type = 'light', $priority = false)
 {
-    return domoticzCmd(['idx' => $device, 'switchcmd' => $cmd ? 'On' : 'Off', 'param' => 'switch' . $type, 'level' => '0']);
+    return domoticzCmd(['idx' => $device, 'switchcmd' => $cmd ? 'On' : 'Off', 'param' => 'switch' . $type, 'level' => '0'], $priority);
 }
 
-function domoticzCmd($command)
+function domoticzCmd($command, $priority = false)
 {
     $redis = connectRedis();
-    $queue = $redis->get('domoticz_queue');
+    $queue_name = 'domoticz_queue';
+    if ($priority) {
+        $queue_name .= '_priority';
+    }
+    $queue = $redis->get($queue_name);
     if (!is_array($queue)) {
         $queue = [];
     }
     $queue[] = $command;
-    $redis->set('domoticz_queue', $queue);
+    $redis->set($queue_name, $queue);
 }
\ No newline at end of file
index d3e8734b5960021db843d339b7007142a7d8a05f..f7ad246568007edcac93e2504e20e25a19515709 100644 (file)
@@ -261,7 +261,7 @@ $scenes = [
     ],
     'home/alert' => [
         ['type' => 'phonetask', 'phone' => 'vincent', 'task' => 'Tortuga Alerte'],
-        ['type' => 'domoticz', 'device' => '2', 'switchtype' => 'scene', 'command' => true],
+        ['type' => 'domoticz', 'device' => '2', 'switchtype' => 'scene', 'command' => true, 'priority' => true],
         ['type' => 'hue', 'group' => $home, 'scene' => ['alert' => 'select']],
         ['type' => 'hue', 'group' => $home, 'scene' => ['alert' => 'none'], 'delay' => 1],
         ['type' => 'hue', 'group' => $home, 'scene' => ['alert' => 'select']],
@@ -413,11 +413,11 @@ $scenes = [
     ],
 
     'bureau/plasma/on' => [
-        ['type' => 'domoticz', 'device' => '477', 'command' => true],
+        ['type' => 'domoticz', 'device' => '477', 'command' => true, 'priority' => true],
         //['type' => 'insteon', 'command' => '0?1138=I=0=0'],
     ],
     'bureau/plasma/off' => [
-        ['type' => 'domoticz', 'device' => '477', 'command' => false],
+        ['type' => 'domoticz', 'device' => '477', 'command' => false, 'priority' => true],
         //['type' => 'insteon', 'command' => '0?1338=I=0=0'],
     ],
 
@@ -436,16 +436,16 @@ $scenes = [
         ['type' => 'insteon', 'command' => '0?1339=I=0=0']
     ],
     'bureau/screen/down' => [
-        ['type' => 'domoticz', 'device' => '1', 'command' => true],
+        ['type' => 'domoticz', 'device' => '1', 'command' => true, 'priority' => true],
     ],
     'bureau/screen/up' => [
-        ['type' => 'domoticz', 'device' => '1', 'command' => false],
+        ['type' => 'domoticz', 'device' => '1', 'command' => false, 'priority' => true],
     ],
     'bureau/rideaux/close' => [
-        ['type' => 'domoticz', 'device' => '391', 'command' => false],
+        ['type' => 'domoticz', 'device' => '391', 'command' => false, 'priority' => true],
     ],
     'bureau/rideaux/open' => [
-        ['type' => 'domoticz', 'device' => '391', 'command' => true],
+        ['type' => 'domoticz', 'device' => '391', 'command' => true, 'priority' => true],
     ],
 
     'insteon/off' => [
@@ -541,14 +541,14 @@ $scenes = [
         //['type' => 'scene', 'scene' => 'bureau/media/off'],// Media bureau
         ['type' => 'scene', 'scene' => 'salon/freebox/off'],
         ['type' => 'scene', 'scene' => 'sdb/ampli/off'],
-       // ['type' => 'domoticz', 'device' => '2', 'switchtype' => 'scene', 'command' => false],
+        // ['type' => 'domoticz', 'device' => '2', 'switchtype' => 'scene', 'command' => false],
     ],
     'ecomode/super' => [
         ['type' => 'scene', 'scene' => 'ecomode/basic'],
         //['type' => 'domoticz', 'device' => '1', 'switchtype' => 'scene', 'command' => false],
     ],
     'ecomode/notsuper' => [
-        ['type' => 'domoticz', 'device' => '1', 'switchtype' => 'scene', 'command' => true],
+        ['type' => 'domoticz', 'device' => '1', 'switchtype' => 'scene', 'command' => true, 'priority' => false],
     ],
     'ecomode/on' => [
         ['type' => 'scene', 'scene' => 'ecomode/basic'],
@@ -557,7 +557,7 @@ $scenes = [
     'ecomode/off' => [
         ['type' => 'scene', 'scene' => 'ecomode/notsuper'],
         ['type' => 'scene', 'scene' => 'bureau/media/on'],// Media bureau
-        ['type' => 'domoticz', 'device' => '2', 'switchtype' => 'scene', 'command' => true, 'delay' => 2],
+        ['type' => 'domoticz', 'device' => '2', 'switchtype' => 'scene', 'command' => true, 'priority' => false],
     ],
 ];
 
@@ -624,7 +624,7 @@ function execScene($name, $fromUserAction = false)
         } else if ($action['type'] == 'ecomode') {
             ecoMode($action['mode']);
         } else if ($action['type'] == 'domoticz') {
-            domoticzSwitch($action['device'], $action['command'], isset($action['switchtype']) ? $action['switchtype'] : 'light');
+            domoticzSwitch($action['device'], $action['command'], isset($action['switchtype']) ? $action['switchtype'] : 'light', isset($action['priority']) && $action['priority']);
         } else if ($action['type'] == 'ir') {
             irsend($action['room'], $action['device'], $action['command']);
         }
index 51bcd9d79e7e6203ada7df7ab55c8bbf2be34959..7325c13bf55a37b873ab4f07db1e3d2a5906321f 100644 (file)
@@ -23,25 +23,32 @@ function handleDomoticzQueue()
 {
     global $redis;
 
-    $queue = $redis->get('domoticz_queue');
-    if (!is_array($queue)) {
-        $redis->set('domoticz_queue', []);
-    }
-    if (!count($queue)) {
-        return 0.1;
+    $queues = ['domoticz_queue_priority', 'domoticz_queue'];
+
+    foreach ($queues as $q) {
+        $queue = $redis->get($q);
+        if (!is_array($queue)) {
+            $queue = [];
+            $redis->set($q, $queue);
+        }
+        if (!count($queue)) {
+            continue;
+        }
+
+        $command = array_shift($queue);
+        echo 'Run command ' . json_encode($command) . "\n";
+        runDomoticzCommand($command);
+        doneCommand($q, $command);
+        return 1.5;
     }
 
-    $command = array_shift($queue);
-    echo 'Run command ' . json_encode($command) . "\n";
-    runDomoticzCommand($command);
-    doneCommand($command);
-    return 1.5;
+    return 0.1;
 }
 
-function doneCommand($command)
+function doneCommand($q, $command)
 {
     global $redis;
-    $queue = $redis->get('domoticz_queue');
+    $queue = $redis->get($q);
     $res = [];
     foreach ($queue as $item) {
         if ($item == $command) {
@@ -49,6 +56,6 @@ function doneCommand($command)
         }
         $res[] = $item;
     }
-    $redis->set('domoticz_queue', $res);
-    echo 'Done command : ' . json_encode($command) . "\n";
+    $redis->set($q, $res);
+    echo 'Done command (' . $q . ') : ' . json_encode($command) . "\n";
 }
\ No newline at end of file