-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from jonofe/master
PHP 5.3 support for 1.x.
- Loading branch information
Showing
218 changed files
with
3,827 additions
and
4,132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
/vendor | ||
/.idea | ||
composer.lock | ||
*.buildpath | ||
*.prefs | ||
|
||
.settings/org.eclipse.wst.common.project.facet.core.xml | ||
.project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
language: php | ||
|
||
php: | ||
- 5.3 | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,75 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
if (is_file(__DIR__ . '/../vendor/autoload.php')) { | ||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
} else { | ||
require_once __DIR__ . '/../../../autoload.php'; | ||
} | ||
|
||
// Show usage if host and username not passed | ||
if (!isset($argv[1], $argv[2])) { | ||
echo "Philips Hue Light Finder", "\n\n", | ||
"Usage:", "\n", | ||
" <host> <username>", "\n\n"; | ||
exit(1); | ||
} | ||
|
||
// Initialize client | ||
$client = new \Phue\Client($argv[1], $argv[2]); | ||
|
||
echo "Testing connection to bridge at {$client->getHost()}", "\n"; | ||
|
||
try { | ||
$client->sendCommand( | ||
new \Phue\Command\Ping | ||
); | ||
} catch (\Phue\Transport\Exception\ConnectionException $e) { | ||
echo "Issue connecting to bridge", "\n"; | ||
|
||
exit(1); | ||
} | ||
|
||
// Quit if user is not authenticated | ||
if (!$client->sendCommand(new \Phue\Command\IsAuthorized)) { | ||
echo "{$client->getUsername()} is not authenticated with the bridge. Aborting.", "\n\n"; | ||
|
||
exit(1); | ||
} | ||
|
||
// Start light scan, | ||
$client->sendCommand( | ||
new \Phue\Command\StartLightScan | ||
); | ||
|
||
echo "Scanning for lights. Turn at least one light off, then on...", "\n"; | ||
|
||
// Found lights | ||
$lights = []; | ||
|
||
do { | ||
$response = $client->sendCommand( | ||
new \Phue\Command\GetNewLights | ||
); | ||
|
||
// Don't continue if the scan isn't active | ||
if (!$response->isScanActive()) { | ||
break; | ||
} | ||
|
||
// Iterate through each found light | ||
foreach ($response->getLights() as $lightId => $lightName) { | ||
// Light already found in poll | ||
if (isset($lights[$lightId])) { | ||
continue; | ||
} | ||
|
||
$lights[$lightId] = $lightName; | ||
|
||
echo "Found: Light #{$lightId}, {$lightName}", "\n"; | ||
} | ||
} while(true); | ||
|
||
echo "Done scanning", "\n\n"; | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
if (is_file(__DIR__ . '/../vendor/autoload.php')) { | ||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
} else { | ||
require_once __DIR__ . '/../../../autoload.php'; | ||
} | ||
|
||
// Show usage if host and username not passed | ||
if (!isset($argv[1], $argv[2])) { | ||
echo "Philips Hue Light Finder", "\n\n", | ||
"Usage:", "\n", | ||
" <host> <username>", "\n\n"; | ||
exit(1); | ||
} | ||
|
||
// Initialize client | ||
$client = new \Phue\Client($argv[1], $argv[2]); | ||
|
||
echo "Testing connection to bridge at {$client->getHost()}", "\n"; | ||
|
||
try { | ||
$client->sendCommand( | ||
new \Phue\Command\Ping | ||
); | ||
} catch (\Phue\Transport\Exception\ConnectionException $e) { | ||
echo "Issue connecting to bridge", "\n"; | ||
|
||
exit(1); | ||
} | ||
|
||
// Quit if user is not authenticated | ||
if (!$client->sendCommand(new \Phue\Command\IsAuthorized)) { | ||
echo "{$client->getUsername()} is not authenticated with the bridge. Aborting.", "\n\n"; | ||
|
||
exit(1); | ||
} | ||
|
||
// Start light scan, | ||
$client->sendCommand( | ||
new \Phue\Command\StartLightScan | ||
); | ||
|
||
echo "Scanning for lights. Turn at least one light off, then on...", "\n"; | ||
|
||
// Found lights | ||
// TODO $lights = []; | ||
|
||
$lights = array(); | ||
|
||
do { | ||
$response = $client->sendCommand( | ||
new \Phue\Command\GetNewLights | ||
); | ||
|
||
// Don't continue if the scan isn't active | ||
if (!$response->isScanActive()) { | ||
break; | ||
} | ||
|
||
// Iterate through each found light | ||
foreach ($response->getLights() as $lightId => $lightName) { | ||
// Light already found in poll | ||
if (isset($lights[$lightId])) { | ||
continue; | ||
} | ||
|
||
$lights[$lightId] = $lightName; | ||
|
||
echo "Found: Light #{$lightId}, {$lightName}", "\n"; | ||
} | ||
} while(true); | ||
|
||
echo "Done scanning", "\n\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.