Пример #1
0
 /**
  * Adjust individual light
  *
  * @param $id
  * @param $brightness
  * @return array
  */
 public function adjustLight($id, $brightness)
 {
     try {
         $light = $this->client->sendCommand(new \Phue\Command\GetLightById($id));
         $light->setOn(true);
         $command = new \Phue\Command\SetLightState($light);
         $command->brightness($brightness);
         $this->client->sendCommand($command);
         return array('command' => true);
     } catch (\Exception $e) {
         dd($e);
         return array('command' => $e->getMessage());
     }
 }
Пример #2
0
        $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");
    //sleep(1);
    //Dining Room
    shell_exec("curl http://Quinn064:MqC3oSUo@192.168.0.2:25105/3?026230da8a0F11FF=I=3");
} catch (Exception $e) {
    die("Error: " . $e->getMessage());
}
Пример #3
0
<?php

/**
 * Example: Candle effect.
 *
 * Usage: HUE_HOST=127.0.0.1 HUE_USERNAME=1234567890 php candle-effect.php
 */
require_once 'common.php';
$client = new \Phue\Client($hueHost, $hueUsername);
echo 'Starting candle effect.', "\n";
while (true) {
    // Randomly choose values
    $brightness = rand(20, 60);
    $colorTemp = rand(440, 450);
    $transitionTime = rand(0, 3) / 10;
    // Send command
    $x = new \Phue\Command\SetLightState(4);
    $y = $x->brightness($brightness)->colorTemp($colorTemp)->transitionTime($transitionTime);
    $client->sendCommand($y);
    // Sleep for transition time plus extra for request time
    usleep($transitionTime * 1000000 + 25000);
}