From: Vincent Date: Thu, 15 Aug 2019 10:36:19 +0000 (+0200) Subject: . X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=2c86c139e8ee2577c4d87b67c87d89dce7feece6;p=tortuga-home.git . --- diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 4d882eb..f80dce1 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,21 +2,12 @@ - - - - - - - - - - - - - - + + + + + diff --git a/composer.json b/composer.json index 74bb6da..5304533 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "require": { "datto/json-rpc": "^4.0.4", "datto/json-rpc-http": "^3.2.1", - "sqmk/phue": "^v1.6.1", + "sqmk/phue": "^v1.7.0", "zendframework/zend-http": "^2.7.0", "alphayax/freebox_api_php": "^1.2.4", "guzzlehttp/guzzle": "^6.3.3", @@ -20,7 +20,6 @@ "zendframework/zend-db": "^2.10", "zendframework/zend-i18n": "^2.9", "zendframework/zend-i18n-resources": "^2.6", - "ext-ssh2": "*", "ext-json": "*" } } diff --git a/composer.lock b/composer.lock index b09ebc6..64c3c99 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9a9272d0b5f0d93af068be64ce3985f1", + "content-hash": "25c22f8a7754f5fd081527bd174c49a1", "packages": [ { "name": "alphayax/freebox_api_php", @@ -167,9 +167,9 @@ "authors": [ { "name": "Spencer Mortensen", + "role": "Developer", "email": "smortensen@datto.com", - "homepage": "http://spencermortensen.com", - "role": "Developer" + "homepage": "http://spencermortensen.com" } ], "description": "Fully unit-tested JSON-RPC 2.0 for PHP", @@ -215,9 +215,9 @@ "authors": [ { "name": "Spencer Mortensen", + "role": "Developer", "email": "smortensen@datto.com", - "homepage": "http://spencermortensen.com", - "role": "Developer" + "homepage": "http://spencermortensen.com" } ], "description": "HTTP client and server for JSON-RPC 2.0", @@ -1474,8 +1474,8 @@ "authors": [ { "name": "Michael Squires", - "email": "sqmk@php.net", - "role": "lead" + "role": "lead", + "email": "sqmk@php.net" } ], "description": "Phue - Philips Hue PHP client", @@ -1490,16 +1490,16 @@ }, { "name": "symfony/event-dispatcher", - "version": "v4.3.2", + "version": "v4.3.3", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "d257021c1ab28d48d24a16de79dfab445ce93398" + "reference": "212b020949331b6531250584531363844b34a94e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d257021c1ab28d48d24a16de79dfab445ce93398", - "reference": "d257021c1ab28d48d24a16de79dfab445ce93398", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/212b020949331b6531250584531363844b34a94e", + "reference": "212b020949331b6531250584531363844b34a94e", "shasum": "" }, "require": { @@ -1556,7 +1556,7 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2019-06-13T11:03:18+00:00" + "time": "2019-06-27T06:42:14+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -1618,7 +1618,7 @@ }, { "name": "symfony/options-resolver", - "version": "v4.3.2", + "version": "v4.3.3", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", @@ -2358,7 +2358,9 @@ "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, - "platform": [], + "platform": { + "ext-json": "*" + }, "platform-dev": [], "platform-overrides": { "php": "7.3.3" diff --git a/scripts/lib/hue.php b/scripts/lib/hue.php index fff2b07..b9082e3 100644 --- a/scripts/lib/hue.php +++ b/scripts/lib/hue.php @@ -26,40 +26,81 @@ function getHueState() } -function hueApplyScene($groupId, $sceneId) +function hueApplyScene($groupId, $sceneId, $transitionTime = null) { + $hue = getHueInstance(); $groups = $hue->getGroups(); $group = $groups[$groupId]; - print_r($group); + echo "Group : "; + print_r($group) . "\n"; + echo "Scene : "; + print_r($sceneId); + echo "\n"; + echo "Transition : "; + print_r($transitionTime); + echo "\n"; + echo '-----' . "\n\n"; if (is_array($sceneId)) { $command = new Phue\Command\SetGroupState($group); foreach ($sceneId as $key => $value) { $command->$key($value); } if (!isset($sceneId['effect'])) { - $command->effect = 'none'; + $command->effect('none'); + } + if (null !== $transitionTime) { + $command->transitionTime($transitionTime); } $hue->sendCommand($command); + + echo "Command !! : "; + print_r($command); + } else { $command = new Phue\Command\SetGroupState($group); - $command->effect = 'none'; + if (null !== $transitionTime) { + $command->transitionTime($transitionTime); + } else { + $command->effect('none'); + } $hue->sendCommand($command); $group->setScene($sceneId); + + echo "Command ! : "; + print_r($command); } } -function hueApplySceneLight($lightId, $sceneId) +function hueApplySceneLight($lightId, $sceneId, $transitionTime = null) { $hue = getHueInstance(); $lights = $hue->getLights(); $light = $lights[$lightId]; + + echo "Light : "; + print_r($lightId) . "\n"; + echo "Scene : "; + print_r($sceneId); + echo "\n"; + echo "Transition : "; + print_r($transitionTime); + echo "\n"; + echo '-----' . "\n\n"; + if (is_array($sceneId)) { $command = new Phue\Command\SetLightState($light); + if (null !== $transitionTime) { + $command->transitionTime($transitionTime); + } foreach ($sceneId as $key => $value) { $command->$key($value); } + + $hue->sendCommand($command); + echo "Command : "; + print_r($command); } else { $light->setScene($sceneId); } diff --git a/scripts/lib/scenes.php b/scripts/lib/scenes.php index f7ad246..dc2436f 100644 --- a/scripts/lib/scenes.php +++ b/scripts/lib/scenes.php @@ -29,8 +29,10 @@ if (getState('vincenthere')) { $scenes = [ 'chambre/matin' => [ ['type' => 'ecomode', 'mode' => '0'], - ['type' => 'scene', 'scene' => 'chambre/rideaux/open'], - ['type' => 'scene', 'scene' => 'chambre/auto'], + ['type' => 'hue', 'group' => $chambre, 'scene' => 'JNieZpDHu5fbMyf'], + ['type' => 'hue', 'group' => $chambre, 'scene' => 'dawn', 'delay' => 1], + ['type' => 'scene', 'scene' => 'chambre/rideaux/open', 'delay' => 31], + ['type' => 'scene', 'scene' => 'chambre/auto', 'delay' => 35], ['type' => 'scene', 'scene' => 'chambre/deshumidificateur/on'], ['type' => 'scene', 'scene' => 'chambre/planetarium/off'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]], @@ -43,7 +45,6 @@ $scenes = [ // ['type' => 'insteon', 'command' => '0?1338=I=0=0'], ], 'chambre/auto' => [ - ['type' => 'ecomode', 'mode' => '0'], ['type' => 'function', 'function' => 'chambreAuto', 'args' => [true]], ], 'chambre/bed' => [ @@ -562,7 +563,7 @@ $scenes = [ ]; -function execScene($name, $fromUserAction = false) +function execScene($name, $fromUserAction = false, $transitionTime = null) { global $scenes; $scene = $scenes[$name]; @@ -588,9 +589,9 @@ function execScene($name, $fromUserAction = false) if ($action['type'] == 'hue') { if (isset($action['group'])) { - hueApplyScene($action['group'], $action['scene']); + hueApplyScene($action['group'], $action['scene'], $transitionTime); } else if (isset($action['light'])) { - hueApplySceneLight($action['light'], $action['scene']); + hueApplySceneLight($action['light'], $action['scene'], $transitionTime); } } else if ($action['type'] == 'insteon') { insteonCommand($action['command']); @@ -609,7 +610,7 @@ function execScene($name, $fromUserAction = false) if ($action['delay'] > 0) { usleep(round($action['delay'] * 1000000)); } - execScene($action['scene'], $fromUserAction); + execScene($action['scene'], $fromUserAction, $transitionTime); } } else if ($action['type'] == 'function') { $f = $action['function']; @@ -774,11 +775,12 @@ function bedbrightness($brightness) sshCommand($cmd, 'litjerome'); } -function chambreAuto($on = true) +function chambreAuto($on = true, $transitionTime = null) { if ($on) { + ecoMode(0); setState('chambreAutoMode', '1'); - updateChambreAuto(); + updateChambreAuto($transitionTime); } else { setState('chambreAutoMode', '0'); } @@ -794,7 +796,7 @@ function bureauAuto($on = true) } } -function updateChambreAuto() +function updateChambreAuto($transitionTime = null) { $hours = intval(date('H')); if ($hours <= 1) { @@ -810,7 +812,7 @@ function updateChambreAuto() } else { $scene = 'tropical'; } - execScene('chambre/' . $scene); + execScene('chambre/' . $scene, false, $transitionTime); } function updateBureauAuto() diff --git a/scripts/light.php b/scripts/light.php index d204cd1..5444bd5 100644 --- a/scripts/light.php +++ b/scripts/light.php @@ -19,6 +19,11 @@ if (isset($_GET['scene'])) { $hue = getHueInstance(); $command = new Phue\Command\DeleteGroup($_GET['group']); $command->send($hue); +} else if (isset($_GET['action']) && $_GET['action'] == 'createDawnScene') { + $hue = getHueInstance(); + $command = new \Phue\Command\CreateScene('dawn', 'dawn', [7, 8, 9, 10, 11, 12, 13, 17, 21]); + $command->transitionTime(30); + $command->send($hue); } else { echo '
';
     print_r(getHueState());