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.
- checksums.yaml +4 -4
- data/lib/hue/cli.rb +21 -5
- data/lib/hue/client.rb +7 -0
- data/lib/hue/light.rb +1 -1
- data/lib/hue/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad60609e78dfac717ff59ed735c6ec9c309f8faa
|
4
|
+
data.tar.gz: 0d2fc9f44ae1279957886998ba2ce97ca5880b55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb07141d9c06f26184b2f97ff74a4ac233fdd51a6619f08269ccec08a0091c13410106595a36b49615aef7cb41fb213704d0108de26aa639583d82e210f750ba
|
7
|
+
data.tar.gz: ff655b5c6066d7c6ca4af4317f4b172f84ce4cc846005c9684e31686ad5d27db45fd95ee31fc1a71b9e66720d0b76f70bfeb50a1a14bb67c19286a5a85c1b060
|
data/lib/hue/cli.rb
CHANGED
@@ -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 :
|
23
|
-
option :
|
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
|
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
|
data/lib/hue/client.rb
CHANGED
@@ -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
|
data/lib/hue/light.rb
CHANGED
data/lib/hue/version.rb
CHANGED
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.
|
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-
|
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.
|
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.
|