philips_hue 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
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 [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.
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
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ require 'rubygems'
2
3
  require 'philips_hue'
3
4
 
4
5
  hue = PhilipsHue::Bridge.new("lightsapp", "192.168.1.14")
data/bin/all_on.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ require 'rubygems'
2
3
  require 'philips_hue'
3
4
 
4
5
  hue = PhilipsHue::Bridge.new("lightsapp", "192.168.1.14")
data/bin/flash.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # example: flash.rb -l 3 -t 5 -c red -n 3
3
3
 
4
+ require 'rubygems'
4
5
  require 'ostruct'
5
6
  require 'optparse'
6
7
  require 'philips_hue'
@@ -1,11 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- # this is a basic example of what you can do with this library
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
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ require 'rubygems'
2
3
  require 'pp'
3
4
  require 'awesome_print'
4
5
  require 'pry'
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
-
3
2
  require 'rubygems'
4
3
  require 'philips_hue'
5
4
 
@@ -1,18 +1,19 @@
1
1
  module PhilipsHue
2
2
  class Bridge
3
3
 
4
- # creates a new app to talk to a Philips Hue
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 Hue hockeypuck
7
+ # api_url is the hostname/IP address of the bridge
7
8
  def initialize(app_name, api_url)
8
- @name = app_name
9
- @key = Digest::MD5.hexdigest(@name)
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 :name, :key, :api_endpoint, :lights
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 => @name}.to_json
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
@@ -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
- @id = light_id
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/#{@id}"
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/#{@id}/state"
24
+ request_uri = "#{@api_endpoint}/#{@key}/lights/#{@light_id}/state"
22
25
  HTTParty.put(request_uri, :body => json_body)
23
26
  end
24
27
 
@@ -1,3 +1,3 @@
1
1
  module PhilipsHue
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
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.3
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/test_script.rb
46
+ - bin/test.rb
47
47
  - README.md
48
48
  homepage: https://github.com/dmerrick/lights_app
49
49
  licenses: []