-
Notifications
You must be signed in to change notification settings - Fork 5
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 #19 from Chris53897/feature/modernize
feat: drop support for PHP < 8.1
- Loading branch information
Showing
111 changed files
with
1,256 additions
and
821 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
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
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,75 +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 | ||
// 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"; | ||
<?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
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
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
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
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
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.