This is a PHP client library for the Phillips Hue light system.
Definitely a work in progress - bear with me!
-
How to use:
Require or autoload thejlls/Hue/System.php
file.
Create new object of thejlls/Hue/System method
, passing your base station IP and developer ID in constructor.
Call a method! -
Get a Developer ID:
Press the button on the top of your Hue base station, then run theCLI_add_user.php
script.
This will return a randomised developer ID you can plug intoconfig.json
for use with subsequent requests. -
Example:
spl_autoload_extensions(".php");
spl_autoload_register();
use jlls\Hue as Hue;
$myLights = new Hue\System("192.168.1.2", "newdeveloper");
print_r(json_decode($myLights->Lights()->DescribeAllLights(), true));
- Methods are chainable:
$lightId=1;
$operation = $myLights->Lights($lightId)->LightOn()->LightBrightness(100)->LightHue(20000);
- Randomise your light colour every few seconds with the power of automation!:
$lightId=1;
for ($i=1, $i<100; $i++) {
$operation = $myLights->Lights($lightId)->LightOn()->LightBrightness('random')->LightHue('random');
sleep(5);
}
-
Method reference:
See the Wiki. -
Example CLI files:
To get these working, editconfig.json
with your Base Station IP and username.
Then, call them from your command line, e.g.php CLI_describe_lights.php
.
Some need the light ID parameter passing in, e.g.php CLI_light_on.php -l1
will turn on light ID 1. -
Questions/comments:
Drop me an e-mail at [email protected].