Project

hue-lib

0.01
No commit activity in last 3 years
No release in over 3 years
Library allowing registration and invocation of a registered Philips Hue app. Convinient objects allow executing commands on the bridge or individual bulbs.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0.9.0
>= 0
>= 2.6.0
>= 1.8.0

Runtime

>= 0
 Project Readme

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