Skip to content
forked from birkirb/hue-lib

A simple, experimental Ruby library for controlling Philips Hue lights.

Notifications You must be signed in to change notification settings

fuegito/hue-lib

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hue-lib

This is a Ruby library for controlling the Philips Hue lighting system. The API has not yet been released, but there are several people working to figure it out.

WARNING

All of this is very experimental and could permanently damage your awesome (but ridiculously expensive) lightbulbs. As such, exercise extreme caution.

Getting Started

You can get a great overview of the options and limitations of the lights from Ross McKillop.

Usage

To begin using, fire up the irb console from the project root thus:

irb -I lib
>> require 'hue'
=> true

Start by registering your application. Press the button on the bridge and execute

>> Hue.register_default
=> #<Hue::Bridge:0x8b9d950 @application_id="4aa41fe737808af3559f3d22ca67a0ca", @base_uri="http://198.168.1.1/api">

This will create two config files in your ~/.hue-lib directory. One for the bridges discovered on your network and one for the registered application.

You can fetch the default application thus:

>> bridge = Hue.application
=> #<Hue::Bridge:0x8b9d950 @application_id="4aa41fe737808af3559f3d22ca67a0ca", @base_uri="http://198.168.1.1/api">

You can see all of the lights attached to your controller by querying the bridge.

>> bridge.lights
=> {"1"=>{"name"=>"Bedroom Overhead"}, "2"=>{"name"=>"Living Overhead"}, "3"=>{"name"=>"Standing Lamp"}, "4"=>{"name"=>"Living Cabinet"}}
>> bridge.light_names
=> "1. Bedroom Overhead\n2. Living Overhead\n3. Standing Lamp\n4. Living Cabinet"

If you know the ID number of a particular lamp, you can access it directly.

>> b = Hue::Bulb.new(bridge, 1)
=> #<Hue::Bulb:0x007fe35a3586b8 @bridge=#<Hue::Bridge:0x007fe35a358690 @id="1">>

# on/off
>> b.on?
=> false

>> b.on
=> true

>> b.on?
=> true

# brightness
>> b.brightness = 128
=> 128

# color
>> b.color = Hue::Colors::ColorTemperature.new(6500)
=> Temperature=6500°K (153 mired)

>> b.color = Hue::Colors::HueSaturation.new(10_000, 255)
=> Hue=10000, Saturation=255

>> b.color = Hue::Colors::XY.new(0.5, 0.5)
=> XY=[0.5, 0.5]

# blinking
>> b.blinking?
=> false

>> b.blink

>> b.blinking?
=> true

>> b.solid

>> b.blinking?
=> false

About

A simple, experimental Ruby library for controlling Philips Hue lights.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%