philips_hue 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +4 -4
- data/bin/all_off.rb +9 -0
- data/bin/all_on.rb +9 -0
- data/bin/example_script.rb +38 -0
- data/bin/flash.rb +54 -0
- data/bin/sandbox.rb +11 -0
- data/lib/philips_hue.rb +1 -0
- data/lib/philips_hue/light.rb +1 -1
- data/lib/philips_hue/version.rb +3 -0
- metadata +9 -2
data/README.md
CHANGED
@@ -7,16 +7,16 @@ This is a library for accessing and controlling your [Philips Hue](http://www.me
|
|
7
7
|
Check out [bin/example_script.rb](https://github.com/dmerrick/lights_app/blob/master/bin/example_script.rb) for an example of how to use this project and what kind of things you can do.
|
8
8
|
|
9
9
|
|
10
|
-
### Registering
|
10
|
+
### Registering with the Bridge
|
11
11
|
|
12
|
-
You need two things to connect with your Hue, a name for your app and the IP address of the white Hue
|
12
|
+
You need two things to connect with your Hue, a name for your app and the IP address of the white Hue bridge.
|
13
13
|
|
14
14
|
* The IP address can be found on the Hue Community site. Login, [go here](https://www.meethue.com/en-US/user/preferencessmartbridge), click "Show me more," and find the IP under "Internal IP address." Example: `"192.168.1.14"`
|
15
|
-
* 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
|
15
|
+
* 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"`
|
16
16
|
|
17
17
|
Full example:
|
18
18
|
```ruby
|
19
|
-
hue = PhilipsHue.new("my light app", "192.168.1.14")
|
19
|
+
hue = PhilipsHue::Bridge.new("my light app", "192.168.1.14")
|
20
20
|
hue.register!
|
21
21
|
```
|
22
22
|
|
data/bin/all_off.rb
ADDED
data/bin/all_on.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# this is a basic example of what you can do with this library
|
3
|
+
require 'philips_hue'
|
4
|
+
|
5
|
+
# set up your hue app here
|
6
|
+
hue = PhilipsHue::Bridge.new("lightsapp", "192.168.1.14")
|
7
|
+
|
8
|
+
# assign each light to a variable
|
9
|
+
light1, light2, light3 = hue.lights
|
10
|
+
|
11
|
+
# print status of light1
|
12
|
+
puts light1
|
13
|
+
|
14
|
+
# true if we want to have a colorful party
|
15
|
+
looping = true
|
16
|
+
|
17
|
+
# loop pretty colors
|
18
|
+
loop do
|
19
|
+
|
20
|
+
light1.red
|
21
|
+
light2.green
|
22
|
+
light3.blue
|
23
|
+
|
24
|
+
sleep 1
|
25
|
+
|
26
|
+
light1.blue
|
27
|
+
light2.blue
|
28
|
+
light3.yellow
|
29
|
+
|
30
|
+
sleep 1
|
31
|
+
|
32
|
+
light1.yellow
|
33
|
+
light2.red
|
34
|
+
light3.red
|
35
|
+
|
36
|
+
sleep 1
|
37
|
+
|
38
|
+
end if looping
|
data/bin/flash.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# example: flash.rb -l 3 -t 5 -c red -n 3
|
3
|
+
|
4
|
+
require 'ostruct'
|
5
|
+
require 'optparse'
|
6
|
+
require 'philips_hue'
|
7
|
+
|
8
|
+
# set default values here
|
9
|
+
colors = { "red" => [0.6446, 0.3289],
|
10
|
+
"blue" => [0.1727, 0.0512],
|
11
|
+
"green" => [0.4034, 0.5067],
|
12
|
+
"yellow" => [0.4447, 0.4918]}
|
13
|
+
|
14
|
+
options = OpenStruct.new
|
15
|
+
options.light_id = 1
|
16
|
+
options.delay = 1
|
17
|
+
options.repeat = 1
|
18
|
+
options.color = colors["red"]
|
19
|
+
options.app_name = "lightsapp"
|
20
|
+
options.api_url = "192.168.1.14"
|
21
|
+
|
22
|
+
OptionParser.new do |opts|
|
23
|
+
opts.banner = "Usage: flash.rb [options]"
|
24
|
+
opts.on("-l [id]", Integer, "Light to flash") do |id|
|
25
|
+
options.light_id = id
|
26
|
+
end
|
27
|
+
opts.on("-c [color]", "The color to flash") do |color|
|
28
|
+
options.color = colors[color]
|
29
|
+
end
|
30
|
+
opts.on("-t [secs]", Float, "Length of flashes in seconds") do |length|
|
31
|
+
options.delay = length
|
32
|
+
end
|
33
|
+
opts.on("-n [number]", Integer, "Repeat [number] times") do |num|
|
34
|
+
options.repeat = num
|
35
|
+
end
|
36
|
+
opts.on("--app [app_name]", "The name of the registered app") do |app|
|
37
|
+
options.app_name = app
|
38
|
+
end
|
39
|
+
opts.on("--api [url]", "The address of the Hue hub") do |api|
|
40
|
+
options.api_url = api
|
41
|
+
end
|
42
|
+
end.parse!
|
43
|
+
|
44
|
+
# get everything ready...
|
45
|
+
hue = PhilipsHue::Bridge.new(options.app_name, options.api_url)
|
46
|
+
light = hue.light(options.light_id)
|
47
|
+
old_xy = light.xy
|
48
|
+
|
49
|
+
# ...make magic happen
|
50
|
+
options.repeat.times do
|
51
|
+
# flash!
|
52
|
+
light.flash(options.color, :delay => options.delay, :old_xy => old_xy)
|
53
|
+
sleep options.delay
|
54
|
+
end
|
data/bin/sandbox.rb
ADDED
data/lib/philips_hue.rb
CHANGED
data/lib/philips_hue/light.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: philips_hue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -31,11 +31,18 @@ description: A library to control and query Philips Hue lights
|
|
31
31
|
email: dana.merrick@gmail.com
|
32
32
|
executables: []
|
33
33
|
extensions: []
|
34
|
-
extra_rdoc_files:
|
34
|
+
extra_rdoc_files:
|
35
|
+
- README.md
|
35
36
|
files:
|
36
37
|
- lib/philips_hue/bridge.rb
|
37
38
|
- lib/philips_hue/light.rb
|
39
|
+
- lib/philips_hue/version.rb
|
38
40
|
- lib/philips_hue.rb
|
41
|
+
- bin/all_off.rb
|
42
|
+
- bin/all_on.rb
|
43
|
+
- bin/example_script.rb
|
44
|
+
- bin/flash.rb
|
45
|
+
- bin/sandbox.rb
|
39
46
|
- README.md
|
40
47
|
homepage: https://github.com/dmerrick/lights_app
|
41
48
|
licenses: []
|