Skip to content

lovattj/php-HueLights

Repository files navigation

php-HueLights

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 the jlls/Hue/System.php file.
    Create new object of the jlls/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 the CLI_add_user.php script.
    This will return a randomised developer ID you can plug into config.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, edit config.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].

About

A PHP client library for the Hue lights

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages