Example #1
0
 $lights = $client->sendCommand(new \Phue\Command\GetLights());
 // Declare light properties:
 $oldBrightness = new ArrayObject();
 $oldHue = new ArrayObject();
 $oldSaturation = new ArrayObject();
 foreach ($lights as $lightId => $light) {
     $oldBrightness[$lightId] = $light->getBrightness();
     $oldHue[$lightId] = $light->getHue();
     $oldSaturation[$lightId] = $light->getSaturation();
 }
 $sweepTime = 1;
 $group = $client->getGroups();
 $redcommand = new \Phue\Command\SetGroupState($group);
 $redcommand->brightness(166)->hue(39684)->saturation(255);
 $redcommand->transitionTime($sweepTime);
 $darkcommand = new \Phue\Command\SetGroupState($group);
 $darkcommand->brightness(0)->transitionTime($sweepTime);
 for ($i = 1; $i <= 5; $i++) {
     $client->sendCommand($redcommand);
     sleep($sweepTime);
     $client->sendCommand($darkcommand);
     sleep($sweepTime);
 }
 foreach ($lights as $lightId => $light) {
     $oldCommand = new \Phue\Command\SetLightState($light);
     $oldCommand->brightness($oldBrightness[$lightId])->hue($oldHue[$lightId])->saturation($oldSaturation[$lightId])->transitionTime(0);
     $client->sendCommand($oldCommand);
 }
 //On
 //Living Room
 shell_exec("curl http://Quinn064:MqC3oSUo@192.168.0.2:25105/3?026230D9270F11FF=I=3");
Example #2
0
<?php

/**
 * Example: Schedule a specific groups state.
 *
 * Usage: HUE_HOST=127.0.0.1 HUE_USERNAME=1234567890 php schedule-group-state.php
 */
require_once 'common.php';
$client = new \Phue\Client($hueHost, $hueUsername);
echo 'Scheduling group 1 state.', "\n";
$x = new \Phue\Command\CreateSchedule();
$y = new \Phue\Command\SetGroupState(1);
$z = $x->name('Group 1 dimmer')->description('Dims the lights for group 1')->time('+10 seconds')->command($y->brightness(255))->status(\Phue\Schedule::STATUS_ENABLED)->autodelete(true);
$client->sendCommand($z);
echo 'Done.', "\n";
Example #3
0
<?php

/**
 * Example: All lights to a scene.
 *
 * Usage: HUE_HOST=127.0.0.1 HUE_USERNAME=1234567890 php all-lights-scene.php
 */
require_once 'common.php';
$client = new \Phue\Client($hueHost, $hueUsername);
echo 'Setting all lights to a scene.', "\n";
$x = new \Phue\Command\SetGroupState(0);
$y = $x->scene('phue-test');
$client->sendCommand($y);
Example #4
0
<?php

/**
 * Example: Create test rule.
 *
 * Usage: HUE_HOST=127.0.0.1 HUE_USERNAME=1234567890 php create-rule.php
 */
require_once 'common.php';
$client = new \Phue\Client($hueHost, $hueUsername);
echo 'Creating test rule', "\n";
$sensors = $client->getSensors();
$sensor = $sensors[2];
$rule = new \Phue\Command\CreateRule('Button 1 press');
$cond1 = new \Phue\Condition();
$cond2 = new \Phue\Condition();
$g_state = new \Phue\Command\SetGroupState(0);
$cmd = $rule->addCondition($cond1->setSensorId($sensor)->setAttribute('buttonevent')->equals()->setValue(\Phue\SensorModel\ZgpswitchModel::BUTTON_2))->addCondition($cond2->setSensorId($sensor)->setAttribute('lastupdated')->changed())->addAction($g_state->brightness(2));
$ruleId = $client->sendCommand($cmd);
echo 'Rule Id: ', $ruleId, "\n";
Example #5
0
<?php

/**
 * Example: Schedule all lights to change.
 *
 * Usage: HUE_HOST=127.0.0.1 HUE_USERNAME=1234567890 php schedule-all-lights-change.php
 */
require_once 'common.php';
$client = new \Phue\Client($hueHost, $hueUsername);
echo 'Scheduling lights to dim, then become bright, 3 times, 1 second periods.', "\n";
$x1 = new \Phue\TimePattern\Timer(1);
$y1 = new \Phue\Command\SetGroupState(0);
$z1 = new \Phue\Command\CreateSchedule('Dim all lights', $x1->repeat(3), $y1->brightness(1));
$client->sendCommand($z1);
$x2 = new \Phue\TimePattern\Timer(1);
$y2 = new \Phue\Command\SetGroupState(0);
$z2 = new \Phue\Command\CreateSchedule('Brighten all lights', $x2->repeat(3), $y2->brightness(255));
$client->sendCommand($z2);
echo 'Done.', "\n";
Example #6
0
<?php

/**
 * Example: All lights to colorloop effect.
 *
 * Usage: HUE_HOST=127.0.0.1 HUE_USERNAME=1234567890 php all-lights-colorloop.php
 */
require_once 'common.php';
$client = new \Phue\Client($hueHost, $hueUsername);
echo 'Setting all lights to colorloop effect.', "\n";
$x = new \Phue\Command\SetGroupState(0);
$y = $x->effect('colorloop');
$client->sendCommand($y);
Example #7
0
<?php

/**
 * Example: Schedule all lights to change, recurring date.
 *
 * Usage: HUE_HOST=127.0.0.1 HUE_USERNAME=1234567890 php schedule-recurring.php
 */
require_once 'common.php';
$client = new \Phue\Client($hueHost, $hueUsername);
echo 'Dim all lights every Thursday and Saturday at 7:50 UTC.', "\n";
$timePattern = new \Phue\TimePattern\RecurringTime(\Phue\TimePattern\RecurringTime::THURSDAY | \Phue\TimePattern\RecurringTime::SATURDAY, 7, 50);
$x = new \Phue\Command\SetGroupState(0);
$y = new \Phue\Command\CreateSchedule('Dim all lights', $timePattern, $x->brightness(1));
$client->sendCommand($y);
echo 'Done.', "\n";
Example #8
0
<?php

/**
 * Example: Update test rule.
 *
 * Usage: HUE_HOST=127.0.0.1 HUE_USERNAME=1234567890 php update-rule.php
 */
require_once 'common.php';
$client = new \Phue\Client($hueHost, $hueUsername);
echo 'Updating test rule', "\n";
$sensors = $client->getSensors();
$sensor = $sensors[2];
$rules = $client->getRules();
$rule = $rules[5];
$x = new \Phue\Command\UpdateRule($rule);
$y1 = new \Phue\Condition();
$y2 = new \Phue\Command\SetGroupState(0);
$z = $x->name('New name')->addCondition($y1->setSensorId($sensor)->setAttribute('lastupdated')->changed())->addAction($y2->brightness(200));
$client->sendCommand($z);