]> _ Git - tortuga-home.git/commitdiff
.
authorVincent <vincent@enhydra.fr>
Tue, 13 Apr 2021 13:43:38 +0000 (15:43 +0200)
committerVincent <vincent@enhydra.fr>
Tue, 13 Apr 2021 13:43:38 +0000 (15:43 +0200)
.idea/workspace.xml
config/coffee.php
scripts/cron/cron.php
scripts/lib/domoticz.php
scripts/lib/lib.php
scripts/lib/scenes.php
servers/cheminee.php [new file with mode: 0644]

index 9eab33f32036339e50a45c4bfba473c64316b170..c4326d5531696d6f21b52878d9b6ede4fff5f883 100644 (file)
@@ -2,9 +2,13 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
+      <change afterPath="$PROJECT_DIR$/servers/cheminee.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/global.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/global.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/js/home.js" beforeDir="false" afterPath="$PROJECT_DIR$/js/home.js" 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/lib/domoticz.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/domoticz.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" />
         <option name="Make" enabled="true" />
       </method>
     </configuration>
+    <configuration default="true" type="ArquillianJUnit" factoryName="" nameIsGenerated="true">
+      <option name="arquillianRunConfiguration">
+        <value>
+          <option name="containerStateName" value="" />
+        </value>
+      </option>
+      <option name="TEST_OBJECT" value="class" />
+      <method v="2">
+        <option name="Make" enabled="true" />
+      </method>
+    </configuration>
     <configuration default="true" type="ArquillianTestNG" factoryName="">
       <option name="arquillianRunConfiguration">
         <value>
       <workItem from="1617794643348" duration="128000" />
       <workItem from="1617794856868" duration="1126000" />
       <workItem from="1617801536336" duration="4107000" />
-      <workItem from="1618050897134" duration="2465000" />
-    </task>
-    <task id="LOCAL-00414" summary=".">
-      <created>1606677800857</created>
-      <option name="number" value="00414" />
-      <option name="presentableId" value="LOCAL-00414" />
-      <option name="project" value="LOCAL" />
-      <updated>1606677800858</updated>
+      <workItem from="1618050897134" duration="4462000" />
+      <workItem from="1618158049208" duration="6569000" />
     </task>
     <task id="LOCAL-00415" summary=".">
       <created>1606809331094</created>
       <option name="project" value="LOCAL" />
       <updated>1617871680635</updated>
     </task>
-    <option name="localTasksCounter" value="463" />
+    <task id="LOCAL-00463" summary=".">
+      <created>1618054953034</created>
+      <option name="number" value="00463" />
+      <option name="presentableId" value="LOCAL-00463" />
+      <option name="project" value="LOCAL" />
+      <updated>1618054953035</updated>
+    </task>
+    <option name="localTasksCounter" value="464" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
index 4965ce91c3bc337fa3effd5b3ebae6b40053f2ff..ff5220e7ec42aa7addc7403fdce9ad6ecce4db16 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 $shortcuts['coffee'] = [
+    ['type' => 'light','scene'=>'cuisine/toaster/toggle',  'label' => 'Grille pain'],
+    ['type' => 'separator', 'label' => 'Machine à café'],
     ['type' => 'ifttt', 'event' => 'coffee_on', 'label' => 'Allumer'],
     ['type' => 'ifttt', 'event' => 'coffee_off', 'label' => 'éteindre'],
     ['type' => 'separator', 'label' => 'Cafés'],
index 38b7061e3790dba010fa34b5efd9488394ddcb43..c80de8aadae3ea2b4314c3af4f389e417dffced6 100644 (file)
@@ -17,11 +17,13 @@ function cronOneLoop($cronmin)
         cronVelib($cronmin);
         cronGuest($cronmin);
         cronShield($cronmin);
+
     }
     if ($cronmin % 10 == 0) {
         cronSqueezeFavorites($cronmin);
     }
     if ($cronmin % 20 == 0) {
+        cronBackyard($cronmin);
         cronSqueezeCheckPlayers($cronmin);
     }
 
@@ -60,6 +62,13 @@ function cronXPlanet($cronmin)
     `$suncurve;$earth`;
 }
 
+
+function cronBackyard($cronmin)
+{
+    $device = 679;
+    domoticzSwitch($device, getDomoticzDeviceStatus($device) === 'On');
+}
+
 function cronShield($cronmin)
 {
     global $devices;
index d92df817c3453a4c49178d664f67405999496480..ea9c6ef5d414e7cab39e3ac23628bb817226f0c2 100644 (file)
@@ -60,10 +60,10 @@ function domoticzCmd($command, $priority = false)
 
 function getDomoticzDeviceStatus($device, $force = false, $key = 'Data')
 {
-    echo ':)';
+    //echo ':)';
     $res = runDomoticzCommand(['type' => 'devices', 'rid' => $device]);
     $res = json_decode($res->getBody(), true);
-    print_r($res);
+   // print_r($res);
     try {
         $update = new DateTime($res['result'][0]['LastUpdate']);
         $now = new DateTime();
index a783a8e8696f27f34ce9f1eb87b71a0d19d82098..4f1865a30e87c633303fc456747f6623e695720f 100644 (file)
@@ -593,7 +593,7 @@ function makeNav($nav)
         'lights' => '<div data-menu="lights"><i class="far fa-lightbulb" aria-hidden="true"></i><span>Lumières</span></div>',
         '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-coffee" aria-hidden="true"></i><span>Café</span></div>',
+        'coffee' => '<div data-menu="coffee"><i class="fa fa-oven" aria-hidden="true"></i><span>Cuisine / Café</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 a2c6917cf90c0eb6b1c4f07b9e71173515497a57..517bd58fcfaa81af9006a274ca9ac57bc55c920a 100644 (file)
@@ -410,11 +410,11 @@ $scenes = [
     'bureau/screens/on' => [
         ['type' => 'function', 'function' => 'pcScreensProfile', 'args' => ['Tortuga', 'avion']]
     ],
-    'bureau/fan/on'=>[
-        ['type' => 'domoticz', 'device' => '3529', 'command' => true,'priority'=>true],
+    'bureau/fan/on' => [
+        ['type' => 'domoticz', 'device' => '3529', 'command' => true, 'priority' => true],
     ],
-    'bureau/fan/off'=>[
-        ['type' => 'domoticz', 'device' => '3529', 'command' => true,'priority'=>true],
+    'bureau/fan/off' => [
+        ['type' => 'domoticz', 'device' => '3529', 'command' => true, 'priority' => true],
     ],
     'bureau/fan/toggle' => [
         ['type' => 'domoticz', 'device' => '3529', 'command' => 'Toggle', 'priority' => true],
@@ -747,6 +747,15 @@ $scenes = [
     'cuisine/off' => [
         //['type' => 'hue', 'group' => $cuisine, 'scene' => array('on' => false, 'brightness' => 0)]
     ],
+    'cuisine/toaster/toggle' => [
+        ['type' => 'domoticz', 'device' => '1453', 'command' => 'Toggle', 'priority' => true],
+    ],
+    'cuisine/toaster/on' => [
+        ['type' => 'domoticz', 'device' => '1453', 'command' => true, 'priority' => true],
+    ],
+    'cuisine/toaster/off' => [
+        ['type' => 'domoticz', 'device' => '1453', 'command' => false, 'priority' => true],
+    ],
     'cour/auto' => [
         ['type' => 'domoticz', 'device' => '678', 'command' => true],
         ['type' => 'function', 'function' => 'courAuto', 'args' => [true]],
diff --git a/servers/cheminee.php b/servers/cheminee.php
new file mode 100644 (file)
index 0000000..2930987
--- /dev/null
@@ -0,0 +1,93 @@
+<?php
+require_once __DIR__ . "/../scripts/import.php";
+
+if (!isset($room)) {
+    $room = 'salon';
+}
+
+// Set time limit to indefinite execution
+set_time_limit(0);
+ignore_user_abort(true);
+
+if ($room === 'chambre') {
+    $lights = [3866, 3867, 3868];
+} else {
+    $lights = [];
+}
+
+/*
+ * $start = time();
+    $hue = getHueInstance();
+    $speed = 2;
+    $brightness *= 100;
+    $brightnessAmplitude = $brightness * 0.75;
+
+    set_time_limit(0);
+
+    while (true) {
+        if ($program == 'fire') {
+            $time = rand(1 / $speed, 40 / $speed) / 10;
+            $color = rand(0, 10000);
+        } else if ($program == 'cold') {
+            $time = rand(20 / $speed, 40 / $speed) / 2;
+            $color = rand(25500, 46920);
+        }
+        if ($color < 0) {
+            $color += 65280;
+        }
+
+        $command = new \Phue\Command\SetLightState($lightId);
+        $command->on(true);
+        $command->hue($color);
+        $command->brightness(max(0, min(255, rand(0, $brightnessAmplitude) + $brightness - $brightnessAmplitude / 2)));
+        $command->saturation(max(0, min(255, 220 + rand(0, 36))));
+        $command->transitionTime($time);
+        $command->send($hue);
+        usleep($time * 1000000);
+    }
+ */
+
+$now = microtime(true);
+foreach ($lights as $light) {
+    $nextChange[$light] = $now;
+}
+
+while (true) {
+    $program = getState('cheminee_' . $room . '_program', 'off');
+    $now = microtime(true);
+    foreach ($nextChange as $light => $next) {
+        if ($next <= $now) {
+            $nextChange[$light] = change($light, $program);
+        }
+    }
+}
+
+function change($light, $program)
+{
+    $speed = 2;
+    $brightness = 100;
+    $brightnessAmplitude = $brightness * 0.75;
+
+    if ($program == 'fire') {
+        $duration = rand(1 / $speed, 40 / $speed) / 10;
+        $color = rand(0, 10000);
+    } else if ($program == 'cold') {
+        $duration = rand(20 / $speed, 40 / $speed) / 2;
+        $color = rand(25500, 46920);
+    }
+    if ($color < 0) {
+        $color += 65280;
+    }
+
+    hueCommand(
+        [
+            'light' => $light,
+            'on' => true,
+            'hue' => $color,
+            'brightness' => max(0, min(255, rand(0, $brightnessAmplitude) + $brightness - $brightnessAmplitude / 2)),
+            'saturation' => max(0, min(255, 220 + rand(0, 36)))
+        ], $duration
+    );
+
+    return microtime(true) + $duration;
+}
\ No newline at end of file