Lights App

This is a library for accessing and controlling your Philips Hue lights using Ruby.

TL;DR:

Install with 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: "192.168.1.14"
  • The app name can be anything you like. You must register your app with the Hue by running PhilipsHue#register and 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.

For example:

  PhilipsHue::Bridge.register("my light app", "192.168.1.14")

Getting the State of a Light

There are many available status options in the Light class.

  hue = PhilipsHue::Bridge.new("my light app", "192.168.1.14")
  light1, light2, light3 = hue.lights
  puts light1.state
  puts light1.colormode
  puts light2.bri
  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.

Helper Methods

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

See Also