当前位置: 首页>>代码示例>>PHP>>正文


PHP Phue\Client类代码示例

本文整理汇总了PHP中Phue\Client的典型用法代码示例。如果您正苦于以下问题:PHP Client类的具体用法?PHP Client怎么用?PHP Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Client类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->info('Hello Philips Hue');
     $client = new Client('192.168.1.197', 'newdeveloper');
     $light = $client->getLights()[1];
     $light->setOn(true);
     $light->setBrightness(150);
 }
开发者ID:cambri,项目名称:home-automation,代码行数:13,代码来源:PhilipsHue.php

示例2: send

 /**
  * Send command
  *
  * @param Client $client
  *            Phue Client
  *
  * @return Sensor[] List of Sensor objects
  */
 public function send(Client $client)
 {
     // Get response
     $results = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/sensors");
     $sensors = array();
     foreach ($results as $sensorId => $attributes) {
         $sensors[$sensorId] = new Sensor($sensorId, $attributes, $client);
     }
     return $sensors;
 }
开发者ID:sqmk,项目名称:phue,代码行数:18,代码来源:GetSensors.php

示例3: send

 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return Group[] List of Group objects
  */
 public function send(Client $client)
 {
     // Get response
     $results = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/groups");
     $groups = [];
     foreach ($results as $groupId => $attributes) {
         $groups[$groupId] = new Group($groupId, $attributes, $client);
     }
     return $groups;
 }
开发者ID:wardcraigj,项目名称:gametime,代码行数:17,代码来源:GetGroups.php

示例4: send

 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return Rule[] List of Rule objects
  */
 public function send(Client $client)
 {
     // Get response
     $results = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/rules");
     $rules = [];
     foreach ($results as $ruleId => $attributes) {
         $rules[$ruleId] = new Rule($ruleId, $attributes, $client);
     }
     return $rules;
 }
开发者ID:bendspoons,项目名称:Phue,代码行数:17,代码来源:GetRules.php

示例5: send

 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return bool True if authorized, false if not
  */
 public function send(Client $client)
 {
     // Get response
     try {
         $client->getTransport()->sendRequest("/api/{$client->getUsername()}");
     } catch (UnauthorizedUserException $e) {
         return false;
     }
     return true;
 }
开发者ID:bendspoons,项目名称:Phue,代码行数:17,代码来源:IsAuthorized.php

示例6: send

 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return Schedule[] List of Schedule objects
  */
 public function send(Client $client)
 {
     // Get response
     $response = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/schedules");
     $schedules = [];
     foreach ($response as $scheduleId => $attributes) {
         $schedules[$scheduleId] = new Schedule($scheduleId, $attributes, $client);
     }
     return $schedules;
 }
开发者ID:wardcraigj,项目名称:gametime,代码行数:17,代码来源:GetSchedules.php

示例7: send

 /**
  * Send command
  *
  * @param Client $client
  *            Phue Client
  *
  * @return Light[] List of Light objects
  */
 public function send(Client $client)
 {
     // Get response
     $response = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/lights");
     $lights = array();
     foreach ($response as $lightId => $attributes) {
         $lights[$lightId] = new Light($lightId, $attributes, $client);
     }
     return $lights;
 }
开发者ID:sqmk,项目名称:phue,代码行数:18,代码来源:GetLights.php

示例8: send

 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return array List of timezones
  */
 public function send(Client $client)
 {
     // Get response
     $response = $client->getTransport()->sendRequestBypassBodyValidation("/api/{$client->getUsername()}/info/timezones");
     $timezones = [];
     foreach ($response as $timezone) {
         $timezones[] = $timezone;
     }
     return $timezones;
 }
开发者ID:bendspoons,项目名称:Phue,代码行数:17,代码来源:GetTimezones.php

示例9: send

 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return self This object
  */
 public function send(Client $client)
 {
     // Get response
     $response = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/lights/new");
     $this->lastScan = $response->lastscan;
     // Remove scan from response
     unset($response->lastscan);
     // Iterate through left over properties as lights
     foreach ($response as $lightId => $light) {
         $this->lights[$lightId] = $light->name;
     }
     return $this;
 }
开发者ID:wardcraigj,项目名称:gametime,代码行数:20,代码来源:GetNewLights.php

示例10: send

 /**
  * Send command
  *
  * @param Client $client
  *            Phue Client
  *
  * @return User[] List of User objects
  */
 public function send(Client $client)
 {
     // Get response
     $response = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/config");
     // Return empty list if no users
     if (!isset($response->whitelist)) {
         return array();
     }
     $users = array();
     foreach ($response->whitelist as $username => $attributes) {
         $users[$username] = new User($username, $attributes, $client);
     }
     return $users;
 }
开发者ID:sqmk,项目名称:phue,代码行数:22,代码来源:GetUsers.php

示例11: send

 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return Light[] List of Light objects
  */
 public function send(Client $client)
 {
     // Get response
     $response = $client->getTransport()->sendRequest($client->getUsername());
     // Return empty list if no lights
     if (!isset($response->lights)) {
         return [];
     }
     $lights = [];
     foreach ($response->lights as $lightId => $attributes) {
         $lights[$lightId] = new Light($lightId, $attributes, $client);
     }
     return $lights;
 }
开发者ID:Mahlstrom,项目名称:Phue,代码行数:21,代码来源:GetLights.php

示例12: send

 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return Group[] List of Group objects
  */
 public function send(Client $client)
 {
     // Get response
     $response = $client->getTransport()->sendRequest($client->getUsername());
     // Return empty list if no groups
     if (!isset($response->groups)) {
         return [];
     }
     $groups = [];
     foreach ($response->groups as $groupId => $attributes) {
         $groups[$groupId] = new Group($groupId, $attributes, $client);
     }
     return $groups;
 }
开发者ID:Mahlstrom,项目名称:Phue,代码行数:21,代码来源:GetGroups.php

示例13: send

 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return Schedule[] List of Schedule objects
  */
 public function send(Client $client)
 {
     // Get response
     $response = $client->getTransport()->sendRequest($client->getUsername());
     // Return empty list if no schedules
     if (!isset($response->schedules)) {
         return [];
     }
     $schedules = [];
     foreach ($response->schedules as $scheduleId => $attributes) {
         $schedules[$scheduleId] = new Schedule($scheduleId, $attributes, $client);
     }
     return $schedules;
 }
开发者ID:Mahlstrom,项目名称:Phue,代码行数:21,代码来源:GetSchedules.php

示例14: send

 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return \stdClass Authentication response
  */
 public function send(Client $client)
 {
     // Get response
     $response = $client->getTransport()->sendRequest('/api', TransportInterface::METHOD_POST, $this->buildRequestData($client));
     return $response;
 }
开发者ID:bendspoons,项目名称:Phue,代码行数:13,代码来源:CreateUser.php

示例15: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /**
      * Get the chosen light ID.
      */
     $lightID = $input->getArgument('id');
     /**
      * Create client.
      */
     $client = new Client(Hue::getConfig()->ip, Hue::getConfig()->username);
     /**
      * Check that the chosen light ID exists and is reachable.
      */
     if (!isset($client->getLights()[$lightID]) || !$client->getLights()[$lightID]->isReachable()) {
         $output->writeln('<error>Light doesn\'t exist or is not reachable!</error>');
         $output->writeln('Use `hue lights` to see available lights.');
         exit(1);
     }
     $light = $client->getLights()[$lightID];
     /**
      * Turn all light on or off.
      */
     $on = $input->getArgument('on');
     if ($on) {
         $to = true;
         if ($on == 'off') {
             $to = false;
         }
         /**
          * If set to on, turn on.
          */
         $light->setOn($to);
         /**
          * If set to off, turn off & stop here.
          */
         if (!$to) {
             return true;
         }
     }
     /**
      * Get the color argument.
      */
     $color = $input->getArgument('color');
     /**
      * Handle if only 'on' param set (intended to be color).
      */
     if ($on && $on !== 'on' && $on !== 'off' && !$color) {
         $color = $on;
     }
     /**
      * Possible moods.
      */
     $possible_moods = Colors::colors();
     /**
      * If have mood, set it.
      */
     if ($color) {
         /**
          * If mood matches possible ones, go ahead.
          */
         if (isset($possible_moods[$color])) {
             $color = $possible_moods[$color];
             /**
              * Set the light to be that color.
              */
             $light->setXY($color[0], $color[1])->setBrightness(100);
         } else {
             $output->writeln('<question>That doesn\'t look to be a supported color! Try one of these:</question>');
             foreach ($possible_moods as $possible_mood => $mood_colors) {
                 $output->writeln('<comment>' . ucfirst($possible_mood) . '</comment>');
             }
         }
     }
     /**
             if ($color) {
                 /**
     * Calculate X & Y points.
     */
     /*
         $xy = Converter::hexToXY($color);
     
         $red = [0.675, 0.322];
         $green = [0.409, 0.518];
         $blue = [0.167, 0.04];
     
         $area = 1/2*(-$green[1]*$blue[0] + $red[1]*(-$green[0] + $blue[0]) + $red[0]*($green[1] - $blue[1]) + $green[0]*$blue[1]);
         $alpha = 1/(2*$area)*($red[1]*$blue[0] - $red[0]*$blue[1] + ($blue[1] - $red[1])*$xy[0] + ($red[0] - $blue[0])*$xy[1]);
         $beta = 1/(2*$area)*($red[0]*$green[1] - $red[1]*$green[0] + ($red[1] - $green[1])*$xy[0] + ($green[0] - $red[0])*$xy[1]);
         $gamma = 1 - $alpha - $beta;
         $altX = $alpha*$red[0] + $beta*$green[0] + $gamma*$blue[0];
         $altY = $alpha*$red[1] + $beta*$green[1] + $gamma*$blue[1];
     
         if ($alpha > 1 && $beta > 1 && $gamma > 1) {
             $useXY = $xy;
         } else {
             $useXY = [$altX, $altY];
         }
     
         $client->sendCommand(
             (new SetLightState($light))
//.........这里部分代码省略.........
开发者ID:bryceadams,项目名称:TerminalHue,代码行数:101,代码来源:Light.php


注:本文中的Phue\Client类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。