lights 0.8.15 → 0.8.16
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 +8 -8
- data/bin/lights +10 -11
- data/lib/lights/datastore.rb +1 -1
- data/lib/lights/version.rb +1 -1
- data/spec/bulbstate_spec.rb +38 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OTdkYTA0Yzg4MzdkNjk4Nzc0YzkzMWI4ODQ2YWJmMWQ4MjhkMTRiMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTAwNTU4ZTM1NDAzZDkzNmI5NDA3MGVlMDllOGI4NzNhODM0YzY3Ng==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Mjk2MzZiN2M5ZGMzYjU4N2VmNmJkN2QzMDQ5NmMxMTVkNWM3NDUyMzFiY2Nj
|
10
|
+
NmUwZDgxOGU3ODlhMzA4NjVhNmJhNzE4ZTI0MzVjMDBmNmNkZjBmYjVlNWU2
|
11
|
+
ZmFiZDBkOGMwNDQ3MGVhMjJmMTFjOTVhY2ZiMmQ3Y2EyNTAwZTI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YmY3NWM5ZTk3MDM4YjFjODE5Zjk2NGRhYWQxY2RjZWQ3MDYyYjEyMDQ3OWIz
|
14
|
+
MDZlODExMWEyNzc4ODliY2Q5YjlkMDk3OTM1NmY0NDA4MzlhZjRhMjMwZTkw
|
15
|
+
OWI5NmUyNzNiZWYwNGExNzU4ZjI5MTNlYTkzM2RmNDI4NTBjYzM=
|
data/bin/lights
CHANGED
@@ -173,7 +173,6 @@ class LightsCli
|
|
173
173
|
|
174
174
|
def list
|
175
175
|
hue = Lights.new @config["bridge_ip"], @config["username"]
|
176
|
-
objects = []
|
177
176
|
titles = []
|
178
177
|
methods = []
|
179
178
|
|
@@ -187,42 +186,42 @@ class LightsCli
|
|
187
186
|
case type
|
188
187
|
when nil, "","lights"
|
189
188
|
response = options[:new] ? hue.request_new_bulb_list : hue.request_bulb_list
|
190
|
-
objects = BulbList.new(response)
|
189
|
+
objects = BulbList.new(response)
|
191
190
|
titles = ["ID","NAME"]
|
192
191
|
methods = [:id,:name]
|
193
192
|
when "sensors"
|
194
193
|
response = options[:new] ? hue.request_new_sensor_list : hue.request_sensor_list
|
195
|
-
objects = SensorList.new(response)
|
194
|
+
objects = SensorList.new(response)
|
196
195
|
titles = ["ID","NAME"]
|
197
196
|
methods = [:id,:name]
|
198
197
|
when "groups"
|
199
198
|
response = hue.request_group_list
|
200
|
-
objects = GroupList.new(response)
|
199
|
+
objects = GroupList.new(response)
|
201
200
|
titles = ["ID","NAME","LIGHTS"]
|
202
201
|
methods = [:id,:name,:lights]
|
203
202
|
when "scenes"
|
204
203
|
response = hue.request_scene_list
|
205
|
-
objects = SceneList.new(response)
|
204
|
+
objects = SceneList.new(response)
|
206
205
|
titles = ["ID","NAME","LIGHTS"]
|
207
206
|
methods = [:id,:name,:lights]
|
208
207
|
when "users"
|
209
208
|
response = hue.request_config
|
210
|
-
objects = UserList.new(response["whitelist"])
|
209
|
+
objects = UserList.new(response["whitelist"])
|
211
210
|
titles = ["ID","NAME","CREATE DATE","LAST USE DATE"]
|
212
211
|
methods = [:id,:name,:create_date,:last_use_date]
|
213
212
|
when "rules"
|
214
213
|
response = hue.request_rules
|
215
|
-
objects = RuleList.new(response)
|
214
|
+
objects = RuleList.new(response)
|
216
215
|
titles = ["ID","NAME"]
|
217
216
|
methods = [:id,:name]
|
218
217
|
when "schedules"
|
219
218
|
response = hue.request_schedules
|
220
|
-
objects = ScheduleList.new(response)
|
219
|
+
objects = ScheduleList.new(response)
|
221
220
|
titles = ["ID","NAME","TIME","SCENE","STATUS"]
|
222
221
|
methods = [:id,:name,:time,:scene,:status]
|
223
222
|
when "datastore"
|
224
223
|
response = hue.request_datastore
|
225
|
-
objects = Datastore.new(response)
|
224
|
+
objects = Datastore.new(response)
|
226
225
|
titles = ["TYPE","ID","NAME"]
|
227
226
|
methods = [:class,:id,:name]
|
228
227
|
else
|
@@ -230,9 +229,9 @@ class LightsCli
|
|
230
229
|
return
|
231
230
|
end
|
232
231
|
if options[:json]
|
233
|
-
puts JSON.pretty_generate
|
232
|
+
puts JSON.pretty_generate objects.data
|
234
233
|
else
|
235
|
-
puts SimpleTable.new.from_objects(objects,titles,methods).text
|
234
|
+
puts SimpleTable.new.from_objects(objects.list,titles,methods).text
|
236
235
|
end
|
237
236
|
end
|
238
237
|
|
data/lib/lights/datastore.rb
CHANGED
data/lib/lights/version.rb
CHANGED
data/spec/bulbstate_spec.rb
CHANGED
@@ -19,11 +19,13 @@ describe BulbState do
|
|
19
19
|
data = { "on" => true }
|
20
20
|
bulb = BulbState.new(data)
|
21
21
|
bulb.on.should eql true
|
22
|
+
bulb.data["on"].should eql true
|
22
23
|
end
|
23
24
|
it "should properly set on value" do
|
24
25
|
b = BulbState.new
|
25
26
|
b.on = true
|
26
27
|
b.on.should eq true
|
28
|
+
b.data["on"].should eq true
|
27
29
|
end
|
28
30
|
it "should raise exception when on has invalid type" do
|
29
31
|
b = BulbState.new
|
@@ -35,24 +37,28 @@ describe BulbState do
|
|
35
37
|
data = { "bri" => BulbState::MAX_BRI }
|
36
38
|
b = BulbState.new(data)
|
37
39
|
b.bri.should eq BulbState::MAX_BRI
|
40
|
+
b.data["bri"].should eq BulbState::MAX_BRI
|
38
41
|
end
|
39
42
|
|
40
43
|
it "should properly set brightness value in constructor" do
|
41
44
|
data = { "bri" => BulbState::MIN_BRI }
|
42
45
|
b = BulbState.new(data)
|
43
46
|
b.bri.should eq BulbState::MIN_BRI
|
47
|
+
b.data["bri"].should eq BulbState::MIN_BRI
|
44
48
|
end
|
45
49
|
|
46
50
|
it "should properly set brightness value" do
|
47
51
|
b = BulbState.new
|
48
52
|
b.bri = BulbState::MAX_BRI
|
49
53
|
b.bri.should eq BulbState::MAX_BRI
|
54
|
+
b.data["bri"].should eq BulbState::MAX_BRI
|
50
55
|
end
|
51
56
|
|
52
57
|
it "should properly set brightness value" do
|
53
58
|
b = BulbState.new
|
54
59
|
b.bri = BulbState::MIN_BRI
|
55
60
|
b.bri.should eq BulbState::MIN_BRI
|
61
|
+
b.data["bri"].should eq BulbState::MIN_BRI
|
56
62
|
end
|
57
63
|
|
58
64
|
it "should raise exception when brightness value is not an integer" do
|
@@ -85,24 +91,28 @@ describe BulbState do
|
|
85
91
|
data = { "sat" => BulbState::MAX_SAT }
|
86
92
|
b = BulbState.new(data)
|
87
93
|
b.sat.should eq BulbState::MAX_SAT
|
94
|
+
b.data["sat"].should eq BulbState::MAX_SAT
|
88
95
|
end
|
89
96
|
|
90
97
|
it "should properly set saturation value in constructor" do
|
91
98
|
data = { "sat" => BulbState::MIN_SAT }
|
92
99
|
b = BulbState.new(data)
|
93
100
|
b.sat.should eq BulbState::MIN_SAT
|
101
|
+
b.data["sat"].should eq BulbState::MIN_SAT
|
94
102
|
end
|
95
103
|
|
96
104
|
it "should properly set saturation value" do
|
97
105
|
b = BulbState.new
|
98
106
|
b.sat = BulbState::MAX_SAT
|
99
107
|
b.sat.should eq BulbState::MAX_SAT
|
108
|
+
b.data["sat"].should eq BulbState::MAX_SAT
|
100
109
|
end
|
101
110
|
|
102
111
|
it "should properly set saturation value" do
|
103
112
|
b = BulbState.new
|
104
113
|
b.sat = BulbState::MIN_SAT
|
105
114
|
b.sat.should eq BulbState::MIN_SAT
|
115
|
+
b.data["sat"].should eq BulbState::MIN_SAT
|
106
116
|
end
|
107
117
|
|
108
118
|
it "should raise exception when sat value is not an integer" do
|
@@ -134,25 +144,29 @@ describe BulbState do
|
|
134
144
|
it "should properly set hue value in constructor" do
|
135
145
|
data = { "hue" => BulbState::MAX_HUE }
|
136
146
|
b = BulbState.new(data)
|
137
|
-
b.hue.should eq BulbState::MAX_HUE
|
147
|
+
b.hue.should eq BulbState::MAX_HUE
|
148
|
+
b.data["hue"].should eq BulbState::MAX_HUE
|
138
149
|
end
|
139
150
|
|
140
151
|
it "should properly set hue value in constructor" do
|
141
152
|
data = { "hue" => BulbState::MIN_HUE }
|
142
153
|
b = BulbState.new(data)
|
143
|
-
b.hue.should eq BulbState::MIN_HUE
|
154
|
+
b.hue.should eq BulbState::MIN_HUE
|
155
|
+
b.data["hue"].should eq BulbState::MIN_HUE
|
144
156
|
end
|
145
157
|
|
146
158
|
it "should properly set hue value" do
|
147
159
|
b = BulbState.new
|
148
160
|
b.hue = BulbState::MAX_HUE
|
149
|
-
b.hue.should eq BulbState::MAX_HUE
|
161
|
+
b.hue.should eq BulbState::MAX_HUE
|
162
|
+
b.data["hue"].should eq BulbState::MAX_HUE
|
150
163
|
end
|
151
164
|
|
152
165
|
it "should properly set hue value" do
|
153
166
|
b = BulbState.new
|
154
167
|
b.hue = BulbState::MIN_HUE
|
155
|
-
b.hue.should eq BulbState::MIN_HUE
|
168
|
+
b.hue.should eq BulbState::MIN_HUE
|
169
|
+
b.data["hue"].should eq BulbState::MIN_HUE
|
156
170
|
end
|
157
171
|
|
158
172
|
it "should raise exception when hue value is not an integer" do
|
@@ -185,24 +199,28 @@ describe BulbState do
|
|
185
199
|
data = { "ct" => BulbState::MAX_CT }
|
186
200
|
b = BulbState.new(data)
|
187
201
|
b.ct.should eq BulbState::MAX_CT
|
202
|
+
b.data["ct"].should eq BulbState::MAX_CT
|
188
203
|
end
|
189
204
|
|
190
205
|
it "should properly set color temperature value in constructor" do
|
191
206
|
data = { "ct" => BulbState::MIN_CT }
|
192
207
|
b = BulbState.new(data)
|
193
208
|
b.ct.should eq BulbState::MIN_CT
|
209
|
+
b.data["ct"].should eq BulbState::MIN_CT
|
194
210
|
end
|
195
211
|
|
196
212
|
it "should properly set color temperature value" do
|
197
213
|
b = BulbState.new
|
198
214
|
b.ct = BulbState::MAX_CT
|
199
215
|
b.ct.should eq BulbState::MAX_CT
|
216
|
+
b.data["ct"].should eq BulbState::MAX_CT
|
200
217
|
end
|
201
218
|
|
202
219
|
it "should properly set color temperature value" do
|
203
220
|
b = BulbState.new
|
204
221
|
b.ct = BulbState::MIN_CT
|
205
222
|
b.ct.should eq BulbState::MIN_CT
|
223
|
+
b.data["ct"].should eq BulbState::MIN_CT
|
206
224
|
end
|
207
225
|
|
208
226
|
it "should raise exception when color temperature value is not an integer" do
|
@@ -235,24 +253,28 @@ describe BulbState do
|
|
235
253
|
data = { "effect" => BulbState::Effect::COLORLOOP }
|
236
254
|
b = BulbState.new(data)
|
237
255
|
b.effect.should eq BulbState::Effect::COLORLOOP
|
256
|
+
b.data["effect"].should eq BulbState::Effect::COLORLOOP
|
238
257
|
end
|
239
258
|
|
240
259
|
it "should properly set effect value in constructor" do
|
241
260
|
data = { "effect" => BulbState::Effect::COLORLOOP }
|
242
261
|
b = BulbState.new(data)
|
243
262
|
b.effect.should eq BulbState::Effect::COLORLOOP
|
263
|
+
b.data["effect"].should eq BulbState::Effect::COLORLOOP
|
244
264
|
end
|
245
265
|
|
246
266
|
it "should properly set effect value" do
|
247
267
|
b = BulbState.new
|
248
268
|
b.effect = BulbState::Effect::COLORLOOP
|
249
269
|
b.effect.should eq BulbState::Effect::COLORLOOP
|
270
|
+
b.data["effect"].should eq BulbState::Effect::COLORLOOP
|
250
271
|
end
|
251
272
|
|
252
273
|
it "should properly set effect value" do
|
253
274
|
b = BulbState.new
|
254
275
|
b.effect = BulbState::Effect::NONE
|
255
276
|
b.effect.should eq BulbState::Effect::NONE
|
277
|
+
b.data["effect"].should eq BulbState::Effect::NONE
|
256
278
|
end
|
257
279
|
|
258
280
|
it "should raise exception when effect value is invalid" do
|
@@ -265,12 +287,14 @@ describe BulbState do
|
|
265
287
|
data = { "transitiontime" => 0.1 }
|
266
288
|
b = BulbState.new(data)
|
267
289
|
b.transition_time.should eq 0.1
|
290
|
+
b.data["transitiontime"].should eq 0.1
|
268
291
|
end
|
269
292
|
|
270
293
|
it "should properly set transition time value" do
|
271
294
|
b = BulbState.new
|
272
295
|
b.transition_time = BulbState::MIN_TRANSITION_TIME
|
273
296
|
b.transition_time.should eq BulbState::MIN_TRANSITION_TIME
|
297
|
+
b.data["transitiontime"].should eq BulbState::MIN_TRANSITION_TIME
|
274
298
|
end
|
275
299
|
|
276
300
|
it "should raise exception when transition time value is invalid" do
|
@@ -288,18 +312,21 @@ describe BulbState do
|
|
288
312
|
data = { "alert" => BulbState::Alert::SELECT }
|
289
313
|
b = BulbState.new(data)
|
290
314
|
b.alert.should eq BulbState::Alert::SELECT
|
315
|
+
b.data["alert"].should eq BulbState::Alert::SELECT
|
291
316
|
end
|
292
317
|
|
293
318
|
it "should properly set alert value" do
|
294
319
|
b = BulbState.new
|
295
320
|
b.alert = BulbState::Alert::LSELECT
|
296
321
|
b.alert.should eq BulbState::Alert::LSELECT
|
322
|
+
b.data["alert"].should eq BulbState::Alert::LSELECT
|
297
323
|
end
|
298
324
|
|
299
325
|
it "should properly set alert value" do
|
300
326
|
b = BulbState.new
|
301
327
|
b.alert = BulbState::Alert::NONE
|
302
328
|
b.alert.should eq BulbState::Alert::NONE
|
329
|
+
b.data["alert"].should eq BulbState::Alert::NONE
|
303
330
|
end
|
304
331
|
|
305
332
|
it "should raise exception when alert value is invalid" do
|
@@ -312,18 +339,21 @@ describe BulbState do
|
|
312
339
|
data = { "colormode" => BulbState::ColorMode::HS }
|
313
340
|
b = BulbState.new(data)
|
314
341
|
b.color_mode.should eq BulbState::ColorMode::HS
|
342
|
+
b.data["colormode"].should eq BulbState::ColorMode::HS
|
315
343
|
end
|
316
344
|
|
317
345
|
it "should properly set color mode value" do
|
318
346
|
b = BulbState.new
|
319
347
|
b.color_mode = BulbState::ColorMode::XY
|
320
348
|
b.color_mode.should eq BulbState::ColorMode::XY
|
349
|
+
b.data["colormode"].should eq BulbState::ColorMode::XY
|
321
350
|
end
|
322
351
|
|
323
352
|
it "should properly set color mode value" do
|
324
353
|
b = BulbState.new
|
325
354
|
b.color_mode = BulbState::ColorMode::CT
|
326
355
|
b.color_mode.should eq BulbState::ColorMode::CT
|
356
|
+
b.data["colormode"].should eq BulbState::ColorMode::CT
|
327
357
|
end
|
328
358
|
|
329
359
|
it "should raise exception when alert value is invalid" do
|
@@ -337,6 +367,7 @@ describe BulbState do
|
|
337
367
|
data = { "xy" => xy }
|
338
368
|
b = BulbState.new(data)
|
339
369
|
b.xy.should eq xy
|
370
|
+
b.data["xy"].should eq xy
|
340
371
|
end
|
341
372
|
|
342
373
|
it "should properly set xy value in constructor" do
|
@@ -344,6 +375,7 @@ describe BulbState do
|
|
344
375
|
data = { "xy" => xy }
|
345
376
|
b = BulbState.new(data)
|
346
377
|
b.xy.should eq xy
|
378
|
+
b.data["xy"].should eq xy
|
347
379
|
end
|
348
380
|
|
349
381
|
it "should properly set xy value" do
|
@@ -351,6 +383,7 @@ describe BulbState do
|
|
351
383
|
xy = [BulbState::MAX_XY,BulbState::MAX_XY]
|
352
384
|
b.xy = xy
|
353
385
|
b.xy.should eq xy
|
386
|
+
b.data["xy"].should eq xy
|
354
387
|
end
|
355
388
|
|
356
389
|
it "should properly set xy value" do
|
@@ -358,6 +391,7 @@ describe BulbState do
|
|
358
391
|
xy = [BulbState::MIN_XY,BulbState::MIN_XY]
|
359
392
|
b.xy = xy
|
360
393
|
b.xy.should eq xy
|
394
|
+
b.data["xy"].should eq xy
|
361
395
|
end
|
362
396
|
|
363
397
|
it "should raise exception when xy value is not an array" do
|