]> _ Git - tortuga-home.git/commitdiff
.
authorvincent <vincent@enhydra.fr>
Wed, 13 Apr 2022 23:34:05 +0000 (01:34 +0200)
committervincent <vincent@enhydra.fr>
Wed, 13 Apr 2022 23:34:05 +0000 (01:34 +0200)
.idea/workspace.xml
config/coffee.php
scripts/cron/cron.php
scripts/domoticz_device_event.php
scripts/lib/ecomode.php
scripts/lib/lib.php
scripts/lib/scenes.php
scripts/lib/velib.php

index 317c68bf7cd4a37e7b432041e3c99c6d7497935f..d6a18afd0699f7681d5ca2399bf23f5d0607f6d3 100644 (file)
@@ -3,10 +3,12 @@
   <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/coffee.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/coffee.php" 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/domoticz_device_event.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/domoticz_device_event.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/ecomode.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/ecomode.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/light.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/light.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/velib.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/velib.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
       <workItem from="1649747856888" duration="2527000" />
       <workItem from="1649833630727" duration="738000" />
       <workItem from="1649835938314" duration="1458000" />
-      <workItem from="1649877396831" duration="1123000" />
-    </task>
-    <task id="LOCAL-00474" summary=".">
-      <created>1619544331948</created>
-      <option name="number" value="00474" />
-      <option name="presentableId" value="LOCAL-00474" />
-      <option name="project" value="LOCAL" />
-      <updated>1619544331948</updated>
+      <workItem from="1649877396831" duration="6279000" />
     </task>
     <task id="LOCAL-00475" summary=".">
       <created>1619641979806</created>
       <option name="project" value="LOCAL" />
       <updated>1649878144183</updated>
     </task>
-    <option name="localTasksCounter" value="523" />
+    <task id="LOCAL-00523" summary=".">
+      <created>1649878545445</created>
+      <option name="number" value="00523" />
+      <option name="presentableId" value="LOCAL-00523" />
+      <option name="project" value="LOCAL" />
+      <updated>1649878545445</updated>
+    </task>
+    <option name="localTasksCounter" value="524" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
index 6229f74b504731267f3ef7096fd035c6a8bd17e0..31feaef6517bc5efe8e204aafb66e0beb1c4878f 100644 (file)
@@ -4,6 +4,10 @@ $shortcuts['coffee'] = [
     ['type' => 'separator', 'label' => 'Machine à café'],
     ['type' => 'light', 'scene' => 'cuisine/coffee/on', 'label' => 'Allumer'],
     ['type' => 'light', 'scene' => 'cuisine/coffee/off', 'label' => 'éteindre'],
+    ['type' => 'separator', 'label' => 'Hotte'],
+    ['type' => 'light', 'scene' => 'cuisine/hotte/on', 'label' => 'Allumer'],
+    ['type' => 'light', 'scene' => 'cuisine/hotte/off', 'label' => 'éteindre'],
+
 //    ['type' => 'separator', 'label' => 'Cafés'],
 //    ['type' => 'ifttt', 'event' => 'coffee_vincent', 'label' => 'Vincent'],
 //    ['type' => 'ifttt', 'event' => 'coffee_jerome', 'label' => 'Jérôme'],
index 6fb52057c9dd2677cd2625b9ee9b6f49494f3093..a517b7dd2e703f7220c60d2755d4c061e7524ffd 100644 (file)
@@ -123,19 +123,20 @@ function _logSection($t)
 function cronRooms($cronmin)
 {
     _logSection('Rooms');
-    if (getState('bureauAutoMode') == '1') {
-        _logSection('Bureau');
-        updateBureauAuto();
-    }
-    if (getState('chambreAutoMode') == '1') {
-        _logSection('Chambre');
-        updateChambreAuto();
-    }
-    if (getState('courAutoMode') == '1') {
-        _logSection('Cour');
-        updateCourAuto();
-    }
+
+    _logSection('Bureau');
+    updateBureauAuto();
+
+    _logSection('Chambre');
+    updateChambreAuto();
+
     _logSection('Cour');
+    updateCourAuto();
+
+    _logSection('Salon');
+    updateSalonAuto();
+
+    _logSection('Cuisine');
     updateCuisine();
     _logSection('Planetarium');
     checkPlanetarium();
@@ -192,6 +193,9 @@ function cronPing($cronmin)
     setState('vincenthere', ping('192.168.13.20', 5) ? '1' : '0');
     setState('hasnetwork', ping('1.1.1.1', 3, 443) ? '1' : '0');
     foreach ($devices as $name => $device) {
+        if (!isset($device['host'])) {
+            continue;
+        }
         $result = ping($device['host'], 3, 22) ? '1' : '0';
         setState('device_' . $name . '_awake', $result);
         echo 'device_' . $name . '_awake : ' . getState('device_' . $name . '_awake') . "\n";
index 8745543c3c8bd6da65944491e0bbe443a68c36b3..3777b597da253d0631186ac77ed1749eb3c77d7f 100644 (file)
@@ -24,18 +24,18 @@ if (gloria()) {
 
 
 if ($_GET['device'] == 480) {
-    chambreToggle();
+    chambreToggle(true);
 } else if (in_array($_GET['device'], $cubesalon)) {
     // Cube
     switch ($_GET['state']) {
         case 'Shake':
-            execScene('home/alert');
+            execScene('home/alert',true);
             break;
         case 'Flip_90':
-            execScene('salon/cinema');
+            execScene('salon/cinema',true);
             break;
         case 'Flip_180':
-            execScene('salon/auto');
+            execScene('salon/auto',true);
             break;
         case 'Free_Fall':
             off('salon');
@@ -62,11 +62,11 @@ if ($_GET['device'] == 480) {
     $forceConfig = 'wc';
     switch ($_GET['state']) {
         case 'Double_Click':
-            execScene('wc/spa');
+            execScene('wc/spa',true);
             setState('wc', 1);
             break;
         case 'Long_Click':
-            execScene('home/alert');
+            execScene('home/alert',true);
             break;
         case 'Click':
         default:
@@ -77,16 +77,16 @@ if ($_GET['device'] == 480) {
     // Cube bureau
     switch ($_GET['state']) {
         case 'Shake':
-            execScene('home/alert');
+            execScene('home/alert',true);
             break;
         case 'Flip_90':
-            execScene('bureau/rideaux/toggle');
+            execScene('bureau/rideaux/toggle',true);
             break;
         case 'Flip_180':
-            execScene('bureau/auto');
+            execScene('bureau/auto',true);
             break;
         case 'Free_Fall':
-            execScene('bureau/off');
+            execScene('bureau/off',true);
             off('bureau');
             break;
         case 'Move':
@@ -119,13 +119,13 @@ if ($_GET['device'] == 480) {
     // Cube SDB
     switch ($_GET['state']) {
         case 'Shake':
-            execScene('home/alert');
+            execScene('home/alert',true);
             break;
         case 'Flip_90':
-            execScene('sdb/off');
+            execScene('sdb/off',true);
             break;
         case 'Flip_180':
-            execScene('sdb/on');
+            execScene('sdb/on',true);
             break;
         case 'Free_Fall':
             off('sdb');
index 5f9227e875bd4517ed523bb1d2481c41dd2b21b4..2f124b749edc033da365acc591e0869cf862f055 100644 (file)
@@ -34,30 +34,32 @@ function getNightMode()
 {
     $device = config('DEVICE');
     if ($device === 'sdb') {
-        $h = date('G');
-        if ($h > 6 && $h < 21) {
+        $h = date('H');
+        if ($h >= 6 && $h <= 8) {
             return false;
         }
-    }
-    if ($device === 'salon') {
+        if (getState('chambreOff')) {
+            return true;
+        }
+    } else if ($device === 'salon') {
         if (getState('salon') !== 'off') {
             return false;
         }
-    }
-    if ($device === 'bureau' || $device === 'bureausun') {
+    } else if ($device === 'bureau' || $device === 'bureausun') {
+        if (getState('bureauOff') == '1') {
+            return true;
+        }
         if (getDomoticzDeviceStatus(391) === 'Closed') {
             return true;
         }
         if (getState('bureau_gradient') !== 'off') {
             return false;
         }
-    }
-    if ($device === 'wc') {
+    } else if ($device === 'wc') {
         if (getState('bureau_gradient') !== 'off') {
             return false;
         }
-    }
-    if ($device === 'entree' || $device === 'cuisine') {
+    } else if ($device === 'entree' || $device === 'cuisine') {
         $lights = [15, 18, 1, 58, 59, 57, 56, 55, 37];
         $hueLights = getHueInstance()->getLights();
         foreach ($lights as $l) {
@@ -66,7 +68,12 @@ function getNightMode()
                 return false;
             }
         }
+    } else if ($device === 'chambre' || $device === 'litjerome' || $device === 'litvincent') {
+        if (getState('chambreOff')) {
+            return true;
+        }
     }
+
     return getState('night') == '1';
 }
 
index 6333dad475a5ff2b9ea017133fc9a31def39cec9..417e34352f3044abfa51abe6a62d742e7ccce9f1 100644 (file)
@@ -95,8 +95,7 @@ function getCurrentConfig()
     }
 
     if (!isset($_COOKIE['homeconfig'])) {
-
-        if (isset($ips[$_SERVER['REMOTE_ADDR']])) {
+        if (isset($_SERVER['REMOTE_ADDR']) && isset($ips[$_SERVER['REMOTE_ADDR']])) {
             $c = $ips[$_SERVER['REMOTE_ADDR']];
         } else {
             $c = 'salon';
index 113a4adceeb4436ea319afbde90898f50f8207fb..047764546c52a24d58a49171dbb566ba94b26539 100644 (file)
@@ -111,7 +111,6 @@ $scenes = [
 
     'chambre/boreal' => [
         ['type' => 'nightmode', 'mode' => '0'],
-        ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => 'mwAGvt2n70oXCqA'],
         ['type' => 'domoticz', 'scene' => 4, 'command' => true, 'priority' => true],
         //['type' => 'insteon', 'command' => '0?1131=I=0=0'],
@@ -119,7 +118,6 @@ $scenes = [
     ],
     'chambre/savane' => [
         ['type' => 'nightmode', 'mode' => '0'],
-        ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => 'ABqCuE-ob-sw2vQ'],
         ['type' => 'domoticz', 'scene' => 5, 'command' => true, 'priority' => true],
         //['type' => 'insteon', 'command' => '0?1131=I=0=0'],
@@ -127,7 +125,6 @@ $scenes = [
     ],
     'chambre/focus' => [
         ['type' => 'nightmode', 'mode' => '0'],
-        ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => 'Ne6uJnnoPO9yRhl'],
         ['type' => 'domoticz', 'scene' => 6, 'command' => true, 'priority' => true],
         //['type' => 'insteon', 'command' => '0?1131=I=0=0'],
@@ -136,7 +133,6 @@ $scenes = [
     ],
     'chambre/chillout' => [
         ['type' => 'nightmode', 'mode' => '0'],
-        ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => '03gdSwPyZ9sbZVg'],
         ['type' => 'domoticz', 'scene' => 7, 'command' => true, 'priority' => true],
         //['type' => 'insteon', 'command' => '0?1131=I=0=0'],
@@ -149,7 +145,6 @@ $scenes = [
     ],
     'chambre/reading' => [
         ['type' => 'nightmode', 'mode' => '0'],
-        ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => 'BNiNQjxiWNbKRaH'],
         ['type' => 'domoticz', 'scene' => 8, 'command' => true, 'priority' => true],
         // ['type' => 'insteon', 'command' => '0?1131=I=0=0'],
@@ -158,7 +153,6 @@ $scenes = [
     ],
     'chambre/tonic' => [
         ['type' => 'nightmode', 'mode' => '0'],
-        ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => 'Tlcft9sPK492cJA'],
         ['type' => 'domoticz', 'scene' => 9, 'command' => true, 'priority' => true],
         // ['type' => 'insteon', 'command' => '0?1131=I=0=0'],
@@ -173,7 +167,6 @@ $scenes = [
     ],
     'chambre/party' => [
         ['type' => 'nightmode', 'mode' => '0'],
-        ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => 'qvQXHDodBPa0cZf'],
         ['type' => 'domoticz', 'scene' => 12, 'command' => true, 'priority' => true],
         //['type' => 'insteon', 'command' => '0?1119=I=0=0'],
@@ -182,7 +175,6 @@ $scenes = [
     ],
     'chambre/flowers' => [
         ['type' => 'nightmode', 'mode' => '0'],
-        ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => 'VtGPKtpQ7DF-RCd'],
         ['type' => 'domoticz', 'scene' => 13, 'command' => true, 'priority' => true],
         //['type' => 'insteon', 'command' => '0?1131=I=0=0'],
@@ -191,7 +183,6 @@ $scenes = [
     ],
     'chambre/tropical' => [
         ['type' => 'nightmode', 'mode' => '0'],
-        ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => 'Mqq8VMsmPQtzEQ0'],
         ['type' => 'domoticz', 'scene' => 14, 'command' => true, 'priority' => true],
         // ['type' => 'insteon', 'command' => '0?1131=I=0=0'],
@@ -200,7 +191,6 @@ $scenes = [
     ],
     'chambre/beach' => [
         ['type' => 'nightmode', 'mode' => '0'],
-        ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => 'HfMaPG92lEOUDB0'],
         ['type' => 'domoticz', 'scene' => 15, 'command' => true, 'priority' => true],
         //['type' => 'insteon', 'command' => '0?1131=I=0=0'],
@@ -212,7 +202,6 @@ $scenes = [
         ['type' => 'domoticz', 'scene' => 16, 'command' => true, 'priority' => true],
     ],
     'chambre/summernight' => [
-        ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'scene', 'scene' => 'chambre/nightlights'],
         //['type' => 'insteon', 'command' => '0?1131=I=0=0'],
         ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]],
@@ -220,7 +209,6 @@ $scenes = [
     ],
     'chambre/lounge' => [
         ['type' => 'nightmode', 'mode' => '0'],
-        ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => 'XGuSVQ3RCd7JUBC'],
         ['type' => 'domoticz', 'scene' => 17, 'command' => true, 'priority' => true],
         // ['type' => 'insteon', 'command' => '0?1131=I=0=0'],
@@ -229,7 +217,6 @@ $scenes = [
     ],
     'chambre/full' => [
         ['type' => 'nightmode', 'mode' => '0'],
-        ['type' => 'state', 'key' => 'chambre', 'value' => 1],
         ['type' => 'hue', 'group' => $chambre, 'scene' => 'ZkiQbNQDXJz9-OC'],
         ['type' => 'domoticz', 'scene' => 18, 'command' => true, 'priority' => true],
         // ['type' => 'insteon', 'command' => '0?1132=I=0=0'],
@@ -248,7 +235,6 @@ $scenes = [
         // ['type' => 'insteon', 'command' => '0?1332=I=0=0'],
         ['type' => 'domoticz', 'scene' => 19, 'command' => false, 'priority' => true],
     ],
-
     'chambre/cheminee' => [
         ['type' => 'domoticz', 'scene' => 43, 'command' => true, 'priority' => true],
     ],
@@ -580,7 +566,6 @@ $scenes = [
         ['type' => 'scene', 'scene' => 'bureau/base/on'],
         ['type' => 'scene', 'scene' => 'bureau/screens/on'],
         ['type' => 'domoticz', 'scene' => 39, 'command' => true, 'priority' => true],
-
     ],
     'bureau/beach' => [
         ['type' => 'hue', 'group' => $bureau, 'scene' => '0mPAKOl-Kw8Fwb1'],
@@ -908,9 +893,14 @@ function execScene($name, $fromUserAction = false, $transitionTime = null)
 
     $e = explode('/', $name);
 
-    if ($fromUserAction && $e[1] !== 'auto' && count($e) == 2) {
-        call_user_func($e[0] . 'Auto', false);
+    $autoRooms = ['bureau', 'chambre', 'salon', 'cour'];
+
+    if (in_array($e[0], $autoRooms)) {
         setState($e[0] . 'Off', $e[1] === 'off' ? '1' : '0');
+        if ($fromUserAction && $e[1] !== 'auto' && count($e) == 2) {
+            call_user_func($e[0] . 'Auto', false);
+
+        }
     }
 
     $killurl = WEB_ROOT . 'scripts/light.php?[r]=2';
@@ -937,7 +927,7 @@ function execScene($name, $fromUserAction = false, $transitionTime = null)
 
         if ($action['type'] == 'hue') {
             hueCommand($action, $transitionTime);
-        }  else if ($action['type'] == 'delay' || $action['type'] == 'scene') {
+        } else if ($action['type'] == 'delay' || $action['type'] == 'scene') {
             if (!isset($action['delay'])) {
                 $action['delay'] = 0;
             }
@@ -977,12 +967,12 @@ function execScene($name, $fromUserAction = false, $transitionTime = null)
     }
 }
 
-function chambreToggle()
+function chambreToggle($fromUserAction = false)
 {
-    if (getState('chambre') == 1) {
-        execScene('chambre/off');
+    if (getState('chambreOff') == 0) {
+        execScene('chambre/off', $fromUserAction);
     } else {
-        execScene('chambre/full');
+        execScene('chambre/full', $fromUserAction);
     }
 }
 
@@ -1000,7 +990,7 @@ function wcMusic($volume)
 function wcToggle()
 {
     if (getState('wc') == 1) {
-        execScene('wc/off');
+        execScene('wc/off', true);
     } else {
         wcOn();
     }
@@ -1018,7 +1008,6 @@ function sdbToggle()
 
 function wcOn($vmc = true)
 {
-
     $hour = getHour();
     if (getNightMode()) {
         $period = 'night';
@@ -1031,7 +1020,7 @@ function wcOn($vmc = true)
     } else {
         $period = 'evening';
     }
-    execScene('wc/' . $period);
+    execScene('wc/' . $period, true);
     setState('wc', 1);
     if ($vmc && $period != 'night') {
         wcVMCOn();
@@ -1155,7 +1144,6 @@ function bedbrightness($brightness)
 function salonAuto($on = true)
 {
     if ($on) {
-
         setState('salonAutoMode', '1');
         updateSalonAuto();
     } else if (getState('salonAutoMode') === '1') {
@@ -1165,10 +1153,6 @@ function salonAuto($on = true)
 
 function chambreAuto($on = true, $transitionTime = null)
 {
-    if (getState('chambreOff') == '1') {
-        execScene('chambre/off');
-        return;
-    }
     if ($on) {
         ecoMode(0);
         setState('chambreAutoMode', '1');
@@ -1204,6 +1188,9 @@ function updateSalonAuto()
         execScene('salon/off');
         return;
     }
+    if (getState('salonAutoMode') != '1') {
+        return;
+    }
     $hours = intval(date('H'));
     if ($hours <= 9) {
         $scene = 'tamise';
@@ -1221,6 +1208,9 @@ function updateChambreAuto($transitionTime = null)
         execScene('chambre/off');
         return;
     }
+    if (getState('chambreAutoMode') != '1') {
+        return;
+    }
     $hours = intval(date('H'));
     if ($hours <= 4) {
         $scene = 'party';
@@ -1246,6 +1236,9 @@ function updateBureauAuto()
         execScene('bureau/off');
         return;
     }
+    if (getState('bureauAutoMode') != '1') {
+        return;
+    }
     $hours = intval(date('H'));
     if ($hours <= 4) {
         $scene = 'outrun';
@@ -1281,6 +1274,9 @@ function updateCourAuto()
         execScene('cour/off');
         return;
     }
+    if (getState('courAutoMode') != '1') {
+        return;
+    }
     if (isDay()) {
         $scene = 'daylight';
     } else {
@@ -1388,4 +1384,23 @@ function alert()
         domoticzSwitch($domoticzDevice, $domoticzState);
     }
 
+}
+
+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
index 66bf8bf3c8fbb3461f17be0cd621fc0916451e4f..ecf66ba7a48c51749881da3b961969c4a127125c 100644 (file)
@@ -1,7 +1,9 @@
 <?php
 function velibStations()
 {
-    $alldata = json_decode(file_get_contents('https://www.velib-metropole.fr/webapi/map/details?gpsTopLatitude=51&gpsTopLongitude=4&gpsBotLatitude=48&gpsBotLongitude=1&zoomLevel=11'), true);
+    $cache = __DIR__ . '/../../cache/velib.all.json';
+    `curl 'https://www.velib-metropole.fr/webapi/map/details?gpsTopLatitude=51&gpsTopLongitude=4&gpsBotLatitude=48&gpsBotLongitude=1&zoomLevel=11' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0' --output $cache`;
+    $alldata = json_decode(file_get_contents($cache), true);
 
     $stations = ['Cadet' => 9101, 'Bleue' => 9113, 'Folies bergères' => 9011, 9009, 'Le Pelletier' => 9014];
     $res = array();