]> _ Git - tortuga-home.git/commitdiff
.
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 13 Oct 2022 06:04:13 +0000 (08:04 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 13 Oct 2022 06:04:13 +0000 (08:04 +0200)
.idea/workspace.xml
scripts/lib/switchbot.php

index 8ec9af622f472be64dee656fc567afa7a50da932..4128cb0e52999b536e8781133e8ae9d1a7f4ae57 100644 (file)
@@ -2,16 +2,7 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
-      <change afterPath="$PROJECT_DIR$/lib/caldav-client-v2.php" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/scripts/ical.php" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/scripts/lib/ical.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/.docker/phpdocker/php-fpm/Dockerfile" beforeDir="false" afterPath="$PROJECT_DIR$/.docker/phpdocker/php-fpm/Dockerfile" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/.idea/deployment.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/deployment.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/index.php" beforeDir="false" afterPath="$PROJECT_DIR$/index.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/scripts/core" beforeDir="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/redis.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/redis.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="1664987779048" duration="543000" />
       <workItem from="1664988360545" duration="634000" />
       <workItem from="1665630775990" duration="1219000" />
-      <workItem from="1665632309048" duration="8175000" />
-    </task>
-    <task id="LOCAL-00481" summary=".">
-      <created>1620207485516</created>
-      <option name="number" value="00481" />
-      <option name="presentableId" value="LOCAL-00481" />
-      <option name="project" value="LOCAL" />
-      <updated>1620207485516</updated>
+      <workItem from="1665632309048" duration="8544000" />
     </task>
     <task id="LOCAL-00482" summary=".">
       <created>1620572516162</created>
       <option name="project" value="LOCAL" />
       <updated>1665632976124</updated>
     </task>
-    <option name="localTasksCounter" value="530" />
+    <task id="LOCAL-00530" summary=".">
+      <created>1665640717675</created>
+      <option name="number" value="00530" />
+      <option name="presentableId" value="LOCAL-00530" />
+      <option name="project" value="LOCAL" />
+      <updated>1665640717675</updated>
+    </task>
+    <option name="localTasksCounter" value="531" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
index f5f5f5f90eaa71156820a2a63f2ae1a16f63cb90..b00a6b4d91aee5b1240baddf8f66659a482e60aa 100644 (file)
@@ -26,30 +26,33 @@ function hotwaterCheckMode()
         return;
     }
 
-    if (getSqueezePlayerStatus('Salle de bains')) {
-        $hot = '2';
-    } else {
-        $h = date('G');
-        $d = date('N');
-        $isWeek = $d < 6;
+    $h = date('G');
+    $d = date('N');
+    $isWeek = $d < 6;
 
-        $ecomode = (int)getState('ecomode', '0');
+    $ecomode = (int)getState('ecomode', '0');
 
-        if (isJerome()) {
-            $weekColdHours = [0, 1, 2, 3, 4, 5, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 23];
-            if ($ecomode == 0) {
-                $hot = ($isWeek && in_array($h, $weekColdHours)) ? '0' : '1';
-            } else if ($ecomode == 1) {
-                $hot = ($isWeek && $h >= 6 && $h <= 7) ? '1' : '0';
-            } else if ($ecomode == 2) {
+    if (!isVincent()) {
+        $hot = 1;
+    } else {
+        if (getSqueezePlayerStatus('Salle de bains')) {
+            $hot = '2';
+        } else {
+            if (isJerome()) {
+                $weekColdHours = [0, 1, 2, 3, 4, 5, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 23];
+                if ($ecomode == 0) {
+                    $hot = ($isWeek && in_array($h, $weekColdHours)) ? '0' : '1';
+                } else if ($ecomode == 1) {
+                    $hot = ($isWeek && $h >= 6 && $h <= 7) ? '1' : '0';
+                } else if ($ecomode == 2) {
+                    $hot = '0';
+                }
+            } else {
                 $hot = '0';
             }
-        } else {
-            $hot = '0';
         }
-
-        echo "\n\n" . 'J:' . isJerome() . 'H:' . $h . '/D:' . $d . '/W:' . $hot . "\n\n";
     }
+    echo "\n\n" . 'V:' . isVincent() . '/J:' . isJerome() . '/H:' . $h . '/D:' . $d . '/W:' . $hot . "\n\n";
     hotwater($hot);
 }
 
@@ -91,7 +94,21 @@ function hotwater($newState)
 
 function isVincent()
 {
+    return remember('vincent_in_paris', 3600, function () {
+        return _isVincent();
+    });
+}
 
+function _isVincent()
+{
+    $today = new DateTime('now');
+    $events = searchIcalEventDay('dplacements-jrme', $today);
+    foreach ($events as $event) {
+        if (stristr($event['data']['SUMMARY'], '(V)')) {
+            return false;
+        }
+    }
+    return true;
 }
 
 function isJerome()
@@ -112,7 +129,7 @@ function _isJerome()
     $dates = [$yesterday, $today, $tomorrow];
 
     foreach ($dates as $date) {
-        $events = searchIcalEventDay('dplacements-jrme', $today);
+        $events = searchIcalEventDay('dplacements-jrme', $date);
         $count = 0;
         foreach ($events as $event) {
             if (stristr($event['data']['SUMMARY'], '(V)')) {