hue 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d6a7f55311b35aa3cb7e2907ecad349632e102b7
4
- data.tar.gz: 3201fe193181c257741f03f14a71b78b78ca3ecf
3
+ metadata.gz: ad60609e78dfac717ff59ed735c6ec9c309f8faa
4
+ data.tar.gz: 0d2fc9f44ae1279957886998ba2ce97ca5880b55
5
5
  SHA512:
6
- metadata.gz: 76884d923bbe4ee4084bd121caae4f0004cb25f0fcd8e0618f27acd5887c89350f412e4d765c2e0ac148c079e82f245261d0a8664eff2eb6dbb3a7a64d8f88b3
7
- data.tar.gz: c86bbdea9bca5ec707791137c72836fae70f3a4fd9978eff41b472968391f2a32b14494bb9885fa943a8f636ac9d4e9a62de83d15bc24917fcdcdeae2829c150
6
+ metadata.gz: eb07141d9c06f26184b2f97ff74a4ac233fdd51a6619f08269ccec08a0091c13410106595a36b49615aef7cb41fb213704d0108de26aa639583d82e210f750ba
7
+ data.tar.gz: ff655b5c6066d7c6ca4af4317f4b172f84ce4cc846005c9684e31686ad5d27db45fd95ee31fc1a71b9e66720d0b76f70bfeb50a1a14bb67c19286a5a85c1b060
@@ -9,6 +9,14 @@ module Hue
9
9
  end
10
10
  end
11
11
 
12
+ desc 'add LIGHTS', 'Search for new lights'
13
+ def add(thing)
14
+ case thing
15
+ when 'lights'
16
+ client.add_lights
17
+ end
18
+ end
19
+
12
20
  desc 'all STATE', 'Send commands to all lights'
13
21
  def all(state)
14
22
  on = state == 'on'
@@ -17,17 +25,25 @@ module Hue
17
25
  end
18
26
  end
19
27
 
20
- desc 'light ID STATE', 'Access a light'
28
+ desc 'light ID STATE [COLOR]', 'Access a light'
29
+ long_desc <<-LONGDESC
30
+ Examples: \n
31
+ hue light 1 on --hue 12345 \n
32
+ hue light 1 --bri 25 \n
33
+ hue light 1 --alert lselect \n
34
+ hue light 1 off
35
+ LONGDESC
21
36
  option :hue, :type => :numeric
22
- option :saturation, :type => :numeric
23
- option :brightness, :type => :numeric
37
+ option :sat, :type => :numeric
38
+ option :bri, :type => :numeric
39
+ option :alert, :type => :string
24
40
  def light(id, state = nil)
25
41
  light = client.light(id)
26
42
  puts light.name
27
43
 
28
44
  body = options.dup
29
- body[:on] = state unless state.nil?
30
- light.set_state(body) if body.length > 0
45
+ body[:on] = (state == 'on' || !(state == 'off'))
46
+ puts light.set_state(body) if body.length > 0
31
47
  end
32
48
 
33
49
  private
@@ -42,6 +42,13 @@ module Hue
42
42
  end
43
43
  end
44
44
 
45
+ def add_lights
46
+ uri = URI.parse("http://#{bridge.ip}/api/#{@username}/lights")
47
+ http = Net::HTTP.new(uri.host)
48
+ response = http.request_post(uri.path, nil)
49
+ MultiJson.load(response.body).first
50
+ end
51
+
45
52
  def light(id)
46
53
  self.lights.select { |l| l.id == id }.first
47
54
  end
@@ -180,7 +180,7 @@ module Hue
180
180
  def translate_keys(hash)
181
181
  new_hash = {}
182
182
  hash.each do |key, value|
183
- new_key = KEYS_MAP[key.to_sym]
183
+ new_key = STATE_KEYS_MAP[key.to_sym]
184
184
  key = new_key if new_key
185
185
  new_hash[key] = value
186
186
  end
@@ -1,3 +1,3 @@
1
1
  module Hue
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Soffes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-03 00:00:00.000000000 Z
11
+ date: 2013-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  version: '0'
83
83
  requirements: []
84
84
  rubyforge_project:
85
- rubygems_version: 2.0.2
85
+ rubygems_version: 2.0.3
86
86
  signing_key:
87
87
  specification_version: 4
88
88
  summary: Work with Philips Hue light bulbs from Ruby.