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


PHP Client::sendCommand方法代码示例

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


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

示例1: adjustLight

 /**
  * 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());
     }
 }
开发者ID:cambri,项目名称:home-automation,代码行数:21,代码来源:Lights.php

示例2: setColorTemp

 /**
  * Set Color temperature
  *
  * @param int $value Color temperature value
  *
  * @return Light Self object
  */
 public function setColorTemp($value)
 {
     $this->client->sendCommand((new SetLightState($this))->colorTemp((int) $value));
     // Change both internal color temp and colormode state
     $this->attributes->state->ct = (int) $value;
     $this->attributes->state->colormode = 'ct';
     return $this;
 }
开发者ID:Mahlstrom,项目名称:Phue,代码行数:15,代码来源:Light.php

示例3: delete

 /**
  * Delete user
  */
 public function delete()
 {
     $this->client->sendCommand(new DeleteUser($this));
 }
开发者ID:bendspoons,项目名称:Phue,代码行数:7,代码来源:User.php

示例4: setLinkButtonOn

 /**
  * Set link button state
  *
  * @param bool $state True for on, false for off
  *
  * @return self This object
  */
 public function setLinkButtonOn($state = true)
 {
     $this->client->sendCommand(new SetBridgeConfig(['linkbutton' => (bool) $state]));
     $this->attributes->linkbutton = (bool) $state;
     return $this;
 }
开发者ID:bendspoons,项目名称:Phue,代码行数:13,代码来源:Bridge.php

示例5: delete

 /**
  * Delete schedule
  */
 public function delete()
 {
     $this->client->sendCommand(new Command\DeleteSchedule($this));
 }
开发者ID:Mahlstrom,项目名称:Phue,代码行数:7,代码来源:Schedule.php

示例6: disableInstallNotification

 /**
  * Disable the install notification
  *
  * @return self This object
  */
 public function disableInstallNotification()
 {
     $this->client->sendCommand(new SetBridgeConfig(['swupdate' => ['notify' => false]]));
     $this->attributes->notify = false;
     return $this;
 }
开发者ID:wardcraigj,项目名称:gametime,代码行数:11,代码来源:SoftwareUpdate.php

示例7: setName

 /**
  * Set name of bridge
  *
  * @param string $name Name
  *
  * @return Bridge Self object
  */
 public function setName($name)
 {
     $this->client->sendCommand(new SetBridgeConfig(['name' => (string) $name]));
     $this->attributes->name = (string) $name;
     return $this;
 }
开发者ID:Mahlstrom,项目名称:Phue,代码行数:13,代码来源:Bridge.php

示例8: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $ip = $input->getArgument('ip');
     $username = $input->getArgument('username');
     if ($ip) {
         $ipAddress = $ip;
     } else {
         $output->writeln('Finding your Bridge...');
         $bridges = json_decode(file_get_contents('https://www.meethue.com/api/nupnp'));
         /**
          * No bridges - stop.
          */
         if (!$bridges) {
             $output->writeln('No bridges found - sorry!');
         }
         /**
          * One bridge, grab IP.
          */
         if (count($bridges) == 1) {
             $ipAddress = $bridges[0]->internalipaddress;
         }
         /**
          * Multiple bridges? Ask for IP.
          */
         if (count($bridges) > 1) {
             $choices = [];
             foreach ($bridges as $bridge) {
                 $choices[] = $bridge->internalipaddress;
             }
             $helper = $this->getHelper('question');
             $question = new ChoiceQuestion('We found multiple bridges. Which one do you want to connect to?', $choices, 0);
             $question->setErrorMessage('Choice %s is invalid.');
             $choice = $helper->ask($input, $output, $question);
             $ipAddress = $choice;
             $output->writeln('You have just selected: ' . $choice);
         }
     }
     if ($input->getOption('yell')) {
         //
     }
     /**
      * Username.
      */
     $user = $username ? $username : get_current_user();
     $user = $user . substr(md5(microtime()), rand(0, 26), 10);
     /**
      * Authenticate with Bridge.
      */
     $client = new Client($ipAddress, $user);
     $output->writeln("Testing connection to bridge at {$client->getHost()}");
     try {
         $client->sendCommand(new Ping());
     } catch (ConnectionException $e) {
         $output->writeln("Issue connecting to bridge - " . $e->getMessage());
         exit(1);
     }
     $output->writeln("Attempting to create user: " . $user . "...");
     $output->writeln("Press the Bridge's button! Waiting...");
     $maxTries = 30;
     for ($i = 1; $i <= $maxTries; ++$i) {
         try {
             $response = $client->sendCommand(new CreateUser($user));
             $output->write("\n");
             $output->writeln("Successfully created new user: " . $response->username);
             break;
         } catch (LinkButtonException $e) {
             $output->write(".");
         } catch (Exception $e) {
             $output->writeln("Failure to create user. Please try again!");
             $output->writeln("Reason: " . $e->getMessage());
             break;
         }
         sleep(1);
     }
     /**
      * Save to memory.
      * @todo Would prefer a better way of doing this, if you can think of one.
      */
     if ($ipAddress && $user) {
         file_put_contents("config.txt", json_encode(['ip' => $ipAddress, 'username' => $user]));
     }
     $output->writeln("Let there be light! Use `hue list` to see available commands.");
 }
开发者ID:bryceadams,项目名称:TerminalHue,代码行数:83,代码来源:Setup.php


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