]> _ Git - tortuga-home.git/commitdiff
.
authorvincent <vincent@enhydra.fr>
Sat, 22 Jan 2022 12:29:30 +0000 (13:29 +0100)
committervincent <vincent@enhydra.fr>
Sat, 22 Jan 2022 12:29:30 +0000 (13:29 +0100)
.idea/workspace.xml
scripts/lib/lib.php
scripts/lib/switchbot.php [new file with mode: 0644]

index 9324f9354515f18462733e205ec51275550aebc3..5b836148de50d2291cbd5cb657e32946eb704aa2 100644 (file)
@@ -2,8 +2,9 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
+      <change afterPath="$PROJECT_DIR$/scripts/lib/switchbot.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/servers/logcat.php" beforeDir="false" afterPath="$PROJECT_DIR$/servers/logcat.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/lib.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/lib.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
       <workItem from="1642149121693" duration="376000" />
       <workItem from="1642240002240" duration="1108000" />
       <workItem from="1642761590471" duration="1992000" />
-    </task>
-    <task id="LOCAL-00456" summary=".">
-      <created>1615664599666</created>
-      <option name="number" value="00456" />
-      <option name="presentableId" value="LOCAL-00456" />
-      <option name="project" value="LOCAL" />
-      <updated>1615664599667</updated>
+      <workItem from="1642848701157" duration="1843000" />
     </task>
     <task id="LOCAL-00457" summary=".">
       <created>1615881926505</created>
       <option name="project" value="LOCAL" />
       <updated>1642149511288</updated>
     </task>
-    <option name="localTasksCounter" value="505" />
+    <task id="LOCAL-00505" summary=".">
+      <created>1642848715262</created>
+      <option name="number" value="00505" />
+      <option name="presentableId" value="LOCAL-00505" />
+      <option name="project" value="LOCAL" />
+      <updated>1642848715262</updated>
+    </task>
+    <option name="localTasksCounter" value="506" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
index 3fc781075c3049b6113d941b9c6342b9a4f3e1de..5da52c8eb06e20a12745a87fa0e5b3eeb67a8811 100644 (file)
@@ -49,6 +49,7 @@ require_once ROOT . '/scripts/lib/kodi.php';
 require_once ROOT . '/scripts/lib/climacell.php';
 require_once ROOT . '/scripts/lib/homeconnect.php';
 require_once ROOT . '/scripts/lib/wol.php';
+require_once ROOT . '/scripts/lib/switchbot.php';
 
 
 profile('Loaded libraries', __FILE__, __LINE__);
diff --git a/scripts/lib/switchbot.php b/scripts/lib/switchbot.php
new file mode 100644 (file)
index 0000000..0a4bdba
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+function switchbot($device, $command = 'press')
+{
+    sshCommand('/usr/bin/python3 /usr/local/python-host/switchbot_py3.py -d ' . $device . ' -c ' . $command, 'bureausun', true, true);
+}
+
+function hotwater($on = true)
+{
+    $device = 'C1:F7:66:5E:A2:CF';
+    $state = getState('hotwater', '1');
+    $newState = $on ? '1' : '0';
+    if ($newState === $state) {
+        return;
+    }
+    if ($newState === '1') {
+        switchbot($device);
+    } else {
+        switchbot($device);
+        sleep(2);
+        switchbot($device);
+    }
+}
\ No newline at end of file