A Ruby gem to control Philips Hue lights
Latest commit 0bcbc56 Apr 23, 2016 @dmerrick dmerrick Merge pull request #4 from ryderstorm/adding-color-choice-by-RGB
Adding color choice by rgb


Lights App

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


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: ""
  • 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", "")

Getting the State of a Light

There are many available status options in the Light class.

  hue = PhilipsHue::Bridge.new("my light app", "")
  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.

Helper Methods

Some helper methods, including default color options, are provided. For example:

  light1.blip  # blink once
  light2.blink # blink repeatedly
  light3.flash([0.6446, 0.3289]) # flash red

See Also