/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * Send command * * @param Client $client Phue Client * * @return int Sensor Id */ public function send(Client $client) { $response = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/sensors", TransportInterface::METHOD_POST, (object) array_merge($this->attributes, ['state' => $this->state, 'config' => $this->config])); return $response->id; }
/** * Send command * * @param Client $client Phue Client * * @return mixed|void */ public function send(Client $client) { $client->getTransport()->sendRequest("{$client->getUsername()}/schedules/{$this->scheduleId}", TransportInterface::METHOD_DELETE); }
/** * Send command * * @param Client $client Phue Client * * @return mixed|void */ public function send(Client $client) { $client->getTransport()->sendRequest("{$client->getUsername()}/config", TransportInterface::METHOD_PUT, (object) $this->config); }
/** * Send command * * @param Client $client * Phue Client * * @return mixed */ public function send(Client $client) { // Get response $response = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/lights", TransportInterface::METHOD_POST); return $response; }
/** * Send command * * @param Client $client Phue Client */ public function send(Client $client) { $client->getTransport()->sendRequest("/api/{$client->getUsername()}/groups/{$this->groupId}", TransportInterface::METHOD_DELETE); }
/** * Send command * * @param Client $client Phue Client * * @return Bridge Bridge object */ public function send(Client $client) { // Get response $response = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/config"); return new Bridge($response, $client); }
/** * Send command * * @param Client $client Phue Client * * @return mixed|void */ public function send(Client $client) { $client->getTransport()->sendRequest("{$client->getUsername()}/groups/{$this->groupId}", TransportInterface::METHOD_PUT, (object) $this->attributes); }
/** * Send command * * @param Client $client * Phue Client */ public function send(Client $client) { $client->getTransport()->sendRequest("/api/{$client->getUsername()}/lights/{$this->lightId}", TransportInterface::METHOD_PUT, (object) array('name' => $this->name)); }
/** * Get schedulable params * * @param Client $client Phue Client * * @return array Key/value pairs of params */ public function getSchedulableParams(Client $client) { return ['address' => "{$client->getUsername()}/groups/{$this->groupId}/action", 'method' => TransportInterface::METHOD_PUT, 'body' => (object) $this->params]; }
/** * Send command * * @param Client $client Phue Client */ public function send(Client $client) { $client->getTransport()->sendRequest("/api/{$client->getUsername()}/config/whitelist/{$this->username}", TransportInterface::METHOD_DELETE); }
/** * Send command * * @param Client $client Phue Client * * @return int Group Id */ public function send(Client $client) { $response = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/groups", TransportInterface::METHOD_POST, (object) ['name' => $this->name, 'lights' => $this->lights]); return explode('/', $response->id)[2]; }
/** * Send command * * @param Client $client * Phue Client * * @return string Scene Id */ public function send(Client $client) { $body = (object) array('name' => $this->name, 'lights' => $this->lights); if ($this->transitionTime !== null) { $body->transitiontime = $this->transitionTime; } $client->getTransport()->sendRequest("/api/{$client->getUsername()}/scenes/{$this->id}", TransportInterface::METHOD_PUT, $body); return $this->id; }
/** * Send command * * @param Client $client Phue Client * * @return Schedule Schedule object */ public function send(Client $client) { // Get response $attributes = $client->getTransport()->sendRequest("{$client->getUsername()}/schedules/{$this->scheduleId}"); return new Schedule($this->scheduleId, $attributes, $client); }
/** * Send command * * @param Client $client Phue Client * * @return Light Light object */ public function send(Client $client) { // Get response $attributes = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/lights/{$this->lightId}"); return new Light($this->lightId, $attributes, $client); }
/** * Send command * * @param Client $client * Phue Client */ public function send(Client $client) { $client->getTransport()->sendRequest("/api/{$client->getUsername()}/sensors/{$this->sensorId}/state", TransportInterface::METHOD_PUT, (object) $this->state); }
/** * Send command * * @param Client $client Phue Client * * @return string Scene Id */ public function send(Client $client) { $client->getTransport()->sendRequest("/api/{$client->getUsername()}/scenes/{$this->id}", TransportInterface::METHOD_PUT, (object) ['name' => $this->name, 'lights' => $this->lights]); return $this->id; }
/** * Send command * * @param Client $client * Phue Client */ public function send(Client $client) { $client->getTransport()->sendRequest("/api/{$client->getUsername()}/scenes/{$this->sceneId}/lights/{$this->lightId}/state", TransportInterface::METHOD_PUT, (object) $this->params); }
/** * Send command * * @param Client $client * Phue Client * * @return int Rule Id */ public function send(Client $client) { $response = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/rules", TransportInterface::METHOD_POST, (object) array('name' => $this->name, 'conditions' => array_map(function ($condition) { return $condition->export(); }, $this->conditions), 'actions' => array_map(function ($action) use($client) { return $action->getActionableParams($client); }, $this->actions))); return $response->id; }