lights 0.9.1 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/lights +15 -9
- data/lib/lights.rb +7 -1
- data/lib/lights/exception.rb +6 -0
- data/lib/lights/scene.rb +6 -2
- data/lib/lights/version.rb +1 -1
- data/lights.gemspec +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: c6d909c6641d7266b0edc7c8c6b6e237ef70395a
|
4
|
+
data.tar.gz: dd5a4799fd9e63c0debb30900ec5184a554694c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c58ddfb878662d5bf6372477bf7c27e16b1b00ce0b323051a5a0db2aba273e38e9629f69865783c48728f737437c24ce65d577844950e1283bb46cec75d94e8b
|
7
|
+
data.tar.gz: b710fd301e879fbc14d5f527833f7b708d5a9e07e91de3d6255d6a7ef0deca84b78ad42be6637e7ee948fdfac193b7d655a81ccb0551672c6cb974ccacdccd02
|
data/bin/lights
CHANGED
@@ -73,7 +73,8 @@ class LightsCli
|
|
73
73
|
OptionParser.new do |opts|
|
74
74
|
opts.on("-l", "--lights 1,2,...N", Array, "Which lights are in the scene"){|l| options[:lights]=l}
|
75
75
|
opts.on("-n", "--name <name>", String, "Set scene name"){|n| options[:name]=n}
|
76
|
-
opts.on("-
|
76
|
+
opts.on("-r", "--recycle", "Can bridge recycle scene"){|r| options[:recycle]=r}
|
77
|
+
opts.on("-d", "--duration seconds", OptionParser::DecimalInteger, "Transition duration in seconds"){|d| options[:duration]=d}
|
77
78
|
end.parse!
|
78
79
|
|
79
80
|
if !options[:lights]
|
@@ -84,14 +85,12 @@ class LightsCli
|
|
84
85
|
puts "Must specify scene name."
|
85
86
|
exit 1
|
86
87
|
end
|
87
|
-
if !options[:id]
|
88
|
-
puts "Must specify scene id."
|
89
|
-
exit 1
|
90
|
-
end
|
91
88
|
|
92
|
-
s = Scene.new
|
89
|
+
s = Scene.new
|
93
90
|
s.name = options[:name]
|
94
91
|
s.lights = options[:lights]
|
92
|
+
s.recycle = options[:recycle] || false
|
93
|
+
s.transition_time = options[:duration]
|
95
94
|
hue.create_scene s
|
96
95
|
when "group"
|
97
96
|
OptionParser.new do |opts|
|
@@ -192,7 +191,14 @@ class LightsCli
|
|
192
191
|
|
193
192
|
hue.delete_user id
|
194
193
|
when "scene"
|
195
|
-
|
194
|
+
id = ARGV.shift
|
195
|
+
|
196
|
+
if !id
|
197
|
+
puts "Must specify scene id."
|
198
|
+
exit 1
|
199
|
+
end
|
200
|
+
|
201
|
+
hue.delete_scene id
|
196
202
|
when nil
|
197
203
|
STDERR.puts "Must specify a type to delete."
|
198
204
|
else
|
@@ -231,8 +237,8 @@ class LightsCli
|
|
231
237
|
when "scenes"
|
232
238
|
response = hue.request_scene_list
|
233
239
|
objects = SceneList.new(response)
|
234
|
-
titles = ["ID","NAME","LIGHTS"]
|
235
|
-
methods = [:id,:name,:lights]
|
240
|
+
titles = ["ID","NAME","LIGHTS","RECYCLE"]
|
241
|
+
methods = [:id,:name,:lights,:recycle]
|
236
242
|
when "users"
|
237
243
|
response = hue.request_config
|
238
244
|
objects = UserList.new(response["whitelist"])
|
data/lib/lights.rb
CHANGED
@@ -139,7 +139,11 @@ class Lights
|
|
139
139
|
end
|
140
140
|
|
141
141
|
def create_scene( scene )
|
142
|
-
|
142
|
+
post "scenes/#{scene.id}", scene
|
143
|
+
end
|
144
|
+
|
145
|
+
def delete_scene( id )
|
146
|
+
delete "scenes/#{id}"
|
143
147
|
end
|
144
148
|
|
145
149
|
def delete_group( id )
|
@@ -170,6 +174,8 @@ private
|
|
170
174
|
raise ParameterUnavailableException, result["error"]["description"]
|
171
175
|
when 101
|
172
176
|
raise BridgeConnectException
|
177
|
+
when 403
|
178
|
+
raise SceneLockedException, result["error"]["description"]
|
173
179
|
else
|
174
180
|
raise "Unknown Error: #{result["error"]["description"]}"
|
175
181
|
end
|
data/lib/lights/exception.rb
CHANGED
data/lib/lights/scene.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
require 'lights/hobject'
|
2
2
|
|
3
3
|
class Scene < HObject
|
4
|
-
attr_accessor :id, :name, :active, :lights
|
5
|
-
def initialize(id,data = {})
|
4
|
+
attr_accessor :id, :name, :active, :lights, :recycle, :transition_time
|
5
|
+
def initialize(id = nil,data = {})
|
6
6
|
@id = id
|
7
7
|
@name = data["name"]
|
8
8
|
@active = data["active"]
|
9
9
|
@lights = data["lights"]
|
10
|
+
@recycle = data["recycle"]
|
11
|
+
@transition_time = data["transitiontime"]
|
10
12
|
end
|
11
13
|
|
12
14
|
def data
|
@@ -14,6 +16,8 @@ class Scene < HObject
|
|
14
16
|
data["name"] = @name if @name
|
15
17
|
data["active"] = @active unless @active.nil?
|
16
18
|
data["lights"] = @lights if @lights
|
19
|
+
data["recycle"] = @recycle unless @recycle.nil?
|
20
|
+
data["transitiontime"] = @transition_time if @transition_time
|
17
21
|
data
|
18
22
|
end
|
19
23
|
end
|
data/lib/lights/version.rb
CHANGED
data/lights.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.summary = "lights"
|
13
13
|
s.homepage = 'http://rubygems.org/gems/lights'
|
14
14
|
s.license = 'MIT'
|
15
|
-
s.date =
|
15
|
+
s.date = Date.today.to_s
|
16
16
|
|
17
17
|
s.files = `git ls-files`.split($/)
|
18
18
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lights
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brady Turner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simpletable
|
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
164
|
version: '0'
|
165
165
|
requirements: []
|
166
166
|
rubyforge_project:
|
167
|
-
rubygems_version: 2.
|
167
|
+
rubygems_version: 2.6.13
|
168
168
|
signing_key:
|
169
169
|
specification_version: 4
|
170
170
|
summary: lights
|