]> _ Git - tortuga-home.git/commitdiff
.
authorvincent <vincent@enhydra.fr>
Sat, 22 Jan 2022 14:15:05 +0000 (15:15 +0100)
committervincent <vincent@enhydra.fr>
Sat, 22 Jan 2022 14:15:05 +0000 (15:15 +0100)
.idea/workspace.xml
config/cuisine.php
config/sdb.php
config/water.php [new file with mode: 0644]
scripts/hotwater.php [new file with mode: 0644]
scripts/lib/lib.php
scripts/lib/profile.php
scripts/lib/scenes.php
scripts/lib/switchbot.php
scripts/lib/tmdb.php

index 5b836148de50d2291cbd5cb657e32946eb704aa2..bcbaa9a00199d8b304031899df9ae7f12901407d 100644 (file)
@@ -2,9 +2,16 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
-      <change afterPath="$PROJECT_DIR$/scripts/lib/switchbot.php" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/config/water.php" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/scripts/hotwater.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/config/cuisine.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/cuisine.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/config/sdb.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/sdb.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/profile.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/profile.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" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/tmdb.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/tmdb.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
       <workItem from="1642149121693" duration="376000" />
       <workItem from="1642240002240" duration="1108000" />
       <workItem from="1642761590471" duration="1992000" />
-      <workItem from="1642848701157" duration="1843000" />
-    </task>
-    <task id="LOCAL-00457" summary=".">
-      <created>1615881926505</created>
-      <option name="number" value="00457" />
-      <option name="presentableId" value="LOCAL-00457" />
-      <option name="project" value="LOCAL" />
-      <updated>1615881926506</updated>
+      <workItem from="1642848701157" duration="3435000" />
+      <workItem from="1642856038290" duration="3025000" />
     </task>
     <task id="LOCAL-00458" summary=".">
       <created>1615883286918</created>
       <option name="project" value="LOCAL" />
       <updated>1642848715262</updated>
     </task>
-    <option name="localTasksCounter" value="506" />
+    <task id="LOCAL-00506" summary=".">
+      <created>1642854570967</created>
+      <option name="number" value="00506" />
+      <option name="presentableId" value="LOCAL-00506" />
+      <option name="project" value="LOCAL" />
+      <updated>1642854570967</updated>
+    </task>
+    <option name="localTasksCounter" value="507" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
index 4018be093d14964f7ece459e3285ec03b229c046..84a5ca2abb6c0ff9a4582a452258442b443d266a 100644 (file)
@@ -21,6 +21,7 @@ if (DISPLAYINTERFACE) {
     $favoriteslights = array_merge($favoriteslights, $c['favorites']);
 
     include "default.php";
+    include "water.php";
 
-    $nav=['home','lights','music','remote','coffee','switch','settings','alert','off'];
+    $nav=['home','lights','water','music','remote','coffee','switch','settings','alert','off'];
 }
\ No newline at end of file
index 2de3cce186334da6895fb1126196128d0ff31ffb..37139fe34b0cc85550a1e925e9b9f45bb30525df 100644 (file)
@@ -17,7 +17,7 @@ config('THEME', '#92475c');
 if (DISPLAYINTERFACE) {
     $c = sdb();
     $shortcuts['lights'] = $c['all'];
-    $nav = ['home', 'lights', 'music', 'media', 'remote', 'switch', 'settings', 'alert', 'off'];
+    $nav = ['home', 'lights','water', 'music', 'media', 'remote', 'switch', 'settings', 'alert', 'off'];
 
     include_once ROOT . '/config/music.php';
 
@@ -27,6 +27,7 @@ if (DISPLAYINTERFACE) {
     ];
     $favoriteslights[] = array_merge($allmusics['France Info'], array('volume' => 50));
     $favoriteslights = array_merge($favoriteslights, $c['favorites']);
+    include "water.php";
     include "media.php";
     include "default.php";
 }
\ No newline at end of file
diff --git a/config/water.php b/config/water.php
new file mode 100644 (file)
index 0000000..e1f1761
--- /dev/null
@@ -0,0 +1,8 @@
+<?php
+
+$shortcuts['water'] = [
+    ['type' => 'light', 'scene' => 'sdb/hotwater/eco', 'label' => 'Eco'],
+    ['type' => 'light', 'scene' => 'sdb/hotwater/max', 'label' => 'Max'],
+    ['type' => 'light', 'scene' => 'sdb/hotwater/off', 'label' => 'Off'],
+
+];
\ No newline at end of file
diff --git a/scripts/hotwater.php b/scripts/hotwater.php
new file mode 100644 (file)
index 0000000..58667ea
--- /dev/null
@@ -0,0 +1,5 @@
+<?php
+require_once "import.php";
+if (isset($_GET['on'])) {
+    echo hotwater($_GET['on']);
+}
\ No newline at end of file
index 5da52c8eb06e20a12745a87fa0e5b3eeb67a8811..ba854e480b76a60066068ef959a611f0f1ced689 100644 (file)
@@ -5,6 +5,7 @@ $insteonProcessingQueue = false;
 $harmonyClient = null;
 $endQueue = [];
 
+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';
@@ -12,7 +13,6 @@ require_once ROOT . '/scripts/lib/redis.php';
 require_once ROOT . '/scripts/lib/state.php';
 require_once ROOT . '/scripts/lib/hue.php';
 require_once ROOT . '/scripts/lib/harmony.php';
-require_once ROOT . '/scripts/lib/insteon.php';
 require_once ROOT . '/scripts/lib/scenes.php';
 require_once ROOT . '/scripts/lib/squeezebox.php';
 require_once ROOT . '/scripts/lib/freebox.php';
@@ -609,6 +609,7 @@ function makeNav($nav)
         'music' => '<div data-menu="music"><i class="fa fa-music" aria-hidden="true"></i><span>Musique & Radio</span></div>',
         'media' => '<div data-menu="media"><i class="fa fa-tv-retro" aria-hidden="true"></i><span>Medias & TV</span></div>',
         'coffee' => '<div data-menu="coffee"><i class="fa fa-oven" aria-hidden="true"></i><span>Cuisine / Café</span></div>',
+        'water' => '<div data-menu="water"><i class="fa fa-faucet-drip" aria-hidden="true"></i><span>Eau chaude</span></div>',
         'fan' => '<a href="/scripts/light.php?scene=' . config('ROOM') . '/fan/toggle" class="ajax"><i class="fa fa-fan" aria-hidden="true"></i><span>Ventilateur</span></a>',
         'remote' => '<div data-menu="remote"><i class="fa fa-play" aria-hidden="true"></i><span>Télécommande</span></div>',
         'switch' => '<div data-menu="switch"><i class="far fa-portal-enter" aria-hidden="true"></i><span>Changer de pièce</span></div>',
index d1084dd7d886d3fb5ea9074c36b023cb15c6e4fe..bccbf10515548d1320e3c11994e85ab54936bbfe 100644 (file)
@@ -1,4 +1,9 @@
 <?php
+
+use Illuminate\Support\Str;
+
+require_once ROOT . '/vendor/autoload.php';
+
 $u = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/';
 
 $n = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : '-';
@@ -7,7 +12,7 @@ $n = str_replace('/home/tortugahome/www/', '', $n);
 $n = str_replace('/', '-', $n);
 $n = trim($n, '/ ');
 
-$profileFp = fopen('/var/log/tortugahome/profiles/' . \Illuminate\Support\Str::slug($n) . '.log', 'a+b');
+$profileFp = fopen('/var/log/tortugahome/profiles/' . Str::slug($n) . '.log', 'a+b');
 $profileStart = microtime(true);
 fwrite($profileFp, "\r\n\r\n------------\r\n" . 'URL : ' . $u . "\r\nDate : " . date('Y-m-d H:i:s') . "\r\n" . print_r($_REQUEST, true) . "\r\n\r\n");
 
index b8c9f72716a6f9fd74552c95f218414cd84d5887..79f270db9d7d6ad5ba7f9312a7749d47f97a7eb4 100644 (file)
@@ -728,6 +728,15 @@ $scenes = [
     'sdb/ampli/off' => [
         ['type' => 'domoticz', 'device' => '476', 'command' => false, 'priority' => true],
     ],
+    'sdb/hotwater/eco' => [
+        ['type' => 'function', 'function' => 'hotwater', 'args' => ['1']],
+    ],
+    'sdb/hotwater/max' => [
+        ['type' => 'function', 'function' => 'hotwater', 'args' => ['2']],
+    ],
+    'sdb/hotwater/off' => [
+        ['type' => 'function', 'function' => 'hotwater', 'args' => ['0']],
+    ],
     'sdb/off' => [
         ['type' => 'state', 'key' => 'sdb', 'value' => 0],
         ['type' => 'domoticz', 'scene' => 20, 'command' => false, 'priority' => true],
@@ -1185,11 +1194,12 @@ function updateBureauAuto()
     execScene('bureau/' . $scene);
 }
 
-function updateCuisine(){
-    $salon=getState('salon','off');
-    if($salon==='on' || $salon==='off' || $salon==='tamise'){
+function updateCuisine()
+{
+    $salon = getState('salon', 'off');
+    if ($salon === 'on' || $salon === 'off' || $salon === 'tamise') {
         execScene('cuisine/on');
-    }else if($salon=='cinema'){
+    } else if ($salon == 'cinema') {
         execScene('cuisine/tamise');
     }
 }
index 0a4bdba95b47d3cd11bcf469a913360f42749803..34e61e2b00941afed0846dca4a1e2340936f2018 100644 (file)
@@ -1,22 +1,35 @@
 <?php
 function switchbot($device, $command = 'press')
 {
-    sshCommand('/usr/bin/python3 /usr/local/python-host/switchbot_py3.py -d ' . $device . ' -c ' . $command, 'bureausun', true, true);
+    return sshCommand('/usr/bin/python3 /usr/local/python-host/switchbot_py3.py -d ' . $device . ' -c ' . $command, 'bureausun', true, true);
 }
 
-function hotwater($on = true)
+function hotwater($newState)
 {
+    // 0 : OFF
+    // 1 : ECO
+    // 2 : MAX
+
+    $changing = getState('hotwater_change', '0');
+//    if ($changing == '1') {
+//        return 'changing';
+//    }
+    setState('hotwater_change', '1');
+
     $device = 'C1:F7:66:5E:A2:CF';
     $state = getState('hotwater', '1');
-    $newState = $on ? '1' : '0';
     if ($newState === $state) {
-        return;
+        return 'no state change';
     }
-    if ($newState === '1') {
-        switchbot($device);
-    } else {
-        switchbot($device);
-        sleep(2);
-        switchbot($device);
+
+    $clicks = (3 + $newState - $state) % 3;
+    $res = '';
+    for ($i = 0; $i < $clicks; $i++) {
+        $res .= ' one click - ';
+        $res .= switchbot($device);
+        sleep(5);
     }
+    setState('hotwater', $newState);
+    setState('hotwater_change', '0');
+    return $res;
 }
\ No newline at end of file
index 83dc3bc6a24e6a07556bf76c8d20f76334a8d423..6588cf156b6bbf191bd6f9503273777c4cbe48dc 100644 (file)
@@ -257,6 +257,8 @@ class tvShowLibrary extends mediaLibrary
     {
         global $videoExt;
 
+        set_time_limit(0);
+
         $e = explode(':', $tvShow['dir']);
         if ($e[0] === 'netflix') {
             $res['shortcuts'][] = ['label' => $tvShow['data']['name'], 'type' => 'netflix', 'url' => '/scripts/netflix.php?id=' . $e[1], 'poster' => $this->_poster($tvShow['data']['poster_path'])];