]> _ Git - tortuga-home.git/commitdiff
.
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 14 Nov 2022 08:37:12 +0000 (09:37 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 14 Nov 2022 08:37:12 +0000 (09:37 +0100)
.idea/workspace.xml
config/water.php
scripts/hotwater.php
scripts/lib/redis.php
scripts/lib/scenes.php
scripts/lib/switchbot.php

index 044a998308be3306afb078a196a7d5c01bbbfef1..9a82287e0248975dc70a35407bbb8be0e26a053d 100644 (file)
@@ -3,8 +3,9 @@
   <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$/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$/config/water.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/water.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/hotwater.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/hotwater.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/redis.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/redis.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>
       <workItem from="1666880430659" duration="1177000" />
       <workItem from="1667037570905" duration="1563000" />
       <workItem from="1667739527547" duration="1293000" />
-      <workItem from="1668006276656" duration="977000" />
-    </task>
-    <task id="LOCAL-00492" summary=".">
-      <created>1639205467698</created>
-      <option name="number" value="00492" />
-      <option name="presentableId" value="LOCAL-00492" />
-      <option name="project" value="LOCAL" />
-      <updated>1639205467698</updated>
+      <workItem from="1668006276656" duration="1860000" />
+      <workItem from="1668260964528" duration="1497000" />
     </task>
     <task id="LOCAL-00493" summary=".">
       <created>1639302540066</created>
       <option name="project" value="LOCAL" />
       <updated>1667752233866</updated>
     </task>
-    <option name="localTasksCounter" value="541" />
+    <task id="LOCAL-00541" summary=".">
+      <created>1668013144815</created>
+      <option name="number" value="00541" />
+      <option name="presentableId" value="LOCAL-00541" />
+      <option name="project" value="LOCAL" />
+      <updated>1668013144815</updated>
+    </task>
+    <option name="localTasksCounter" value="542" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
index ac998a147c8eb9b8564cb145deb4360fff096ac8..4f682758bc6cb050dfb098254ac2e51bd34c540b 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 $shortcuts['water'] = [
-    ['type' => 'light', 'scene' => 'sdb/hotwater/auto', 'label' => 'Auto'],
+    ['type' => 'light', 'scene' => 'sdb/hotwater/auto/force', 'label' => 'Auto'],
     ['type' => 'light', 'scene' => 'sdb/hotwater/eco', 'label' => 'Eco'],
     ['type' => 'light', 'scene' => 'sdb/hotwater/max', 'label' => 'Max'],
     ['type' => 'light', 'scene' => 'sdb/hotwater/off', 'label' => 'Off'],
index 00f85baa36b72b9331d1308e825e72c032705df9..b9e52d2eba41ed2741c6ca6b9f150df8554df4a9 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 require_once "import.php";
 echo "\n\n";
-hotwaterCheckMode();
+hotwaterCheckMode(true);
 echo "\n\n";
 echo getState('hotwater');
 if (isset($_GET['on'])) {
index f56cb2b8340aa2010492e0fee0334c245f98c7db..ca38a4be63442b2a7582ad09989ba36576a891e9 100644 (file)
@@ -112,11 +112,11 @@ function redisEventListener($channel, $callback)
  * @param $closure Closure
  * @return mixed
  */
-function remember($key, $ttl, $closure, $default = null)
+function remember($key, $ttl, $closure, $default = null, $force = false)
 {
     $rememberSaveKey = $key . '_save_remember';
     $client = getRedisClient();
-    if (!$client->exists($key)) {
+    if ($force || !$client->exists($key)) {
         try {
             $data = call_user_func($closure);
         } catch (Exception $e) {
index 3aa03da715e28a3bf031b355e6c6f8cf1cfd6502..05f3650e60eb70e0c85b2882ce52f7a633882c61 100644 (file)
@@ -758,6 +758,9 @@ $scenes = [
     'sdb/hotwater/auto' => [
         ['type' => 'function', 'function' => 'hotwaterAutoMode', 'args' => ['1']],
     ],
+    'sdb/hotwater/auto/force' => [
+        ['type' => 'function', 'function' => 'hotwaterAutoMode', 'args' => ['1',true]],
+    ],
     'sdb/hotwater/eco' => [
         ['type' => 'function', 'function' => 'hotwaterAutoMode', 'args' => ['0']],
         ['type' => 'function', 'function' => 'hotwater', 'args' => ['1']],
index 6879c7538d31b49abc4ba7081bcf64082698350d..05ee08336ffd297081c5a9dbc450af08cb930c79 100644 (file)
@@ -11,29 +11,32 @@ function switchbot($device, $command = 'press', $rpi = 'sdb')
     return $res;
 }
 
-function hotwaterAutoMode($mode)
+function hotwaterAutoMode($mode, $force = false)
 {
     $mode = $mode ? '1' : '0';
     setState('hotwater_auto_mode', $mode);
     if ($mode) {
-        hotwaterCheckMode();
+        hotwaterCheckMode($force);
     }
 }
 
-function hotwaterCheckMode()
+function hotwaterCheckMode($force = false)
 {
     if (getState('hotwater_auto_mode', '1') == '0') {
         return;
     }
 
+    $jerome = isJerome(true, $force);
+    $vincent = isVincent($force);
+
     $h = date('G');
     $d = date('N');
     $isWeek = $d < 6;
-    $maxLevel = isJerome() ? "2" : '1';
+    $maxLevel = $jerome ? "2" : '1';
 
     $ecomode = (int)getState('ecomode', '0');
 
-    if (!isVincent()) {
+    if (!isVincent($force)) {
         $hot = '1';
     } else {
         if (getSqueezePlayerStatus('Salle de bains')) {
@@ -53,7 +56,7 @@ function hotwaterCheckMode()
             }
         }
     }
-    echo "\n\n" . 'V:' . isVincent() . '/J:' . isJerome() . '/H:' . $h . '/D:' . $d . '/W:' . $hot . "\n\n";
+    echo "\n\n" . 'V:' . $vincent . '/J:' . $jerome . '/H:' . $h . '/D:' . $d . '/W:' . $hot . "\n\n";
     hotwater($hot);
 }
 
@@ -64,7 +67,6 @@ function hotwater($newState)
     // 1 : ECO
     // 2 : MAX
 
-
     echo getState('hotwater_auto_mode', '1') . '::' . getState('hotwater_change', '0') . '::' . getState('hotwater', '1');
     $changing = getState('hotwater_change', '0');
     $limit = time() - 300;
@@ -94,11 +96,11 @@ function hotwater($newState)
     return $res;
 }
 
-function isVincent()
+function isVincent($force = false)
 {
     return remember('vincent_in_paris', 3600, function () {
         return _isVincent();
-    }, true);
+    }, true, $force);
 }
 
 function _isVincent()
@@ -113,13 +115,13 @@ function _isVincent()
     return true;
 }
 
-function isJerome($strict = true)
+function isJerome($strict = true, $force = false)
 {
     $key = 'jerome_in_paris' . ($strict ? '' : '_1');
 
     return remember($key, 3600, function () use ($strict) {
         return _isJerome($strict);
-    }, true);
+    }, true, $force);
 }
 
 function _isJerome($strict = true)