This is a library for accessing and controlling your Philips Hue lights using Ruby.
gem install philips_hue. Check out the bin/ directory for examples of how to use this project and what kind of things you can do.
Registering with the Bridge
You need two things to connect with your Hue, a name for your app and the IP address of the white Hue bridge.
- The IP address can be found on the Hue Community site. Login, go here, click "Show me more," and find the IP under "Internal IP address." Example:
- The app name can be anything you like. You must register your app with the Hue by running
PhilipsHue#registerand pressing the button on the bridge. You must do this again for every new app name you create. Example:
"my light app"
- Skip this step by running the bin/register.rb script.
PhilipsHue::Bridge.register("my light app", "192.168.1.14")
Getting the State of a Light
There are many available status options in the
hue = PhilipsHue::Bridge.new("my light app", "192.168.1.14") light1, light2, light3 = hue.lights puts light1.state puts light1.colormode puts light2.brightness puts light3 # => "Front right is on and reachable"
Changing the Color of a Light
To change the state of a light, simply modify the value of one of the state parameters. For example:
light1.xy = [0.6446, 0.3289] light1.ct = 200 light1.hue = 25000 # etc.
Some helper methods, including default color options, are provided. For example:
light1.blue light2.red light3.green light1.blip # blink once light2.blink # blink repeatedly light3.flash([0.6446, 0.3289]) # flash red