]> _ Git - tortuga-home.git/commitdiff
.
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 10 Jul 2023 22:09:58 +0000 (00:09 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 10 Jul 2023 22:09:58 +0000 (00:09 +0200)
.idea/workspace.xml
scripts/automodes.php [new file with mode: 0644]
scripts/lib/automodes.php [new file with mode: 0644]
scripts/lib/lib.php
scripts/lib/scenes.php

index 1540e88a6fa599c4125796835cdd72b84e9a641b..bc801c6b14ea54ed52c75c8f6d8720791d21e992 100644 (file)
@@ -5,11 +5,11 @@
   </component>
   <component name="ChangeListManager">
     <list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
-      <change afterPath="$PROJECT_DIR$/scripts/cron/traffic.php" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/scripts/automodes.php" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/scripts/lib/automodes.php" afterDir="false" />
       <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/traffic.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/traffic.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/scripts/lib/velib.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/velib.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/scenes.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/scenes.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
       <workItem from="1688808953960" duration="594000" />
       <workItem from="1688849303515" duration="1558000" />
       <workItem from="1688897001591" duration="22890000" />
-      <workItem from="1689010387612" duration="1396000" />
+      <workItem from="1689010387612" duration="1878000" />
+      <workItem from="1689026578748" duration="401000" />
     </task>
     <task id="LOCAL-00502" summary=".">
       <created>1641726946298</created>
       <option name="project" value="LOCAL" />
       <updated>1687259667913</updated>
     </task>
-    <option name="localTasksCounter" value="569" />
+    <option name="localTasksCounter" value="570" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
     <MESSAGE value="." />
     <option name="LAST_COMMIT_MESSAGE" value="." />
   </component>
-  <component name="XDebuggerManager">
-    <breakpoint-manager>
-      <breakpoints>
-        <line-breakpoint enabled="true" type="php">
-          <url>file://$PROJECT_DIR$/scripts/lib/lib.php</url>
-          <line>98</line>
-          <option name="timeStamp" value="1" />
-        </line-breakpoint>
-      </breakpoints>
-    </breakpoint-manager>
-  </component>
   <component name="XSLT-Support.FileAssociations.UIState">
     <expand />
     <select />
diff --git a/scripts/automodes.php b/scripts/automodes.php
new file mode 100644 (file)
index 0000000..1159251
--- /dev/null
@@ -0,0 +1,8 @@
+<?php
+require_once "import.php";
+if (isset($_GET['disable'])) {
+       disableAutoModes($_GET['disable']);
+}
+if (isset($_GET['enable'])) {
+       enableAutoModes();
+}
\ No newline at end of file
diff --git a/scripts/lib/automodes.php b/scripts/lib/automodes.php
new file mode 100644 (file)
index 0000000..ab20b77
--- /dev/null
@@ -0,0 +1,185 @@
+<?php
+
+function disableAutoModes($duration) {
+       setState('disable_auto_modes', time() + $duration);
+}
+
+function enableAutoModes() {
+       setState('disable_auto_modes', 0);
+}
+
+function isAutoModeEnabled() {
+       return getState('disable_auto_modes', 0) < time();
+}
+
+
+function autoRooms() {
+       if (isAutoModeEnabled()) {
+               if (getState('bureauAutoMode') == '1') {
+                       updateBureauAuto();
+               }
+               if (getState('chambreAutoMode') == '1') {
+                       updateChambreAuto();
+               }
+               if (getState('courAutoMode') == '1') {
+                       updateCourAuto();
+               }
+               if (getState('salonAutoMode') == '1') {
+                       updateSalonAuto();
+               }
+               updateCuisine();
+       }
+       checkPlanetarium();
+       checkWCVMC();
+}
+
+function updateBureauAuto() {
+       if (getState('bureauOff') == '1') {
+               execScene('bureau/off');
+               return;
+       }
+       if (getState('bureauAutoMode') != '1') {
+               return;
+       }
+       $hours = intval(date('H'));
+       if ($hours <= 4) {
+               $scene = 'outrun';
+       } else if ($hours <= 9) {
+               $scene = 'boreal';
+       } else if ($hours <= 11) {
+               $scene = 'tonic';
+       } else if ($hours <= 14) {
+               $scene = 'flowers';
+       } else if ($hours <= 18) {
+               $scene = 'beach';
+       } else if ($hours <= 22) {
+               $scene = 'tropical';
+       } else {
+               $scene = 'outrun';
+       }
+       execScene('bureau/' . $scene);
+}
+
+function updateCuisine() {
+       $salon = getState('salon', 'off');
+       if ($salon === 'day' || $salon === 'on' || $salon === 'off' || $salon === 'tamise') {
+               execScene('cuisine/base/on');
+       } else if ($salon == 'cinema') {
+               execScene('cuisine/tamise');
+       }
+}
+
+function updateCourAuto() {
+       $h = date('H');
+       if ($h >= 7) {
+               execScene('cour/projecteurs/off');
+       } else {
+               execScene('cour/projecteurs/on');
+       }
+       if (getState('courOff') == '1') {
+               execScene('cour/off');
+               return;
+       }
+       if (getState('courAutoMode') != '1') {
+               return;
+       }
+       if (isDay()) {
+               $scene = 'daylight';
+       } else {
+               $scene = 'lumineux';
+       }
+       execScene('cour/' . $scene);
+}
+
+function salonAuto($on = true) {
+       if ($on) {
+               setState('salonOff', '0');
+               setState('salonAutoMode', '1');
+               updateSalonAuto();
+       } else if (getState('salonAutoMode') === '1') {
+               setState('salonAutoMode', '0');
+       }
+}
+
+function chambreAuto($on = true, $transitionTime = null) {
+       if ($on) {
+               ecoMode(0);
+               setState('chambreAutoMode', '1');
+               updateChambreAuto($transitionTime);
+       } else if (getState('chambreAutoMode') === '1') {
+               setState('chambreAutoMode', '0');
+       }
+}
+
+function bureauAuto($on = true) {
+       if ($on) {
+               setState('bureauAutoMode', '1');
+               updateBureauAuto();
+       } else {
+               setState('bureauAutoMode', '0');
+       }
+}
+
+function courAuto($on = true) {
+       if ($on) {
+               setState('courAutoMode', '1');
+               updateCourAuto();
+       } else {
+               setState('courAutoMode', '0');
+       }
+}
+
+function updateSalonAuto() {
+       if (getState('salonOff') == '1') {
+               execScene('salon/off');
+               return;
+       }
+       if (getState('salonAutoMode') != '1') {
+               return;
+       }
+       $d = date('w');
+       $hours = intval(date('H'));
+       if ($d < 5) {
+               if ($hours <= 9) {
+                       $scene = 'tamise';
+               } else if ($hours <= 22) {
+                       $scene = 'day';
+               } else {
+                       $scene = 'tamise';
+               }
+       } else {
+               if ($hours <= 9) {
+                       $scene = 'tamise';
+               } else {
+                       $scene = 'day';
+               }
+       }
+       execScene('salon/' . $scene, false);
+}
+
+function updateChambreAuto($transitionTime = null) {
+       if (getState('chambreOff') == '1') {
+               execScene('chambre/off');
+               return;
+       }
+       if (getState('chambreAutoMode') != '1') {
+               return;
+       }
+       $hours = intval(date('H'));
+       if ($hours <= 4) {
+               $scene = 'party';
+       } else if ($hours <= 9) {
+               $scene = 'boreal';
+       } else if ($hours <= 11) {
+               $scene = 'tonic';
+       } else if ($hours <= 14) {
+               $scene = 'flowers';
+       } else if ($hours <= 18) {
+               $scene = 'beach';
+       } else if ($hours <= 22) {
+               $scene = 'tropical';
+       } else {
+               $scene = 'party';
+       }
+       execScene('chambre/' . $scene, false, $transitionTime);
+}
index df9237d63b2a3595cf3194d94982def4db5dc6f5..94c6e779b83f0c3292a600363142717c5fd32d20 100644 (file)
@@ -10,6 +10,7 @@ require_once ROOT . '/vendor/autoload.php';
 require_once ROOT . '/scripts/lib/profile.php';
 require_once ROOT . "/config/global.php";
 require_once ROOT . '/config/rooms.php';
+require_once ROOT . '/scripts/lib/automodes.php';
 require_once ROOT . '/scripts/lib/homeassistant.php';
 require_once ROOT . '/scripts/lib/redis.php';
 require_once ROOT . '/scripts/lib/state.php';
index c6c2423cb6ba83953a0706b8574845a325494d4a..09153d60550f3c2ef03ba003ff7f272da9fe57b1 100644 (file)
@@ -1148,156 +1148,7 @@ function bedbrightness($brightness) {
        sshCommand($cmd, 'litjerome');
 }
 
-function salonAuto($on = true) {
-       if ($on) {
-               setState('salonOff', '0');
-               setState('salonAutoMode', '1');
-               updateSalonAuto();
-       } else if (getState('salonAutoMode') === '1') {
-               setState('salonAutoMode', '0');
-       }
-}
-
-function chambreAuto($on = true, $transitionTime = null) {
-       if ($on) {
-               ecoMode(0);
-               setState('chambreAutoMode', '1');
-               updateChambreAuto($transitionTime);
-       } else if (getState('chambreAutoMode') === '1') {
-               setState('chambreAutoMode', '0');
-       }
-}
-
-function bureauAuto($on = true) {
-       if ($on) {
-               setState('bureauAutoMode', '1');
-               updateBureauAuto();
-       } else {
-               setState('bureauAutoMode', '0');
-       }
-}
-
-function courAuto($on = true) {
-       if ($on) {
-               setState('courAutoMode', '1');
-               updateCourAuto();
-       } else {
-               setState('courAutoMode', '0');
-       }
-}
 
-function updateSalonAuto() {
-       if (getState('salonOff') == '1') {
-               execScene('salon/off');
-               return;
-       }
-       if (getState('salonAutoMode') != '1') {
-               return;
-       }
-       $d = date('w');
-       $hours = intval(date('H'));
-       if ($d < 5) {
-               if ($hours <= 9) {
-                       $scene = 'tamise';
-               } else if ($hours <= 22) {
-                       $scene = 'day';
-               } else {
-                       $scene = 'tamise';
-               }
-       } else {
-               if ($hours <= 9) {
-                       $scene = 'tamise';
-               } else {
-                       $scene = 'day';
-               }
-       }
-       execScene('salon/' . $scene, false);
-}
-
-function updateChambreAuto($transitionTime = null) {
-       if (getState('chambreOff') == '1') {
-               execScene('chambre/off');
-               return;
-       }
-       if (getState('chambreAutoMode') != '1') {
-               return;
-       }
-       $hours = intval(date('H'));
-       if ($hours <= 4) {
-               $scene = 'party';
-       } else if ($hours <= 9) {
-               $scene = 'boreal';
-       } else if ($hours <= 11) {
-               $scene = 'tonic';
-       } else if ($hours <= 14) {
-               $scene = 'flowers';
-       } else if ($hours <= 18) {
-               $scene = 'beach';
-       } else if ($hours <= 22) {
-               $scene = 'tropical';
-       } else {
-               $scene = 'party';
-       }
-       execScene('chambre/' . $scene, false, $transitionTime);
-}
-
-function updateBureauAuto() {
-       if (getState('bureauOff') == '1') {
-               execScene('bureau/off');
-               return;
-       }
-       if (getState('bureauAutoMode') != '1') {
-               return;
-       }
-       $hours = intval(date('H'));
-       if ($hours <= 4) {
-               $scene = 'outrun';
-       } else if ($hours <= 9) {
-               $scene = 'boreal';
-       } else if ($hours <= 11) {
-               $scene = 'tonic';
-       } else if ($hours <= 14) {
-               $scene = 'flowers';
-       } else if ($hours <= 18) {
-               $scene = 'beach';
-       } else if ($hours <= 22) {
-               $scene = 'tropical';
-       } else {
-               $scene = 'outrun';
-       }
-       execScene('bureau/' . $scene);
-}
-
-function updateCuisine() {
-       $salon = getState('salon', 'off');
-       if ($salon === 'day' || $salon === 'on' || $salon === 'off' || $salon === 'tamise') {
-               execScene('cuisine/base/on');
-       } else if ($salon == 'cinema') {
-               execScene('cuisine/tamise');
-       }
-}
-
-function updateCourAuto() {
-       $h = date('H');
-       if ($h >= 7) {
-               execScene('cour/projecteurs/off');
-       } else {
-               execScene('cour/projecteurs/on');
-       }
-       if (getState('courOff') == '1') {
-               execScene('cour/off');
-               return;
-       }
-       if (getState('courAutoMode') != '1') {
-               return;
-       }
-       if (isDay()) {
-               $scene = 'daylight';
-       } else {
-               $scene = 'lumineux';
-       }
-       execScene('cour/' . $scene);
-}
 
 function wcVMCOn() {
        setState('lastVMCOn', time());
@@ -1399,21 +1250,3 @@ function alert() {
        }
 
 }
-
-function autoRooms() {
-       if (getState('bureauAutoMode') == '1') {
-               updateBureauAuto();
-       }
-       if (getState('chambreAutoMode') == '1') {
-               updateChambreAuto();
-       }
-       if (getState('courAutoMode') == '1') {
-               updateCourAuto();
-       }
-       if (getState('salonAutoMode') == '1') {
-               updateSalonAuto();
-       }
-       updateCuisine();
-       checkPlanetarium();
-       checkWCVMC();
-}
\ No newline at end of file