Ha 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,33 @@
1
+ require_relative "hue_resource"
2
+
3
+ # Represent Hue Sensors
4
+ class Sensor < HueResource
5
+ attr_reader :detail, :on, :name
6
+
7
+ def initialize(key, hashvalue)
8
+ super
9
+ key = analyze_detail @detail
10
+ @on = hashvalue.dig("state", key)
11
+ gen_reskey("s")
12
+ @state.merge! ({"on" => @on})
13
+ end
14
+
15
+ def array(selectors)
16
+ selectors.map { |key| @state[key] }
17
+ end
18
+
19
+ def analyze_detail detail
20
+ key = "status"
21
+ if detail == "CLIPPresence"
22
+ key = "presence"
23
+ elsif detail == "Geofence"
24
+ key = "presence"
25
+ elsif detail == "CLIPGenericFlag"
26
+ key = "flag"
27
+ elsif detail == "Daylight"
28
+ key = "daylight"
29
+ end
30
+ key
31
+ end
32
+
33
+ end
@@ -0,0 +1,3 @@
1
+ module Ha
2
+ VERSION = "0.3.1"
3
+ end
@@ -0,0 +1,32 @@
1
+ require_relative 'test_helper'
2
+ require 'ha/cli_table'
3
+
4
+ class CliTableTest < Minitest::Test
5
+ describe "has core functionality" do
6
+ before do
7
+ @t1 = CliTable.new
8
+ @t2 = CliTable.new
9
+ @t2.add(["a", "b", "c"], [["1", "2", "3"],["X", "Y", "Z"]])
10
+ end
11
+ it "Can accept data" do
12
+ @t1.add(["a", "b", "c"], [["1", "2", "3"],["X", "Y", "Z"]])
13
+ @t1.rows_count.must_equal 2
14
+ end
15
+
16
+ it "Can be reset" do
17
+ @t2.reset
18
+ @t2.rows_count.must_equal 0
19
+ end
20
+
21
+ it "can update headers" do
22
+ @t2.headers = ["Boo", "Foo"]
23
+ @t2.headers.include?("Boo").must_equal true
24
+ end
25
+
26
+ it "generate a simple table" do
27
+ @t2.column_widths = [20, 10, 10]
28
+ res = @t2.render
29
+ res.include?("a").must_equal true
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,99 @@
1
+ {
2
+ "lights": {},
3
+ "groups": {},
4
+ "config": {
5
+ "name": "Philips hue",
6
+ "zigbeechannel": 15,
7
+ "bridgeid": "001788FFFE71C27D",
8
+ "mac": "00:17:88:71:c2:7d",
9
+ "dhcp": true,
10
+ "ipaddress": "10.0.0.89",
11
+ "netmask": "255.255.255.0",
12
+ "gateway": "10.0.0.1",
13
+ "proxyaddress": "none",
14
+ "proxyport": 0,
15
+ "UTC": "2018-10-20T18:03:33",
16
+ "localtime": "none",
17
+ "timezone": "none",
18
+ "modelid": "BSB002",
19
+ "datastoreversion": "73",
20
+ "swversion": "1809121051",
21
+ "apiversion": "1.27.0",
22
+ "swupdate": {
23
+ "updatestate": 0,
24
+ "checkforupdate": false,
25
+ "devicetypes": {
26
+ "bridge": false,
27
+ "lights": [],
28
+ "sensors": []
29
+ },
30
+ "url": "",
31
+ "text": "",
32
+ "notify": false
33
+ },
34
+ "swupdate2": {
35
+ "checkforupdate": false,
36
+ "lastchange": null,
37
+ "bridge": {
38
+ "state": "noupdates",
39
+ "lastinstall": null
40
+ },
41
+ "state": "noupdates",
42
+ "autoinstall": {
43
+ "updatetime": "T14:00:00",
44
+ "on": false
45
+ }
46
+ },
47
+ "linkbutton": false,
48
+ "portalservices": false,
49
+ "portalconnection": "connected",
50
+ "portalstate": {
51
+ "signedon": true,
52
+ "incoming": false,
53
+ "outgoing": true,
54
+ "communication": "disconnected"
55
+ },
56
+ "internetservices": {
57
+ "internet": "connected",
58
+ "remoteaccess": "disconnected",
59
+ "time": "connected",
60
+ "swupdate": "connected"
61
+ },
62
+ "factorynew": true,
63
+ "replacesbridgeid": null,
64
+ "backup": {
65
+ "status": "idle",
66
+ "errorcode": 0
67
+ },
68
+ "starterkitid": "",
69
+ "whitelist": {
70
+ "78UEGUotX3otmWxbhiucELCLiiKmaD9E2O5YW-d1": {
71
+ "last use date": "2018-10-20T18:03:33",
72
+ "create date": "2018-10-20T17:54:35",
73
+ "name": "my_hue_app#iphone peter"
74
+ }
75
+ }
76
+ },
77
+ "schedules": {},
78
+ "scenes": {},
79
+ "rules": {},
80
+ "sensors": {
81
+ "1": {
82
+ "state": {
83
+ "daylight": null,
84
+ "lastupdated": "none"
85
+ },
86
+ "config": {
87
+ "on": true,
88
+ "configured": false,
89
+ "sunriseoffset": 30,
90
+ "sunsetoffset": -30
91
+ },
92
+ "name": "Daylight",
93
+ "type": "Daylight",
94
+ "modelid": "PHDL00",
95
+ "manufacturername": "Philips",
96
+ "swversion": "1.0"
97
+ }
98
+ },
99
+ "resourcelinks": {}
@@ -0,0 +1,423 @@
1
+ {
2
+ "lights": {
3
+ "1": {
4
+ "state": {
5
+ "on": true,
6
+ "bri": 1,
7
+ "alert": "none",
8
+ "mode": "homeautomation",
9
+ "reachable": true
10
+ },
11
+ "swupdate": {
12
+ "state": "noupdates",
13
+ "lastinstall": null
14
+ },
15
+ "type": "Dimmable light",
16
+ "name": "Hue white lamp 1",
17
+ "modelid": "LWB014",
18
+ "manufacturername": "Philips",
19
+ "productname": "Hue white lamp",
20
+ "capabilities": {
21
+ "certified": true,
22
+ "control": {
23
+ "mindimlevel": 5000,
24
+ "maxlumen": 840
25
+ },
26
+ "streaming": {
27
+ "renderer": false,
28
+ "proxy": false
29
+ }
30
+ },
31
+ "config": {
32
+ "archetype": "classicbulb",
33
+ "function": "functional",
34
+ "direction": "omnidirectional"
35
+ },
36
+ "uniqueid": "00:17:88:01:02:8d:81:73-0b",
37
+ "swversion": "1.29.0_r21169",
38
+ "swconfigid": "75D50777",
39
+ "productid": "Philips-LWB014-1-A19DLv3"
40
+ },
41
+ "2": {
42
+ "state": {
43
+ "on": true,
44
+ "bri": 1,
45
+ "alert": "none",
46
+ "mode": "homeautomation",
47
+ "reachable": true
48
+ },
49
+ "swupdate": {
50
+ "state": "noupdates",
51
+ "lastinstall": null
52
+ },
53
+ "type": "Dimmable light",
54
+ "name": "Hue white lamp 2",
55
+ "modelid": "LWB014",
56
+ "manufacturername": "Philips",
57
+ "productname": "Hue white lamp",
58
+ "capabilities": {
59
+ "certified": true,
60
+ "control": {
61
+ "mindimlevel": 5000,
62
+ "maxlumen": 840
63
+ },
64
+ "streaming": {
65
+ "renderer": false,
66
+ "proxy": false
67
+ }
68
+ },
69
+ "config": {
70
+ "archetype": "classicbulb",
71
+ "function": "functional",
72
+ "direction": "omnidirectional"
73
+ },
74
+ "uniqueid": "00:17:88:01:02:f0:09:0e-0b",
75
+ "swversion": "1.29.0_r21169",
76
+ "swconfigid": "75D50777",
77
+ "productid": "Philips-LWB014-1-A19DLv3"
78
+ },
79
+ "3": {
80
+ "state": {
81
+ "on": true,
82
+ "bri": 254,
83
+ "alert": "none",
84
+ "mode": "homeautomation",
85
+ "reachable": false
86
+ },
87
+ "swupdate": {
88
+ "state": "noupdates",
89
+ "lastinstall": null
90
+ },
91
+ "type": "Dimmable light",
92
+ "name": "Hue white lamp 3",
93
+ "modelid": "LWB014",
94
+ "manufacturername": "Philips",
95
+ "productname": "Hue white lamp",
96
+ "capabilities": {
97
+ "certified": true,
98
+ "control": {
99
+ "mindimlevel": 5000,
100
+ "maxlumen": 840
101
+ },
102
+ "streaming": {
103
+ "renderer": false,
104
+ "proxy": false
105
+ }
106
+ },
107
+ "config": {
108
+ "archetype": "classicbulb",
109
+ "function": "functional",
110
+ "direction": "omnidirectional"
111
+ },
112
+ "uniqueid": "00:17:88:01:03:39:24:99-0b",
113
+ "swversion": "1.29.0_r21169",
114
+ "swconfigid": "321D79EA",
115
+ "productid": "Philips-LWB014-1-A19DLv4"
116
+ },
117
+ "4": {
118
+ "state": {
119
+ "on": true,
120
+ "bri": 254,
121
+ "alert": "none",
122
+ "mode": "homeautomation",
123
+ "reachable": false
124
+ },
125
+ "swupdate": {
126
+ "state": "noupdates",
127
+ "lastinstall": null
128
+ },
129
+ "type": "Dimmable light",
130
+ "name": "Hue white lamp 4",
131
+ "modelid": "LWB014",
132
+ "manufacturername": "Philips",
133
+ "productname": "Hue white lamp",
134
+ "capabilities": {
135
+ "certified": true,
136
+ "control": {
137
+ "mindimlevel": 5000,
138
+ "maxlumen": 840
139
+ },
140
+ "streaming": {
141
+ "renderer": false,
142
+ "proxy": false
143
+ }
144
+ },
145
+ "config": {
146
+ "archetype": "classicbulb",
147
+ "function": "functional",
148
+ "direction": "omnidirectional"
149
+ },
150
+ "uniqueid": "00:17:88:01:03:15:3d:0a-0b",
151
+ "swversion": "1.29.0_r21169",
152
+ "swconfigid": "321D79EA",
153
+ "productid": "Philips-LWB014-1-A19DLv4"
154
+ },
155
+ "5": {
156
+ "state": {
157
+ "on": true,
158
+ "bri": 254,
159
+ "alert": "none",
160
+ "mode": "homeautomation",
161
+ "reachable": false
162
+ },
163
+ "swupdate": {
164
+ "state": "noupdates",
165
+ "lastinstall": null
166
+ },
167
+ "type": "Dimmable light",
168
+ "name": "Hue white lamp 5",
169
+ "modelid": "LWB014",
170
+ "manufacturername": "Philips",
171
+ "productname": "Hue white lamp",
172
+ "capabilities": {
173
+ "certified": true,
174
+ "control": {
175
+ "mindimlevel": 5000,
176
+ "maxlumen": 840
177
+ },
178
+ "streaming": {
179
+ "renderer": false,
180
+ "proxy": false
181
+ }
182
+ },
183
+ "config": {
184
+ "archetype": "classicbulb",
185
+ "function": "functional",
186
+ "direction": "omnidirectional"
187
+ },
188
+ "uniqueid": "00:17:88:01:03:3d:c8:e5-0b",
189
+ "swversion": "1.29.0_r21169",
190
+ "swconfigid": "321D79EA",
191
+ "productid": "Philips-LWB014-1-A19DLv4"
192
+ },
193
+ "6": {
194
+ "state": {
195
+ "on": true,
196
+ "bri": 254,
197
+ "alert": "none",
198
+ "mode": "homeautomation",
199
+ "reachable": false
200
+ },
201
+ "swupdate": {
202
+ "state": "noupdates",
203
+ "lastinstall": null
204
+ },
205
+ "type": "Dimmable light",
206
+ "name": "Hue white lamp 6",
207
+ "modelid": "LWB014",
208
+ "manufacturername": "Philips",
209
+ "productname": "Hue white lamp",
210
+ "capabilities": {
211
+ "certified": true,
212
+ "control": {
213
+ "mindimlevel": 5000,
214
+ "maxlumen": 840
215
+ },
216
+ "streaming": {
217
+ "renderer": false,
218
+ "proxy": false
219
+ }
220
+ },
221
+ "config": {
222
+ "archetype": "classicbulb",
223
+ "function": "functional",
224
+ "direction": "omnidirectional"
225
+ },
226
+ "uniqueid": "00:17:88:01:03:3d:c8:ec-0b",
227
+ "swversion": "1.29.0_r21169",
228
+ "swconfigid": "321D79EA",
229
+ "productid": "Philips-LWB014-1-A19DLv4"
230
+ }
231
+ },
232
+ "groups": {
233
+ "1": {
234
+ "name": "Living",
235
+ "lights": [
236
+ "4",
237
+ "5",
238
+ "6",
239
+ "3",
240
+ "2",
241
+ "1"
242
+ ],
243
+ "sensors": [],
244
+ "type": "Room",
245
+ "state": {
246
+ "all_on": true,
247
+ "any_on": true
248
+ },
249
+ "recycle": false,
250
+ "class": "Living room",
251
+ "action": {
252
+ "on": true,
253
+ "bri": 1,
254
+ "alert": "none"
255
+ }
256
+ }
257
+ },
258
+ "config": {
259
+ "name": "Philips hue",
260
+ "zigbeechannel": 15,
261
+ "bridgeid": "001788FFFE71C27D",
262
+ "mac": "00:17:88:71:c2:7d",
263
+ "dhcp": true,
264
+ "ipaddress": "10.0.0.89",
265
+ "netmask": "255.255.255.0",
266
+ "gateway": "10.0.0.1",
267
+ "proxyaddress": "none",
268
+ "proxyport": 0,
269
+ "UTC": "2018-10-21T00:50:14",
270
+ "localtime": "2018-10-20T20:50:14",
271
+ "timezone": "America/New_York",
272
+ "modelid": "BSB002",
273
+ "datastoreversion": "73",
274
+ "swversion": "1809121051",
275
+ "apiversion": "1.27.0",
276
+ "swupdate": {
277
+ "updatestate": 0,
278
+ "checkforupdate": false,
279
+ "devicetypes": {
280
+ "bridge": false,
281
+ "lights": [],
282
+ "sensors": []
283
+ },
284
+ "url": "",
285
+ "text": "",
286
+ "notify": false
287
+ },
288
+ "swupdate2": {
289
+ "checkforupdate": false,
290
+ "lastchange": "2018-10-20T18:24:50",
291
+ "bridge": {
292
+ "state": "noupdates",
293
+ "lastinstall": null
294
+ },
295
+ "state": "noupdates",
296
+ "autoinstall": {
297
+ "updatetime": "T14:00:00",
298
+ "on": false
299
+ }
300
+ },
301
+ "linkbutton": false,
302
+ "portalservices": false,
303
+ "portalconnection": "connected",
304
+ "portalstate": {
305
+ "signedon": true,
306
+ "incoming": false,
307
+ "outgoing": true,
308
+ "communication": "disconnected"
309
+ },
310
+ "internetservices": {
311
+ "internet": "connected",
312
+ "remoteaccess": "disconnected",
313
+ "time": "connected",
314
+ "swupdate": "connected"
315
+ },
316
+ "factorynew": false,
317
+ "replacesbridgeid": null,
318
+ "backup": {
319
+ "status": "idle",
320
+ "errorcode": 0
321
+ },
322
+ "starterkitid": "",
323
+ "whitelist": {
324
+ "78UEGUotX3otmWxbhiucELCLiiKmaD9E2O5YW-d1": {
325
+ "last use date": "2018-10-21T00:50:14",
326
+ "create date": "2018-10-20T17:54:35",
327
+ "name": "my_hue_app#iphone peter"
328
+ },
329
+ "oOkEqFnel2ahz8CngoVzQVUQWqrgrtDY3h3uwxjp": {
330
+ "last use date": "2018-10-20T18:31:40",
331
+ "create date": "2018-10-20T18:22:50",
332
+ "name": "Hue 3#RpsIphone"
333
+ }
334
+ }
335
+ },
336
+ "schedules": {},
337
+ "scenes": {
338
+ "GX9QiSrGsRJMM92": {
339
+ "name": "Bright",
340
+ "lights": [
341
+ "1",
342
+ "2",
343
+ "3",
344
+ "4",
345
+ "5",
346
+ "6"
347
+ ],
348
+ "owner": "oOkEqFnel2ahz8CngoVzQVUQWqrgrtDY3h3uwxjp",
349
+ "recycle": false,
350
+ "locked": false,
351
+ "appdata": {
352
+ "version": 1,
353
+ "data": "o5OXm_r01_d05"
354
+ },
355
+ "picture": "",
356
+ "lastupdated": "2018-10-20T18:25:44",
357
+ "version": 2
358
+ },
359
+ "1DNM5cm3sR83OgR": {
360
+ "name": "Dimmed",
361
+ "lights": [
362
+ "1",
363
+ "2",
364
+ "3",
365
+ "4",
366
+ "5",
367
+ "6"
368
+ ],
369
+ "owner": "oOkEqFnel2ahz8CngoVzQVUQWqrgrtDY3h3uwxjp",
370
+ "recycle": false,
371
+ "locked": false,
372
+ "appdata": {
373
+ "version": 1,
374
+ "data": "sHxcP_r01_d06"
375
+ },
376
+ "picture": "",
377
+ "lastupdated": "2018-10-20T18:25:44",
378
+ "version": 2
379
+ },
380
+ "CSiArHPJWaD0XIW": {
381
+ "name": "Nightlight",
382
+ "lights": [
383
+ "1",
384
+ "2",
385
+ "3",
386
+ "4",
387
+ "5",
388
+ "6"
389
+ ],
390
+ "owner": "oOkEqFnel2ahz8CngoVzQVUQWqrgrtDY3h3uwxjp",
391
+ "recycle": false,
392
+ "locked": false,
393
+ "appdata": {
394
+ "version": 1,
395
+ "data": "gHofY_r01_d07"
396
+ },
397
+ "picture": "",
398
+ "lastupdated": "2018-10-20T18:25:44",
399
+ "version": 2
400
+ }
401
+ },
402
+ "rules": {},
403
+ "sensors": {
404
+ "1": {
405
+ "state": {
406
+ "daylight": null,
407
+ "lastupdated": "none"
408
+ },
409
+ "config": {
410
+ "on": true,
411
+ "configured": false,
412
+ "sunriseoffset": 30,
413
+ "sunsetoffset": -30
414
+ },
415
+ "name": "Daylight",
416
+ "type": "Daylight",
417
+ "modelid": "PHDL00",
418
+ "manufacturername": "Philips",
419
+ "swversion": "1.0"
420
+ }
421
+ },
422
+ "resourcelinks": {}
423
+ }