]> _ Git - tortuga-home.git/commitdiff
.
authorVincent <vincent@enhydra.fr>
Sat, 24 Oct 2020 17:10:22 +0000 (19:10 +0200)
committerVincent <vincent@enhydra.fr>
Sat, 24 Oct 2020 17:10:22 +0000 (19:10 +0200)
.idea/workspace.xml
scripts/lib/hue.php
scripts/lib/scenes.php
servers/hue.php [new file with mode: 0644]

index 623af14185c76158daee42f69bf53842a7d7231e..1366b27af9aee58070fa8e3a4e0cfee8f332dd1a 100644 (file)
@@ -2,13 +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/hue.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/config/global.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/global.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/config/rooms.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/rooms.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/off.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/off.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/hue.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/hue.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/squeezebox.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/squeezebox.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
     <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1553247665857" />
     <property name="dumpAutoload T:/Drive/Works/home/composer.json" value="--no-interaction --ansi --verbose --optimize" />
     <property name="editor.config.ad.shown" value="true" />
-    <property name="last_opened_file_path" value="$PROJECT_DIR$/config" />
+    <property name="last_opened_file_path" value="$PROJECT_DIR$/servers" />
     <property name="list.type.of.created.stylesheet" value="Less" />
     <property name="nodejs_package_manager_path" value="npm" />
     <property name="project.structure.last.edited" value="Project" />
     <property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
   </component>
   <component name="RecentsManager">
+    <key name="CopyFile.RECENT_KEYS">
+      <recent name="T:\Drive\Works\home\servers" />
+      <recent name="T:\Drive\Works\home\config" />
+      <recent name="T:\Drive\Works\home\images\backgrounds" />
+      <recent name="T:\Drive\Works\home\tools\xplanet" />
+      <recent name="T:\Drive\Works\home\tools\pop" />
+    </key>
     <key name="MoveFile.RECENT_KEYS">
       <recent name="T:\Drive\Works\home\tools\xplanet" />
       <recent name="T:\Drive\Works\home\style\fonts\webfonts" />
       <recent name="T:\Drive\Works\home\images" />
       <recent name="D:\CloudStation\Works\home\style\fonts" />
     </key>
-    <key name="CopyFile.RECENT_KEYS">
-      <recent name="T:\Drive\Works\home\config" />
-      <recent name="T:\Drive\Works\home\images\backgrounds" />
-      <recent name="T:\Drive\Works\home\tools\xplanet" />
-      <recent name="T:\Drive\Works\home\tools\pop" />
-      <recent name="T:\Drive\Works\home\scripts\lib" />
-    </key>
   </component>
   <component name="RunManager">
     <configuration default="true" type="Applet">
         <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="1602581583330" duration="1284000" />
       <workItem from="1602862886793" duration="1014000" />
       <workItem from="1603095373591" duration="1368000" />
-      <workItem from="1603270756890" duration="2727000" />
-    </task>
-    <task id="LOCAL-00300" summary=".">
-      <created>1581951532460</created>
-      <option name="number" value="00300" />
-      <option name="presentableId" value="LOCAL-00300" />
-      <option name="project" value="LOCAL" />
-      <updated>1581951532461</updated>
+      <workItem from="1603270756890" duration="3366000" />
+      <workItem from="1603558842019" duration="446000" />
     </task>
     <task id="LOCAL-00301" summary=".">
       <created>1582014172949</created>
       <option name="project" value="LOCAL" />
       <updated>1603131455369</updated>
     </task>
-    <option name="localTasksCounter" value="349" />
+    <task id="LOCAL-00349" summary=".">
+      <created>1603276030272</created>
+      <option name="number" value="00349" />
+      <option name="presentableId" value="LOCAL-00349" />
+      <option name="project" value="LOCAL" />
+      <updated>1603276030273</updated>
+    </task>
+    <option name="localTasksCounter" value="350" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
       <screen x="0" y="0" width="2560" height="1040" />
     </state>
     <state x="872" y="161" key="#Plugins/0.0.2560.1040@0.0.2560.1040" timestamp="1596008801840" />
-    <state x="198" y="0" width="745" height="567" key="CommitChangelistDialog2" timestamp="1603131428714">
+    <state x="198" y="0" width="745" height="567" key="CommitChangelistDialog2" timestamp="1603275999359">
       <screen x="0" y="0" width="2560" height="1040" />
     </state>
     <state x="701" y="75" key="CommitChangelistDialog2/0.0.1920.1160@0.0.1920.1160" timestamp="1602171117745" />
-    <state x="198" y="0" width="745" height="567" key="CommitChangelistDialog2/0.0.2560.1040@0.0.2560.1040" timestamp="1603131428714" />
+    <state x="198" y="0" width="745" height="567" key="CommitChangelistDialog2/0.0.2560.1040@0.0.2560.1040" timestamp="1603275999359" />
     <state x="1114" y="443" key="NewPhpFileDialog" timestamp="1602146675515">
       <screen x="0" y="0" width="2560" height="1040" />
     </state>
       <screen x="0" y="0" width="2560" height="1040" />
     </state>
     <state x="295" y="0" width="1290" height="907" key="dock-window-1/0.0.2560.1040@0.0.2560.1040" timestamp="1603274697406" />
-    <state x="977" y="257" width="607" height="536" key="find.popup" timestamp="1598297024487">
+    <state x="977" y="257" width="607" height="536" key="find.popup" timestamp="1603559077781">
       <screen x="0" y="0" width="2560" height="1040" />
     </state>
-    <state x="977" y="257" width="607" height="536" key="find.popup/0.0.2560.1040@0.0.2560.1040" timestamp="1598297024487" />
+    <state x="977" y="257" width="607" height="536" key="find.popup/0.0.2560.1040@0.0.2560.1040" timestamp="1603559077781" />
   </component>
   <component name="antWorkspaceConfiguration">
     <option name="IS_AUTOSCROLL_TO_SOURCE" value="false" />
index 8ab5f10169c7645059c7898d6a3dde499cf1bd2e..01372ff7a82b5ca58c88292319acb10b12a2de6a 100644 (file)
@@ -11,20 +11,34 @@ function getHueInstance()
     return $hue;
 }
 
-//function hueScene($id,$intensity)
-//{
-//    $command=new Phue\Test\Command\
-//
-//    $hue = getHueInstance();
-//    $hue->sendCommand();
-//}
-
 function getHueState()
 {
     $hue = getHueInstance();
     return array('groups' => $hue->getGroups(), 'scenes' => $hue->getScenes(), 'lights' => $hue->getLights());
 }
 
+function hueCommand($action, $transitionTime)
+{
+    $redis = connectRedis();
+    $queue = $redis->igbget('hue_queue');
+    if (!is_array($queue)) {
+        $queue = [];
+    }
+    $command = $action;
+    $command['transitionTime'] = $transitionTime;
+    $queue[] = $command;
+    $redis->igbset('hue_queue', $queue);
+    $redis->publish('hue_queue', 'handle_queue');
+}
+
+function _hueCommand($action)
+{
+    if (isset($action['group'])) {
+        hueApplyScene($action['group'], $action['scene'], $action['transitionTime']);
+    } else if (isset($action['light'])) {
+        hueApplySceneLight($action['light'], $action['scene'], $action['transitionTime']);
+    }
+}
 
 function hueApplyScene($groupId, $sceneId, $transitionTime = null)
 {
index 1e4c8c22efb5a86277d38017727f4354d6223368..a92d4d3ec14079d4d034e80a384a7361ba58cdc4 100644 (file)
@@ -738,11 +738,7 @@ function execScene($name, $fromUserAction = false, $transitionTime = null)
         }
 
         if ($action['type'] == 'hue') {
-            if (isset($action['group'])) {
-                hueApplyScene($action['group'], $action['scene'], $transitionTime);
-            } else if (isset($action['light'])) {
-                hueApplySceneLight($action['light'], $action['scene'], $transitionTime);
-            }
+            hueCommand($action,$transitionTime);
         } else if ($action['type'] == 'insteon') {
             insteonCommand($action['command']);
         } else if ($action['type'] == 'delay' || $action['type'] == 'scene') {
diff --git a/servers/hue.php b/servers/hue.php
new file mode 100644 (file)
index 0000000..9a7bd89
--- /dev/null
@@ -0,0 +1,45 @@
+#!/usr/bin/php
+
+<?php
+require_once __DIR__ . "/../scripts/import.php";
+
+// Set time limit to indefinite execution
+set_time_limit(0);
+ignore_user_abort(true);
+
+echo 'Run hue server hue' . "\n";
+
+$redis = connectRedis();
+handleHueQueue();
+
+redisEventListener('hue_event', 'handleHueQueue');
+
+function handleHueQueue()
+{
+    global $redis;
+
+    while (true) {
+        $queue = $redis->igbget('hue_queue');
+        if (!is_array($queue)) {
+            $queue = [];
+            $redis->igbset('hue_queue', $queue);
+        }
+
+
+        if (!count($queue)) {
+            echo 'Queue empty ' . "\n";
+            break;
+        }
+
+        $queue = array_unique($queue);
+
+        echo 'Handle Queue : current state ' . json_encode($queue) . "\n";
+
+        $command = array_shift($queue);
+        $redis->igbset('hue_queue', $queue);
+        echo 'Run command ' . $command . "\n";
+        _hueCommand($command);
+        usleep(1000000 * 0.1);
+    }
+    echo 'End of handling queue' . "\n";
+}
\ No newline at end of file