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

index c697114fb5f20232618ab088060f77130b52cec8..dff337d5a1e4ed0e5ce593878f039c39dfb37bde 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/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" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
       <workItem from="1642240002240" duration="1108000" />
       <workItem from="1642761590471" duration="1992000" />
       <workItem from="1642848701157" duration="3435000" />
-      <workItem from="1642856038290" duration="4553000" />
-    </task>
-    <task id="LOCAL-00459" summary=".">
-      <created>1616837743511</created>
-      <option name="number" value="00459" />
-      <option name="presentableId" value="LOCAL-00459" />
-      <option name="project" value="LOCAL" />
-      <updated>1616837743512</updated>
+      <workItem from="1642856038290" duration="5632000" />
     </task>
     <task id="LOCAL-00460" summary=".">
       <created>1616837886170</created>
       <option name="project" value="LOCAL" />
       <updated>1642860905685</updated>
     </task>
-    <option name="localTasksCounter" value="508" />
+    <task id="LOCAL-00508" summary=".">
+      <created>1642863251325</created>
+      <option name="number" value="00508" />
+      <option name="presentableId" value="LOCAL-00508" />
+      <option name="project" value="LOCAL" />
+      <updated>1642863251325</updated>
+    </task>
+    <option name="localTasksCounter" value="509" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
index f818101714fc43ebf437953711cb1b21909c57e2..55620f66a0329538d37f80a766a1632b70e1a394 100644 (file)
@@ -14,6 +14,7 @@ function cronOneLoop($cronmin)
     cronMagnet($cronmin);
 
     if ($cronmin % 5 == 0) {
+        cronHotWater($cronmin);
         cronTraffic($cronmin, false);
         cronVelib($cronmin);
         cronGuest($cronmin);
@@ -53,6 +54,11 @@ function cronOneLoop($cronmin)
     _logSection('End Loop (min:' . $cronmin . ')');
 }
 
+function cronHotWater($cronmin)
+{
+    hotwaterCheckMode();
+}
+
 function cronMagnet($cronmin)
 {
     _logSection('Magnet links');
index 79f270db9d7d6ad5ba7f9312a7749d47f97a7eb4..20211fa7f59e3a9c075777d13c4d21ab7a61eb3c 100644 (file)
@@ -322,6 +322,7 @@ $scenes = [
         ['type' => 'function', 'function' => 'stopAllSqueezebox'],
         ['type' => 'nightmode', 'mode' => '1'],
         ['type' => 'ecomode', 'mode' => '1'],
+        ['type' => 'function', 'key' => 'hotwaterAutoMode', 'args' => ['1']],
     ],
     'home/music/synchro/soiree' => [
         ['type' => 'function', 'function' => 'syncMusic', 'args' => [['Salon', 'Cuisine', 'Bureau', 'WC']]],
@@ -645,6 +646,7 @@ $scenes = [
     'home/off' => [
         ['type' => 'scene', 'scene' => 'home/hueoff'],
         ['type' => 'ecomode', 'mode' => '2'],
+        ['type' => 'function', 'key' => 'hotwaterAutoMode', 'args' => ['1']],
         //['type' => 'scene', 'scene' => 'cuisine/off'],
         ['type' => 'scene', 'scene' => 'salon/off'],
         ['type' => 'scene', 'scene' => 'cour/off'],
@@ -729,16 +731,20 @@ $scenes = [
         ['type' => 'domoticz', 'device' => '476', 'command' => false, 'priority' => true],
     ],
     'sdb/hotwater/eco' => [
+        ['type' => 'function', 'key' => 'hotwaterAutoMode', 'args' => ['0']],
         ['type' => 'function', 'function' => 'hotwater', 'args' => ['1']],
     ],
     'sdb/hotwater/max' => [
+        ['type' => 'function', 'key' => 'hotwaterAutoMode', 'args' => ['0']],
         ['type' => 'function', 'function' => 'hotwater', 'args' => ['2']],
     ],
     'sdb/hotwater/off' => [
+        ['type' => 'function', 'key' => 'hotwaterAutoMode', 'args' => ['0']],
         ['type' => 'function', 'function' => 'hotwater', 'args' => ['0']],
     ],
     'sdb/off' => [
         ['type' => 'state', 'key' => 'sdb', 'value' => 0],
+        ['type' => 'function', 'key' => 'hotwaterAutoMode', 'args' => ['1']],
         ['type' => 'domoticz', 'scene' => 20, 'command' => false, 'priority' => true],
         ['type' => 'function', 'function' => 'stopSqueezeboxPlayer', 'args' => [$squeezeboxPlayers['Salle de bains'], false]],
     ],
index 6e2c55e88c5b88ccd58cb9e2168b762f7d82b43a..61ee59b44c78d027580743324578ec0a0d318fe7 100644 (file)
@@ -12,6 +12,38 @@ function switchbot($device, $command = 'press')
     return $res;
 }
 
+function hotwaterAutoMode($mode)
+{
+    $mode = $mode ? '1' : '0';
+    setState('hotwater_auto_mode', $mode);
+    if ($mode) {
+        hotwaterCheckMode();
+    }
+}
+
+function hotwaterCheckMode()
+{
+
+    if (getState('hotwater_auto_mode', '1') == '0') {
+        return;
+    }
+
+    if (getSqueezePlayerStatus('Salle de bains')) {
+        $hot = '2';
+    } else {
+        $ecomode = getState('ecomode', '0');
+        if ($ecomode == '0') {
+            $hot = '1';
+        } else if ($ecomode == '2') {
+            $hot = '0';
+        } else if ($ecomode == '1') {
+            $h = date('G');
+            $hot = ($h > 6 && $h < 10) ? '1' : '0';
+        }
+    }
+    hotwater($hot);
+}
+
 function hotwater($newState)
 {
     // 0 : OFF