philips_hue 0.1.3 → 0.1.4
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 +2 -1
- data/bin/all_off.rb +1 -0
- data/bin/all_on.rb +1 -0
- data/bin/flash.rb +1 -0
- data/bin/{example_script.rb → light_show.rb} +1 -4
- data/bin/sandbox.rb +1 -0
- data/bin/{test_script.rb → test.rb} +0 -1
- data/lib/philips_hue/bridge.rb +7 -6
- data/lib/philips_hue/light.rb +7 -4
- data/lib/philips_hue/version.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -4,7 +4,7 @@ This is a library for accessing and controlling your [Philips Hue](http://www.me
|
|
4
4
|
|
5
5
|
#### TL;DR:
|
6
6
|
|
7
|
-
Check out
|
7
|
+
[Check out the bin/ directory for examples](https://github.com/dmerrick/lights_app/tree/master/bin) of how to use this project and what kind of things you can do.
|
8
8
|
|
9
9
|
|
10
10
|
### Registering with the Bridge
|
@@ -60,6 +60,7 @@ Some helper methods, including default color options, are provided. For example:
|
|
60
60
|
|
61
61
|
|
62
62
|
### See Also
|
63
|
+
* [RubyGems homepage for this project](https://rubygems.org/gems/philips_hue)
|
63
64
|
* [Official Philips Hue site](https://www.meethue.com/en-US)
|
64
65
|
* [My original gist](https://gist.github.com/dmerrick/5000839)
|
65
66
|
* [rsmck's hacking guide](http://rsmck.co.uk/hue)
|
data/bin/all_off.rb
CHANGED
data/bin/all_on.rb
CHANGED
data/bin/flash.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
require 'rubygems'
|
3
3
|
require 'philips_hue'
|
4
4
|
|
5
|
-
# set up your hue app here
|
6
5
|
hue = PhilipsHue::Bridge.new("lightsapp", "192.168.1.14")
|
7
|
-
|
8
|
-
# assign each light to a variable
|
9
6
|
light1, light2, light3 = hue.lights
|
10
7
|
|
11
8
|
# print status of light1
|
data/bin/sandbox.rb
CHANGED
data/lib/philips_hue/bridge.rb
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
module PhilipsHue
|
2
2
|
class Bridge
|
3
3
|
|
4
|
-
# creates
|
4
|
+
# creates an app through which to talk to a Philips Hue
|
5
|
+
# (new app names must be registered with the bridge)
|
5
6
|
# app_name is used to register with the Hue
|
6
|
-
# api_url is the hostname/IP address of the
|
7
|
+
# api_url is the hostname/IP address of the bridge
|
7
8
|
def initialize(app_name, api_url)
|
8
|
-
@
|
9
|
-
@key = Digest::MD5.hexdigest(@
|
9
|
+
@app_name = app_name
|
10
|
+
@key = Digest::MD5.hexdigest(@app_name)
|
10
11
|
@api_endpoint = "http://#{api_url}/api"
|
11
12
|
@lights = add_all_lights
|
12
13
|
end
|
13
14
|
|
14
15
|
# provide getter methods for these variables
|
15
|
-
attr_reader :
|
16
|
+
attr_reader :app_name, :key, :api_endpoint, :lights
|
16
17
|
|
17
18
|
# returns overall system status as JSON
|
18
19
|
def overview
|
@@ -36,7 +37,7 @@ module PhilipsHue
|
|
36
37
|
def register!
|
37
38
|
puts "Press the link button on the Hue..."
|
38
39
|
sleep 10
|
39
|
-
json_body = {:username => @key, :devicetype => @
|
40
|
+
json_body = {:username => @key, :devicetype => @app_name}.to_json
|
40
41
|
response = HTTParty.post(@api_endpoint, :body => json_body)
|
41
42
|
|
42
43
|
if response.first["error"] # should be response.code
|
data/lib/philips_hue/light.rb
CHANGED
@@ -3,14 +3,17 @@ module PhilipsHue
|
|
3
3
|
|
4
4
|
def initialize(light_name, light_id, api_endpoint, key)
|
5
5
|
@name = light_name
|
6
|
-
@
|
7
|
-
@api_endpoint = api_endpoint
|
6
|
+
@light_id = light_id
|
8
7
|
@key = key
|
8
|
+
@api_endpoint = api_endpoint
|
9
9
|
end
|
10
10
|
|
11
|
+
# provide getter methods for these variables
|
12
|
+
attr_reader :name, :light_id
|
13
|
+
|
11
14
|
# query full status for single light
|
12
15
|
def status
|
13
|
-
request_uri = "#{@api_endpoint}/#{@key}/lights/#{@
|
16
|
+
request_uri = "#{@api_endpoint}/#{@key}/lights/#{@light_id}"
|
14
17
|
HTTParty.get(request_uri)
|
15
18
|
end
|
16
19
|
|
@@ -18,7 +21,7 @@ module PhilipsHue
|
|
18
21
|
# note that colormode will automagically update
|
19
22
|
def set(options)
|
20
23
|
json_body = options.to_json
|
21
|
-
request_uri = "#{@api_endpoint}/#{@key}/lights/#{@
|
24
|
+
request_uri = "#{@api_endpoint}/#{@key}/lights/#{@light_id}/state"
|
22
25
|
HTTParty.put(request_uri, :body => json_body)
|
23
26
|
end
|
24
27
|
|
data/lib/philips_hue/version.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.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -40,10 +40,10 @@ files:
|
|
40
40
|
- lib/philips_hue.rb
|
41
41
|
- bin/all_off.rb
|
42
42
|
- bin/all_on.rb
|
43
|
-
- bin/example_script.rb
|
44
43
|
- bin/flash.rb
|
44
|
+
- bin/light_show.rb
|
45
45
|
- bin/sandbox.rb
|
46
|
-
- bin/
|
46
|
+
- bin/test.rb
|
47
47
|
- README.md
|
48
48
|
homepage: https://github.com/dmerrick/lights_app
|
49
49
|
licenses: []
|