]> _ Git - tortuga-home.git/commitdiff
.
authorVincent <vincent@enhydra.fr>
Sun, 22 Nov 2020 19:40:00 +0000 (20:40 +0100)
committerVincent <vincent@enhydra.fr>
Sun, 22 Nov 2020 19:40:00 +0000 (20:40 +0100)
.idea/workspace.xml
scripts/cron/cron.php
scripts/lib/insteon.php
scripts/lib/scenes.php

index 5e5be9a3cc10b7d1236df52b51a70975f5a7c3e6..07b3a219687875da138932fc256e447e9ef8d8f8 100644 (file)
@@ -3,6 +3,8 @@
   <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/cron/cron.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/cron/cron.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/insteon.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/insteon.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/scripts/lib/scenes.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/scenes.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
       <workItem from="1605597648537" duration="7658000" />
       <workItem from="1605690676577" duration="7108000" />
       <workItem from="1605973078856" duration="4741000" />
-      <workItem from="1606049944658" duration="48000" />
-    </task>
-    <task id="LOCAL-00360" summary=".">
-      <created>1604237429974</created>
-      <option name="number" value="00360" />
-      <option name="presentableId" value="LOCAL-00360" />
-      <option name="project" value="LOCAL" />
-      <updated>1604237429974</updated>
+      <workItem from="1606049944658" duration="4056000" />
     </task>
     <task id="LOCAL-00361" summary=".">
       <created>1604237480617</created>
       <option name="project" value="LOCAL" />
       <updated>1606049532127</updated>
     </task>
-    <option name="localTasksCounter" value="409" />
+    <task id="LOCAL-00409" summary=".">
+      <created>1606050006824</created>
+      <option name="number" value="00409" />
+      <option name="presentableId" value="LOCAL-00409" />
+      <option name="project" value="LOCAL" />
+      <updated>1606050006824</updated>
+    </task>
+    <option name="localTasksCounter" value="410" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
     </state>
     <state x="740" y="229" key="#com.jetbrains.php.refactoring.extractMethod.PhpExtractMethodDialog#function0/0.0.1707.920@0.0.1707.920" timestamp="1604146905948" />
     <state x="1110" y="259" key="#com.jetbrains.php.refactoring.extractMethod.PhpExtractMethodDialog#function0/0.0.2560.1040@0.0.2560.1040" timestamp="1605437484620" />
-    <state x="198" y="0" width="737" height="502" key="CommitChangelistDialog2" timestamp="1606049525299">
+    <state x="198" y="0" width="737" height="502" key="CommitChangelistDialog2" timestamp="1606050001261">
       <screen x="0" y="0" width="2560" height="1040" />
     </state>
     <state x="132" y="0" width="737" height="502" key="CommitChangelistDialog2/0.0.1707.920@0.0.1707.920" timestamp="1605086955514" />
     <state x="701" y="75" key="CommitChangelistDialog2/0.0.1920.1160@0.0.1920.1160" timestamp="1605188136787" />
-    <state x="198" y="0" width="745" height="567" key="CommitChangelistDialog2/0.0.2560.1040@0.0.2560.1040" timestamp="1606049525299" />
+    <state x="198" y="0" width="745" height="567" key="CommitChangelistDialog2/0.0.2560.1040@0.0.2560.1040" timestamp="1606050001261" />
     <state x="952" y="244" key="FileChooserDialogImpl" timestamp="1605726960903">
       <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="1605727985438">
+    <state x="977" y="257" width="607" height="536" key="find.popup" timestamp="1606072522868">
       <screen x="0" y="0" width="2560" height="1040" />
     </state>
     <state x="651" y="227" width="550" height="534" key="find.popup/0.0.1707.920@0.0.1707.920" timestamp="1604301949692" />
-    <state x="977" y="257" width="607" height="536" key="find.popup/0.0.2560.1040@0.0.2560.1040" timestamp="1605727985438" />
+    <state x="977" y="257" width="607" height="536" key="find.popup/0.0.2560.1040@0.0.2560.1040" timestamp="1606072522868" />
     <state x="1056" y="292" key="refactoring.ChangeSignatureDialog" timestamp="1604518096294">
       <screen x="0" y="0" width="2560" height="1040" />
     </state>
index d05bc0ef663689c78ff76f64e6e1c047bf6f9a5b..7c3bebc787f0ba6c1ac79d268f173cc205065b31 100644 (file)
@@ -116,7 +116,9 @@ function cronRooms($cronmin)
         updateCourAuto();
     }
     checkPlanetarium();
-    checkWCVMC();
+    if ($cronmin % 2) {
+        checkWCVMC();
+    }
 }
 
 function cronFlowerPower($cronmin)
index e9289f195e57861687ae5ec1cbb7c1f74ade98ba..1a6c1298c228eba8ea91746c031e69cb406e133b 100644 (file)
@@ -17,7 +17,7 @@ function insteonCommand($command)
     $redis->publish('insteon_event', 'handle_queue');
 }
 
-function runInsteonCommand($command, $attempts = 3)
+function runInsteonCommand($command, $attempts = 10)
 {
     if ($attempts <= 0) {
         return;
@@ -26,8 +26,8 @@ function runInsteonCommand($command, $attempts = 3)
     insteonClearBuffer();
     echo "\n" . '-- Command ' . $command . ' attempt #' . $attempts . ' --' . "\n";
     echo "command : " . _insteonCommand($command) . "\n";
-    for ($i = 1; $i <= 5; $i++) {
-        usleep(1000000 * 0.01);
+    for ($i = 1; $i <= 100; $i++) {
+        usleep(1000000 * 0.05);
         $buff = insteonBuffer();
         echo $buff . "\n";
         if (stristr($buff, '0250') || stristr($buff, '0258')) {
index c63b8e9c72bd24c22ec07c669682d5832306833f..6244bd7f494c094a0455e96ec7160a22c724151d 100644 (file)
@@ -62,7 +62,7 @@ $scenes = [
         ['type' => 'ecomode', 'mode' => '1'],
         ['type' => 'state', 'key' => 'chambre', 'value' => 0],
         ['type' => 'scene', 'scene' => 'chambre/rideaux/close'],
-        ['type' => 'insteon', 'command' => '0?1131=I=0=0'],
+        //['type' => 'insteon', 'command' => '0?1131=I=0=0'],
         ['type' => 'function', 'function' => 'bedbrightness', 'args' => [$bedlowscreenbrightness]],
         ['type' => 'scene', 'scene' => 'chambre/deshumidificateur/off'],
         ['type' => 'scene', 'scene' => 'chambre/raspberry/off'],
@@ -94,7 +94,7 @@ $scenes = [
         ['type' => 'ecomode', 'mode' => '1'],
         ['type' => 'function', 'function' => 'chambreAuto', 'args' => [false]],
         ['type' => 'state', 'key' => 'chambre', 'value' => 0],
-        ['type' => 'insteon', 'command' => '0?1332=I=0=0'], // Lustre et tableau off
+        //['type' => 'insteon', 'command' => '0?1332=I=0=0'], // Lustre et tableau off
         ['type' => 'function', 'function' => 'bedbrightness', 'args' => [$bedlowscreenbrightness]],
         ['type' => 'scene', 'scene' => 'chambre/rideaux/close'],
         ['type' => 'scene', 'scene' => 'sdb/off'],
@@ -115,7 +115,7 @@ $scenes = [
         ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => 'mwAGvt2n70oXCqA'],
         ['type' => 'domoticz', 'scene' => 4, 'command' => true, 'priority' => true],
-        ['type' => 'insteon', 'command' => '0?1131=I=0=0'],
+        //['type' => 'insteon', 'command' => '0?1131=I=0=0'],
         ['type' => 'scene', 'scene' => 'chambre/cheminee/cold'],
     ],
     'chambre/savane' => [
@@ -123,7 +123,7 @@ $scenes = [
         ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => 'ABqCuE-ob-sw2vQ'],
         ['type' => 'domoticz', 'scene' => 5, 'command' => true, 'priority' => true],
-        ['type' => 'insteon', 'command' => '0?1131=I=0=0'],
+        //['type' => 'insteon', 'command' => '0?1131=I=0=0'],
         ['type' => 'scene', 'scene' => 'chambre/cheminee'],
     ],
     'chambre/focus' => [
@@ -131,7 +131,7 @@ $scenes = [
         ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => 'Ne6uJnnoPO9yRhl'],
         ['type' => 'domoticz', 'scene' => 6, 'command' => true, 'priority' => true],
-        ['type' => 'insteon', 'command' => '0?1131=I=0=0'],
+        //['type' => 'insteon', 'command' => '0?1131=I=0=0'],
         ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]],
         ['type' => 'scene', 'scene' => 'chambre/cheminee/cold'],
     ],
@@ -140,7 +140,7 @@ $scenes = [
         ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => '03gdSwPyZ9sbZVg'],
         ['type' => 'domoticz', 'scene' => 7, 'command' => true, 'priority' => true],
-        ['type' => 'insteon', 'command' => '0?1131=I=0=0'],
+        //['type' => 'insteon', 'command' => '0?1131=I=0=0'],
         ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]],
         ['type' => 'scene', 'scene' => 'chambre/cheminee'],
     ],
@@ -149,7 +149,7 @@ $scenes = [
         ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => 'BNiNQjxiWNbKRaH'],
         ['type' => 'domoticz', 'scene' => 8, 'command' => true, 'priority' => true],
-        ['type' => 'insteon', 'command' => '0?1131=I=0=0'],
+       // ['type' => 'insteon', 'command' => '0?1131=I=0=0'],
         ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]],
         ['type' => 'scene', 'scene' => 'chambre/cheminee'],
     ],
@@ -158,7 +158,7 @@ $scenes = [
         ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => 'Tlcft9sPK492cJA'],
         ['type' => 'domoticz', 'scene' => 9, 'command' => true, 'priority' => true],
-        ['type' => 'insteon', 'command' => '0?1131=I=0=0'],
+       // ['type' => 'insteon', 'command' => '0?1131=I=0=0'],
         ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]],
         ['type' => 'scene', 'scene' => 'chambre/cheminee/cold'],
     ],
@@ -173,7 +173,7 @@ $scenes = [
         ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => 'qvQXHDodBPa0cZf'],
         ['type' => 'domoticz', 'scene' => 12, 'command' => true, 'priority' => true],
-        ['type' => 'insteon', 'command' => '0?1119=I=0=0'],
+        //['type' => 'insteon', 'command' => '0?1119=I=0=0'],
         ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]],
         ['type' => 'scene', 'scene' => 'chambre/cheminee'],
     ],
@@ -182,7 +182,7 @@ $scenes = [
         ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => 'VtGPKtpQ7DF-RCd'],
         ['type' => 'domoticz', 'scene' => 13, 'command' => true, 'priority' => true],
-        ['type' => 'insteon', 'command' => '0?1131=I=0=0'],
+        //['type' => 'insteon', 'command' => '0?1131=I=0=0'],
         ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]],
         ['type' => 'scene', 'scene' => 'chambre/cheminee'],
     ],
@@ -191,7 +191,7 @@ $scenes = [
         ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => 'Mqq8VMsmPQtzEQ0'],
         ['type' => 'domoticz', 'scene' => 14, 'command' => true, 'priority' => true],
-        ['type' => 'insteon', 'command' => '0?1131=I=0=0'],
+       // ['type' => 'insteon', 'command' => '0?1131=I=0=0'],
         ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]],
         ['type' => 'scene', 'scene' => 'chambre/cheminee'],
     ],
@@ -200,7 +200,7 @@ $scenes = [
         ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => 'HfMaPG92lEOUDB0'],
         ['type' => 'domoticz', 'scene' => 15, 'command' => true, 'priority' => true],
-        ['type' => 'insteon', 'command' => '0?1131=I=0=0'],
+        //['type' => 'insteon', 'command' => '0?1131=I=0=0'],
         ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]],
         ['type' => 'scene', 'scene' => 'chambre/cheminee'],
     ],
@@ -211,7 +211,7 @@ $scenes = [
     'chambre/summernight' => [
         ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'scene', 'scene' => 'chambre/nightlights'],
-        ['type' => 'insteon', 'command' => '0?1131=I=0=0'],
+        //['type' => 'insteon', 'command' => '0?1131=I=0=0'],
         ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]],
         ['type' => 'scene', 'scene' => 'chambre/cheminee'],
     ],
@@ -220,7 +220,7 @@ $scenes = [
         ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => 'XGuSVQ3RCd7JUBC'],
         ['type' => 'domoticz', 'scene' => 17, 'command' => true, 'priority' => true],
-        ['type' => 'insteon', 'command' => '0?1131=I=0=0'],
+       // ['type' => 'insteon', 'command' => '0?1131=I=0=0'],
         ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]],
         ['type' => 'scene', 'scene' => 'chambre/cheminee'],
     ],
@@ -229,7 +229,7 @@ $scenes = [
         ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => 'ZkiQbNQDXJz9-OC'],
         ['type' => 'domoticz', 'scene' => 18, 'command' => true, 'priority' => true],
-        ['type' => 'insteon', 'command' => '0?1132=I=0=0'],
+       // ['type' => 'insteon', 'command' => '0?1132=I=0=0'],
         ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]],
         ['type' => 'scene', 'scene' => 'chambre/cheminee'],
     ],
@@ -242,7 +242,7 @@ $scenes = [
         ['type' => 'function', 'function' => 'chambreAuto', 'args' => [false]],
         ['type' => 'state', 'key' => 'chambre', 'value' => 0],
         ['type' => 'hue', 'group' => $chambre, 'scene' => array('on' => false, 'brightness' => 0)],
-        ['type' => 'insteon', 'command' => '0?1332=I=0=0'],
+       // ['type' => 'insteon', 'command' => '0?1332=I=0=0'],
         ['type' => 'domoticz', 'scene' => 19, 'command' => false, 'priority' => true],
     ],
 
@@ -274,10 +274,10 @@ $scenes = [
         ['type' => 'hue', 'light' => $litvincent, 'scene' => array('on' => true, 'brightness' => 20, 'hue' => 0, 'saturation' => 255, 'transitionTime' => 1)],
     ],
     'chambre/vincent/crepuscule' => [
-        ['type' => 'insteon', 'command' => '3?0262261ED00F1300=I=3'],
+       // ['type' => 'insteon', 'command' => '3?0262261ED00F1300=I=3'],
         ['type' => 'hue', 'light' => $litvincent, 'scene' => array('on' => true, 'brightness' => 60, 'hue' => '0', 'saturation' => 255, 'transitionTime' => 10)],
         ['type' => 'hue', 'light' => $litvincent, 'scene' => array('on' => false, 'brightness' => 0, 'transitionTime' => 10 * 60)],
-        ['type' => 'insteon', 'command' => '3?0262261ED00F11FF=I=3'],
+        //['type' => 'insteon', 'command' => '3?0262261ED00F11FF=I=3'],
     ],
     'chambre/vincent/aube' => [
         ['type' => 'hue', 'light' => $litvincent, 'scene' => array('on' => true, 'brightness' => 0, 'hue' => '46920', 'saturation' => 255, 'transitionTime' => 0)],
@@ -332,13 +332,13 @@ $scenes = [
     ],
     'salon/on' => [
         ['type' => 'hue', 'group' => $salon, 'scene' => 'Gte8sl76rzAD1wO'],
-        ['type' => 'insteon', 'command' => '0?113=I=0=0'],
+        //['type' => 'insteon', 'command' => '0?113=I=0=0'],
         ['type' => 'scene', 'scene' => 'salon/cheminee', 'delay' => 1],
         ['type' => 'hue', 'group' => $salon, 'scene' => 'Gte8sl76rzAD1wO'],
     ],
     'salon/off' => [
         ['type' => 'hue', 'group' => $salon, 'scene' => array('on' => false)],
-        ['type' => 'insteon', 'command' => '0?133=I=0=0'],
+        //['type' => 'insteon', 'command' => '0?133=I=0=0'],
         ['type' => 'function', 'function' => 'chemineeOff', 'args' => ['salon']],
         ['type' => 'hue', 'group' => $salon, 'scene' => array('on' => false)],
         ['type' => 'scene', 'scene' => 'salon/fan/off'],
@@ -346,7 +346,7 @@ $scenes = [
     'salon/cinemabase' => [
         ['type' => 'scene', 'scene' => 'cuisine/tamise'],
         ['type' => 'ecomode', 'mode' => '0'],
-        ['type' => 'insteon', 'command' => '0?1111=I=0=0'],
+       // ['type' => 'insteon', 'command' => '0?1111=I=0=0'],
     ],
     'salon/cineclub' => [
         ['type' => 'hue', 'group' => $salon, 'scene' => 'xpCjXtV3u7O1kYu'],
@@ -361,13 +361,13 @@ $scenes = [
     'salon/tamise' => [
         ['type' => 'ecomode', 'mode' => '0'],
         ['type' => 'hue', 'group' => $salon, 'scene' => 'RbjnIcLtcDuHbfU'],
-        ['type' => 'insteon', 'command' => '0?1130=I=0=0'],
+       // ['type' => 'insteon', 'command' => '0?1130=I=0=0'],
         ['type' => 'function', 'function' => 'chemineeOn', 'args' => ['salon', 'fire', 0.8]],
         ['type' => 'hue', 'group' => $salon, 'scene' => 'RbjnIcLtcDuHbfU'],
     ],
     'salon/lecturenocture' => [
         ['type' => 'hue', 'group' => $salon, 'scene' => 'HZiYyM6hMUMkmiY'],
-        ['type' => 'insteon', 'command' => '0?1113=I=0=0'],
+       // ['type' => 'insteon', 'command' => '0?1113=I=0=0'],
         ['type' => 'function', 'function' => 'chemineeOn', 'args' => ['salon', 'fire', 0.25]],
         ['type' => 'hue', 'group' => $salon, 'scene' => 'HZiYyM6hMUMkmiY'],
     ],
@@ -518,7 +518,7 @@ $scenes = [
         ['type' => 'domoticz', 'device' => '391', 'command' => 'Toggle', 'priority' => true],
     ],
     'insteon/off' => [
-        ['type' => 'insteon', 'command' => '0?135=I=0=0'],
+       // ['type' => 'insteon', 'command' => '0?135=I=0=0'],
     ],
     'home/off' => [
         ['type' => 'scene', 'scene' => 'home/hueoff'],
@@ -814,6 +814,7 @@ function sdbToggle()
 
 function wcOn($vmc = true)
 {
+
     $hour = getHour();
     if (getNightMode()) {
         $period = 'night';
@@ -1039,14 +1040,29 @@ function updateCourAuto()
 
 function wcVMCOn()
 {
+    setState('lastVMCOn', time());
     // Start VMC
     insteonCommand('0?1134=I=0=0');
 }
 
-function wcVMCOff($timeout = 600)
+function wcVMCOff($timeout = 'auto')
 {
-    setState('wcVMCOff', max(getState('wcVMCOff', -1), time() + $timeout));
-    if ($timeout === 0) {
+    if ($timeout === 'auto') {
+        $d = time() - getState('lastVMCOn');
+        if ($d <= 60) {
+            $timeout = 0;
+        } else if ($d > 60 && $d <= 120) {
+            $timeout = 60;
+        } else if ($d > 120 && $d <= 300) {
+            $timeout = 300;
+        } else {
+            $timeout = 600;
+        }
+    }
+    $t = time() + $timeout;
+    $max = max(getState('wcVMCOff', -1), $t);
+    setState('wcVMCOff', $max);
+    if ($max <= time()) {
         execScene('wc/vmc/off');
     }
 }
@@ -1055,7 +1071,7 @@ function checkWCVMC()
 {
     $offtime = getState('wcVMCOff', -1);
     $time = time();
-    if ($offtime == -1 || $offtime > $time) {
+    if ($offtime == -1 || $offtime > $time || getState('lastVMCOn') > $offtime) {
         return;
     }
     execScene('wc/vmc/off');