From: Vincent Date: Tue, 13 Apr 2021 13:43:38 +0000 (+0200) Subject: . X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=60dccb4546d6fc75f2b353cc5697bc4253f2fa59;p=tortuga-home.git . --- diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 9eab33f..c4326d5 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,13 @@ + - - + + + + + diff --git a/config/coffee.php b/config/coffee.php index 4965ce9..ff5220e 100644 --- a/config/coffee.php +++ b/config/coffee.php @@ -1,5 +1,7 @@ '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'], diff --git a/scripts/cron/cron.php b/scripts/cron/cron.php index 38b7061..c80de8a 100644 --- a/scripts/cron/cron.php +++ b/scripts/cron/cron.php @@ -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; diff --git a/scripts/lib/domoticz.php b/scripts/lib/domoticz.php index d92df81..ea9c6ef 100644 --- a/scripts/lib/domoticz.php +++ b/scripts/lib/domoticz.php @@ -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(); diff --git a/scripts/lib/lib.php b/scripts/lib/lib.php index a783a8e..4f1865a 100644 --- a/scripts/lib/lib.php +++ b/scripts/lib/lib.php @@ -593,7 +593,7 @@ function makeNav($nav) 'lights' => '
Lumières
', 'music' => '
Musique & Radio
', 'media' => '
Medias & TV
', - 'coffee' => '
Café
', + 'coffee' => '
Cuisine / Café
', 'fan' => 'Ventilateur', 'remote' => '
Télécommande
', 'switch' => '
Changer de pièce
', diff --git a/scripts/lib/scenes.php b/scripts/lib/scenes.php index a2c6917..517bd58 100644 --- a/scripts/lib/scenes.php +++ b/scripts/lib/scenes.php @@ -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 index 0000000..2930987 --- /dev/null +++ b/servers/cheminee.php @@ -0,0 +1,93 @@ +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