]> _ Git - tortuga-home.git/commitdiff
.
authorvincent <vincent@enhydra.fr>
Sat, 22 Jan 2022 14:54:11 +0000 (15:54 +0100)
committervincent <vincent@enhydra.fr>
Sat, 22 Jan 2022 14:54:11 +0000 (15:54 +0100)
.idea/workspace.xml
scripts/lib/switchbot.php

index bcbaa9a00199d8b304031899df9ae7f12901407d..c697114fb5f20232618ab088060f77130b52cec8 100644 (file)
@@ -2,16 +2,8 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
-      <change afterPath="$PROJECT_DIR$/config/water.php" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/scripts/hotwater.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/cuisine.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/cuisine.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/config/sdb.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/sdb.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/scripts/lib/lib.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/lib.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/scripts/lib/profile.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/profile.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/switchbot.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/switchbot.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/scripts/lib/tmdb.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/tmdb.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
       <workItem from="1642240002240" duration="1108000" />
       <workItem from="1642761590471" duration="1992000" />
       <workItem from="1642848701157" duration="3435000" />
-      <workItem from="1642856038290" duration="3025000" />
-    </task>
-    <task id="LOCAL-00458" summary=".">
-      <created>1615883286918</created>
-      <option name="number" value="00458" />
-      <option name="presentableId" value="LOCAL-00458" />
-      <option name="project" value="LOCAL" />
-      <updated>1615883286918</updated>
+      <workItem from="1642856038290" duration="4553000" />
     </task>
     <task id="LOCAL-00459" summary=".">
       <created>1616837743511</created>
       <option name="project" value="LOCAL" />
       <updated>1642854570967</updated>
     </task>
-    <option name="localTasksCounter" value="507" />
+    <task id="LOCAL-00507" summary=".">
+      <created>1642860905685</created>
+      <option name="number" value="00507" />
+      <option name="presentableId" value="LOCAL-00507" />
+      <option name="project" value="LOCAL" />
+      <updated>1642860905685</updated>
+    </task>
+    <option name="localTasksCounter" value="508" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
index 34e61e2b00941afed0846dca4a1e2340936f2018..6e2c55e88c5b88ccd58cb9e2168b762f7d82b43a 100644 (file)
@@ -1,7 +1,15 @@
 <?php
 function switchbot($device, $command = 'press')
 {
-    return sshCommand('/usr/bin/python3 /usr/local/python-host/switchbot_py3.py -d ' . $device . ' -c ' . $command, 'bureausun', true, true);
+    for ($i = 0; $i <= 2; $i++) {
+        $res = sshCommand('/usr/bin/python3 /usr/local/python-host/switchbot_py3.py -d ' . $device . ' -c ' . $command, 'bureausun', true, true);
+        if (stristr($res['output'], 'Command execution successful')) {
+            break;
+        }
+        sleep(1);
+    }
+
+    return $res;
 }
 
 function hotwater($newState)
@@ -26,8 +34,10 @@ function hotwater($newState)
     $res = '';
     for ($i = 0; $i < $clicks; $i++) {
         $res .= ' one click - ';
-        $res .= switchbot($device);
-        sleep(5);
+        $res .= print_r(switchbot($device));
+        if ($i < $clicks - 1) {
+            sleep(2);
+        }
     }
     setState('hotwater', $newState);
     setState('hotwater_change', '0');