<?php /** * Example: List rules. * * Usage: HUE_HOST=127.0.0.1 HUE_USERNAME=1234567890 php list-rules.php */ require_once 'common.php'; $client = new \Phue\Client($hueHost, $hueUsername); echo 'Listing rules:', "\n"; foreach ($client->getRules() as $rule) { echo "\t", "#{$rule->getId()} - {$rule->getName()}", "\n", "\t\t", "Last Triggered Time: {$rule->getLastTriggeredTime()}", "\n", "\t\t", "Creation time: {$rule->getCreationTime()}", "\n", "\t\t", "Times triggered: {$rule->getTriggeredCount()}", "\n", "\t\t", "Owner: {$rule->getOwner()}", "\n", "\t\t", "Status: ", $rule->isEnabled() ? 'Yes' : 'No', "\n"; }
<?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"; $sensor = $client->getSensors()[2]; $rule = $client->getRules()[5]; $client->sendCommand((new \Phue\Command\UpdateRule($rule))->name('New name')->addCondition((new \Phue\Condition())->setSensorId($sensor)->setAttribute('lastupdated')->changed())->addAction((new \Phue\Command\SetGroupState(0))->brightness(200)));
<?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);