homey-lib 2.45.0 → 2.45.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.
- package/assets/capability/capabilities/cooking_time.json +1 -0
- package/assets/capability/capabilities/target_power.json +20 -20
- package/assets/capability/capabilities/target_power_mode.json +47 -47
- package/lib/App/index.js +1 -1
- package/package.json +1 -1
- package/webpack/index.js +1 -1
- package/.github/workflows/apply_locales.yml +0 -57
- package/.github/workflows/deploy.yml +0 -181
- package/.github/workflows/generate_locales.yml +0 -60
- package/.github/workflows/static.yml +0 -43
- package/.github/workflows/test.yml +0 -51
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/node-homey-lib.iml +0 -12
- package/.idea/vcs.xml +0 -6
- package/test/fixtures/mock-app.js +0 -137
- package/test/validate-base-manifest.js +0 -685
- package/test/validate-capabilities.js +0 -109
- package/test/validate-driver-manifest.js +0 -835
- package/test/validate-files.js +0 -267
|
@@ -1,835 +0,0 @@
|
|
|
1
|
-
/* eslint-disable node/no-unpublished-require */
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
const {
|
|
6
|
-
mockApp,
|
|
7
|
-
clearMockApp,
|
|
8
|
-
assertValidates,
|
|
9
|
-
baseAppManifest,
|
|
10
|
-
baseDriverManifest,
|
|
11
|
-
} = require('./fixtures/mock-app');
|
|
12
|
-
|
|
13
|
-
describe('HomeyLib.App#validate() driver manifest', function() {
|
|
14
|
-
this.slow(500);
|
|
15
|
-
|
|
16
|
-
afterEach(function() {
|
|
17
|
-
clearMockApp();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
/*
|
|
21
|
-
* Driver ID
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
it('`id` needs to be defined', async function() {
|
|
25
|
-
const app = mockApp({
|
|
26
|
-
...baseAppManifest,
|
|
27
|
-
drivers: [{
|
|
28
|
-
...baseDriverManifest,
|
|
29
|
-
id: undefined,
|
|
30
|
-
}],
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
await assertValidates(app, {
|
|
34
|
-
debug: /should have required property 'id'/i,
|
|
35
|
-
publish: /should have required property 'id'/i,
|
|
36
|
-
verified: /should have required property 'id'/i,
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
/*
|
|
41
|
-
* Driver Capabilities
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
it('`capabilities` needs to be defined', async function() {
|
|
45
|
-
const app = mockApp({
|
|
46
|
-
...baseAppManifest,
|
|
47
|
-
drivers: [{
|
|
48
|
-
...baseDriverManifest,
|
|
49
|
-
capabilities: undefined,
|
|
50
|
-
}],
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
await assertValidates(app, {
|
|
54
|
-
debug: /should have required property 'capabilities'/i,
|
|
55
|
-
publish: /should have required property 'capabilities'/i,
|
|
56
|
-
verified: /should have required property 'capabilities'/i,
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('`capabilities` needs to be valid', async function() {
|
|
61
|
-
const app = mockApp({
|
|
62
|
-
...baseAppManifest,
|
|
63
|
-
drivers: [{
|
|
64
|
-
...baseDriverManifest,
|
|
65
|
-
capabilities: ['test'],
|
|
66
|
-
}],
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
await assertValidates(app, {
|
|
70
|
-
debug: /drivers\.test invalid capability/i,
|
|
71
|
-
publish: /drivers\.test invalid capability/i,
|
|
72
|
-
verified: /drivers\.test invalid capability/i,
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('`capabilities` needs to be valid (with sub-capabilities)', async function() {
|
|
77
|
-
const app = mockApp({
|
|
78
|
-
...baseAppManifest,
|
|
79
|
-
drivers: [{
|
|
80
|
-
...baseDriverManifest,
|
|
81
|
-
capabilities: ['test.one'],
|
|
82
|
-
}],
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
await assertValidates(app, {
|
|
86
|
-
debug: /drivers\.test invalid capability/i,
|
|
87
|
-
publish: /drivers\.test invalid capability/i,
|
|
88
|
-
verified: /drivers\.test invalid capability/i,
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('`capabilities` custom capabilities are validated', async function() {
|
|
93
|
-
const app = mockApp({
|
|
94
|
-
...baseAppManifest,
|
|
95
|
-
drivers: [{
|
|
96
|
-
...baseDriverManifest,
|
|
97
|
-
capabilities: ['test'],
|
|
98
|
-
}],
|
|
99
|
-
capabilities: {
|
|
100
|
-
test: {
|
|
101
|
-
type: 'boolean',
|
|
102
|
-
title: 'Test capability',
|
|
103
|
-
getable: true,
|
|
104
|
-
setable: true,
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
await assertValidates(app, {
|
|
110
|
-
debug: true,
|
|
111
|
-
publish: true,
|
|
112
|
-
verified: true,
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it('`capabilities` custom sub-capabilities are validated', async function() {
|
|
117
|
-
const app = mockApp({
|
|
118
|
-
...baseAppManifest,
|
|
119
|
-
drivers: [{
|
|
120
|
-
...baseDriverManifest,
|
|
121
|
-
capabilities: ['test.one', 'test.two'],
|
|
122
|
-
}],
|
|
123
|
-
capabilities: {
|
|
124
|
-
test: {
|
|
125
|
-
type: 'boolean',
|
|
126
|
-
title: 'Test capability',
|
|
127
|
-
getable: true,
|
|
128
|
-
setable: true,
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
await assertValidates(app, {
|
|
134
|
-
debug: true,
|
|
135
|
-
publish: true,
|
|
136
|
-
verified: true,
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
/*
|
|
141
|
-
* Driver Images
|
|
142
|
-
*/
|
|
143
|
-
|
|
144
|
-
it('`images` needs to be defined', async function() {
|
|
145
|
-
const app = mockApp({
|
|
146
|
-
...baseAppManifest,
|
|
147
|
-
drivers: [{
|
|
148
|
-
...baseDriverManifest,
|
|
149
|
-
images: undefined,
|
|
150
|
-
}],
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
await assertValidates(app, {
|
|
154
|
-
debug: true, // debug does not validate images
|
|
155
|
-
publish: /property `images` is required/i,
|
|
156
|
-
verified: /property `images` is required/i,
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it('`images` need to be a known format', async function() {
|
|
161
|
-
const app = mockApp({
|
|
162
|
-
...baseAppManifest,
|
|
163
|
-
drivers: [{
|
|
164
|
-
...baseDriverManifest,
|
|
165
|
-
images: {
|
|
166
|
-
small: '/assets/images/small.webp',
|
|
167
|
-
large: '/assets/images/large.webp',
|
|
168
|
-
xlarge: '/assets/images/xlarge.webp',
|
|
169
|
-
},
|
|
170
|
-
}],
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
await assertValidates(app, {
|
|
174
|
-
debug: true, // debug does not validate images
|
|
175
|
-
publish: /invalid image extension/i,
|
|
176
|
-
verified: /invalid image extension/i,
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
/*
|
|
181
|
-
* Driver Platforms
|
|
182
|
-
*/
|
|
183
|
-
|
|
184
|
-
it('`platforms` needs to be defined', async function() {
|
|
185
|
-
const app = mockApp({
|
|
186
|
-
...baseAppManifest,
|
|
187
|
-
drivers: [{
|
|
188
|
-
...baseDriverManifest,
|
|
189
|
-
platforms: undefined,
|
|
190
|
-
}],
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
await assertValidates(app, {
|
|
194
|
-
debug: true, // platforms is optional for debug, but will warn
|
|
195
|
-
publish: true, // platforms is optional for publish, but will warn
|
|
196
|
-
verified: /property `platforms` is required/i,
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
it('`platforms` needs to be valid', async function() {
|
|
201
|
-
const app = mockApp({
|
|
202
|
-
...baseAppManifest,
|
|
203
|
-
drivers: [{
|
|
204
|
-
...baseDriverManifest,
|
|
205
|
-
platforms: ['none'],
|
|
206
|
-
}],
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
await assertValidates(app, {
|
|
210
|
-
debug: /platforms\[0\] should be equal to one of the allowed values/i,
|
|
211
|
-
publish: /platforms\[0\] should be equal to one of the allowed values/i,
|
|
212
|
-
verified: /platforms\[0\] should be equal to one of the allowed values/i,
|
|
213
|
-
});
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
/*
|
|
217
|
-
* Driver Connectivity
|
|
218
|
-
*/
|
|
219
|
-
|
|
220
|
-
it('`connectivity` needs to be defined', async function() {
|
|
221
|
-
const app = mockApp({
|
|
222
|
-
...baseAppManifest,
|
|
223
|
-
drivers: [{
|
|
224
|
-
...baseDriverManifest,
|
|
225
|
-
connectivity: undefined,
|
|
226
|
-
}],
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
await assertValidates(app, {
|
|
230
|
-
debug: true, // connectivity is optional for debug
|
|
231
|
-
publish: true, // connectivity is optional for publish
|
|
232
|
-
verified: /property `connectivity` is required/i,
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
it('`connectivity` needs to be valid', async function() {
|
|
237
|
-
const app = mockApp({
|
|
238
|
-
...baseAppManifest,
|
|
239
|
-
drivers: [{
|
|
240
|
-
...baseDriverManifest,
|
|
241
|
-
connectivity: ['none'],
|
|
242
|
-
}],
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
await assertValidates(app, {
|
|
246
|
-
debug: /connectivity\[0\] should be equal to one of the allowed values/i,
|
|
247
|
-
publish: /connectivity\[0\] should be equal to one of the allowed values/i,
|
|
248
|
-
verified: /connectivity\[0\] should be equal to one of the allowed values/i,
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
it('`class` needs to be checked for compatibility', async function() {
|
|
253
|
-
const app = mockApp({
|
|
254
|
-
...baseAppManifest,
|
|
255
|
-
drivers: [{
|
|
256
|
-
...baseDriverManifest,
|
|
257
|
-
class: 'shutterblinds', // Device class that requires compatibility >= 12
|
|
258
|
-
}],
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
await assertValidates(app, {
|
|
262
|
-
debug: /driver class: shutterblinds is not available for compatibility/i,
|
|
263
|
-
publish: /driver class: shutterblinds is not available for compatibility/i,
|
|
264
|
-
verified: /driver class: shutterblinds is not available for compatibility/i,
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
it('`class` without compatibility should validate', async function() {
|
|
269
|
-
const app = mockApp({
|
|
270
|
-
...baseAppManifest,
|
|
271
|
-
drivers: [{
|
|
272
|
-
...baseDriverManifest,
|
|
273
|
-
class: 'light', // Device class that requires no min compatibility
|
|
274
|
-
}],
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
await assertValidates(app, {
|
|
278
|
-
debug: true,
|
|
279
|
-
publish: true,
|
|
280
|
-
verified: true,
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
it('`capabilities` needs to be checked for compatibility', async function() {
|
|
285
|
-
const app = mockApp({
|
|
286
|
-
...baseAppManifest,
|
|
287
|
-
compatibility: '>=5.0.0 <=12.0.0',
|
|
288
|
-
drivers: [{
|
|
289
|
-
...baseDriverManifest,
|
|
290
|
-
capabilities: ['alarm_pm01'], // Capability that requires compatibility >= 12.1
|
|
291
|
-
}],
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
await assertValidates(app, {
|
|
295
|
-
debug: /capability: alarm_pm01 is not available for compatibility/i,
|
|
296
|
-
publish: /capability: alarm_pm01 is not available for compatibility/i,
|
|
297
|
-
verified: /capability: alarm_pm01 is not available for compatibility/i,
|
|
298
|
-
});
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
it('`capabilities` without compatibility should validate', async function() {
|
|
302
|
-
const app = mockApp({
|
|
303
|
-
...baseAppManifest,
|
|
304
|
-
drivers: [{
|
|
305
|
-
...baseDriverManifest,
|
|
306
|
-
capabilities: ['onoff'], // Capability that has no min compatibility
|
|
307
|
-
}],
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
await assertValidates(app, {
|
|
311
|
-
debug: true,
|
|
312
|
-
publish: true,
|
|
313
|
-
verified: true,
|
|
314
|
-
});
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
/*
|
|
318
|
-
* Zigbee Driver
|
|
319
|
-
*/
|
|
320
|
-
|
|
321
|
-
it('`zigbee.productId` needs to be defined', async function() {
|
|
322
|
-
const app = mockApp({
|
|
323
|
-
...baseAppManifest,
|
|
324
|
-
drivers: [{
|
|
325
|
-
...baseDriverManifest,
|
|
326
|
-
zigbee: {
|
|
327
|
-
manufacturerName: ['dummyManufacturer'],
|
|
328
|
-
endpoints: {},
|
|
329
|
-
},
|
|
330
|
-
}],
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
await assertValidates(app, {
|
|
334
|
-
debug: /zigbee should have required property 'productId'/i,
|
|
335
|
-
publish: /zigbee should have required property 'productId'/i,
|
|
336
|
-
verified: /zigbee should have required property 'productId'/i,
|
|
337
|
-
});
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
it('`zigbee.productId` needs to be valid', async function() {
|
|
341
|
-
const app = mockApp({
|
|
342
|
-
...baseAppManifest,
|
|
343
|
-
drivers: [{
|
|
344
|
-
...baseDriverManifest,
|
|
345
|
-
zigbee: {
|
|
346
|
-
productId: true,
|
|
347
|
-
manufacturerName: ['dummyManufacturer'],
|
|
348
|
-
endpoints: {},
|
|
349
|
-
},
|
|
350
|
-
}],
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
// Product ID can be a string
|
|
354
|
-
await assertValidates(app, {
|
|
355
|
-
debug: /zigbee\.productId should be string/i,
|
|
356
|
-
publish: /zigbee\.productId should be string/i,
|
|
357
|
-
verified: /zigbee\.productId should be string/i,
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
// or an array of strings
|
|
361
|
-
await assertValidates(app, {
|
|
362
|
-
debug: /zigbee\.productId should be array/i,
|
|
363
|
-
publish: /zigbee\.productId should be array/i,
|
|
364
|
-
verified: /zigbee\.productId should be array/i,
|
|
365
|
-
});
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
it('`zigbee.manufacturerName` needs to be defined', async function() {
|
|
369
|
-
const app = mockApp({
|
|
370
|
-
...baseAppManifest,
|
|
371
|
-
drivers: [{
|
|
372
|
-
...baseDriverManifest,
|
|
373
|
-
zigbee: {
|
|
374
|
-
productId: ['dummyProduct'],
|
|
375
|
-
endpoints: {},
|
|
376
|
-
},
|
|
377
|
-
}],
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
await assertValidates(app, {
|
|
381
|
-
debug: /zigbee should have required property 'manufacturerName'/i,
|
|
382
|
-
publish: /zigbee should have required property 'manufacturerName'/i,
|
|
383
|
-
verified: /zigbee should have required property 'manufacturerName'/i,
|
|
384
|
-
});
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
it('`zigbee.manufacturerName` needs to be valid', async function() {
|
|
388
|
-
const app = mockApp({
|
|
389
|
-
...baseAppManifest,
|
|
390
|
-
drivers: [{
|
|
391
|
-
...baseDriverManifest,
|
|
392
|
-
zigbee: {
|
|
393
|
-
productId: 'dummyProduct',
|
|
394
|
-
manufacturerName: true,
|
|
395
|
-
endpoints: {},
|
|
396
|
-
},
|
|
397
|
-
}],
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
// manufacturerName can be a string
|
|
401
|
-
await assertValidates(app, {
|
|
402
|
-
debug: /zigbee\.manufacturerName should be string/i,
|
|
403
|
-
publish: /zigbee\.manufacturerName should be string/i,
|
|
404
|
-
verified: /zigbee\.manufacturerName should be string/i,
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
// or an array of strings
|
|
408
|
-
await assertValidates(app, {
|
|
409
|
-
debug: /zigbee\.manufacturerName should be array/i,
|
|
410
|
-
publish: /zigbee\.manufacturerName should be array/i,
|
|
411
|
-
verified: /zigbee\.manufacturerName should be array/i,
|
|
412
|
-
});
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
it('`zigbee.endpoints` needs to be defined', async function() {
|
|
416
|
-
const app = mockApp({
|
|
417
|
-
...baseAppManifest,
|
|
418
|
-
drivers: [{
|
|
419
|
-
...baseDriverManifest,
|
|
420
|
-
zigbee: {
|
|
421
|
-
productId: ['dummyProduct'],
|
|
422
|
-
manufacturerName: 'dummyManufacturer',
|
|
423
|
-
},
|
|
424
|
-
}],
|
|
425
|
-
});
|
|
426
|
-
|
|
427
|
-
await assertValidates(app, {
|
|
428
|
-
debug: /zigbee should have required property 'endpoints'/i,
|
|
429
|
-
publish: /zigbee should have required property 'endpoints'/i,
|
|
430
|
-
verified: /zigbee should have required property 'endpoints'/i,
|
|
431
|
-
});
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
it('`zigbee.endpoints` needs to be valid', async function() {
|
|
435
|
-
const app = mockApp({
|
|
436
|
-
...baseAppManifest,
|
|
437
|
-
drivers: [{
|
|
438
|
-
...baseDriverManifest,
|
|
439
|
-
zigbee: {
|
|
440
|
-
productId: ['dummyProduct'],
|
|
441
|
-
manufacturerName: ['dummyManufacturer'],
|
|
442
|
-
endpoints: true,
|
|
443
|
-
},
|
|
444
|
-
}],
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
await assertValidates(app, {
|
|
448
|
-
debug: /zigbee\.endpoints should be object/i,
|
|
449
|
-
publish: /zigbee\.endpoints should be object/i,
|
|
450
|
-
verified: /zigbee\.endpoints should be object/i,
|
|
451
|
-
});
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
it('`zigbee.endpoints` key needs to be valid', async function() {
|
|
455
|
-
const app = mockApp({
|
|
456
|
-
...baseAppManifest,
|
|
457
|
-
drivers: [{
|
|
458
|
-
...baseDriverManifest,
|
|
459
|
-
zigbee: {
|
|
460
|
-
productId: ['dummyProduct'],
|
|
461
|
-
manufacturerName: ['dummyManufacturer'],
|
|
462
|
-
endpoints: {
|
|
463
|
-
bla: [],
|
|
464
|
-
},
|
|
465
|
-
},
|
|
466
|
-
}],
|
|
467
|
-
});
|
|
468
|
-
|
|
469
|
-
await assertValidates(app, {
|
|
470
|
-
debug: /zigbee\.endpoints should match pattern/i,
|
|
471
|
-
publish: /zigbee\.endpoints should match pattern/i,
|
|
472
|
-
verified: /zigbee\.endpoints should match pattern/i,
|
|
473
|
-
});
|
|
474
|
-
});
|
|
475
|
-
|
|
476
|
-
it('`zigbee.endpoints.x` needs to be an object', async function() {
|
|
477
|
-
const app = mockApp({
|
|
478
|
-
...baseAppManifest,
|
|
479
|
-
drivers: [{
|
|
480
|
-
...baseDriverManifest,
|
|
481
|
-
zigbee: {
|
|
482
|
-
productId: ['dummyProduct'],
|
|
483
|
-
manufacturerName: ['dummyManufacturer'],
|
|
484
|
-
endpoints: {
|
|
485
|
-
1: [],
|
|
486
|
-
},
|
|
487
|
-
},
|
|
488
|
-
}],
|
|
489
|
-
});
|
|
490
|
-
|
|
491
|
-
await assertValidates(app, {
|
|
492
|
-
debug: /zigbee\.endpoints\['1'] should be object/i,
|
|
493
|
-
publish: /zigbee\.endpoints\['1'] should be object/i,
|
|
494
|
-
verified: /zigbee\.endpoints\['1'] should be object/i,
|
|
495
|
-
});
|
|
496
|
-
});
|
|
497
|
-
|
|
498
|
-
it('`zigbee.endpoints.x.clusters` needs to be an array', async function() {
|
|
499
|
-
const app = mockApp({
|
|
500
|
-
...baseAppManifest,
|
|
501
|
-
drivers: [{
|
|
502
|
-
...baseDriverManifest,
|
|
503
|
-
zigbee: {
|
|
504
|
-
productId: ['dummyProduct'],
|
|
505
|
-
manufacturerName: ['dummyManufacturer'],
|
|
506
|
-
endpoints: {
|
|
507
|
-
1: {
|
|
508
|
-
clusters: {},
|
|
509
|
-
},
|
|
510
|
-
},
|
|
511
|
-
},
|
|
512
|
-
}],
|
|
513
|
-
});
|
|
514
|
-
|
|
515
|
-
await assertValidates(app, {
|
|
516
|
-
debug: /zigbee\.endpoints\['1'].clusters should be array/i,
|
|
517
|
-
publish: /zigbee\.endpoints\['1'].clusters should be array/i,
|
|
518
|
-
verified: /zigbee\.endpoints\['1'].clusters should be array/i,
|
|
519
|
-
});
|
|
520
|
-
});
|
|
521
|
-
|
|
522
|
-
it('`zigbee.endpoints.x.clusters` needs to be an array of only numbers', async function() {
|
|
523
|
-
const app = mockApp({
|
|
524
|
-
...baseAppManifest,
|
|
525
|
-
drivers: [{
|
|
526
|
-
...baseDriverManifest,
|
|
527
|
-
zigbee: {
|
|
528
|
-
productId: ['dummyProduct'],
|
|
529
|
-
manufacturerName: ['dummyManufacturer'],
|
|
530
|
-
endpoints: {
|
|
531
|
-
1: {
|
|
532
|
-
clusters: [true],
|
|
533
|
-
},
|
|
534
|
-
},
|
|
535
|
-
},
|
|
536
|
-
}],
|
|
537
|
-
});
|
|
538
|
-
|
|
539
|
-
await assertValidates(app, {
|
|
540
|
-
debug: /zigbee\.endpoints\['1'].clusters\[0] should be number/i,
|
|
541
|
-
publish: /zigbee\.endpoints\['1'].clusters\[0] should be number/i,
|
|
542
|
-
verified: /zigbee\.endpoints\['1'].clusters\[0] should be number/i,
|
|
543
|
-
});
|
|
544
|
-
});
|
|
545
|
-
|
|
546
|
-
it('`zigbee.endpoints.x.bindings` needs to be an array', async function() {
|
|
547
|
-
const app = mockApp({
|
|
548
|
-
...baseAppManifest,
|
|
549
|
-
drivers: [{
|
|
550
|
-
...baseDriverManifest,
|
|
551
|
-
zigbee: {
|
|
552
|
-
productId: ['dummyProduct'],
|
|
553
|
-
manufacturerName: ['dummyManufacturer'],
|
|
554
|
-
endpoints: {
|
|
555
|
-
1: {
|
|
556
|
-
bindings: {},
|
|
557
|
-
},
|
|
558
|
-
},
|
|
559
|
-
},
|
|
560
|
-
}],
|
|
561
|
-
});
|
|
562
|
-
|
|
563
|
-
await assertValidates(app, {
|
|
564
|
-
debug: /zigbee\.endpoints\['1'].bindings should be array/i,
|
|
565
|
-
publish: /zigbee\.endpoints\['1'].bindings should be array/i,
|
|
566
|
-
verified: /zigbee\.endpoints\['1'].bindings should be array/i,
|
|
567
|
-
});
|
|
568
|
-
});
|
|
569
|
-
|
|
570
|
-
it('`zigbee.endpoints.x.bindings` needs to be an array of only numbers', async function() {
|
|
571
|
-
const app = mockApp({
|
|
572
|
-
...baseAppManifest,
|
|
573
|
-
drivers: [{
|
|
574
|
-
...baseDriverManifest,
|
|
575
|
-
zigbee: {
|
|
576
|
-
productId: ['dummyProduct'],
|
|
577
|
-
manufacturerName: ['dummyManufacturer'],
|
|
578
|
-
endpoints: {
|
|
579
|
-
1: {
|
|
580
|
-
bindings: [true],
|
|
581
|
-
},
|
|
582
|
-
},
|
|
583
|
-
},
|
|
584
|
-
}],
|
|
585
|
-
});
|
|
586
|
-
|
|
587
|
-
await assertValidates(app, {
|
|
588
|
-
debug: /zigbee\.endpoints\['1'].bindings\[0] should be number/i,
|
|
589
|
-
publish: /zigbee\.endpoints\['1'].bindings\[0] should be number/i,
|
|
590
|
-
verified: /zigbee\.endpoints\['1'].bindings\[0] should be number/i,
|
|
591
|
-
});
|
|
592
|
-
});
|
|
593
|
-
|
|
594
|
-
/*
|
|
595
|
-
* target_power_mode values validation
|
|
596
|
-
*/
|
|
597
|
-
|
|
598
|
-
it('`target_power_mode` with custom values should pass (values are silently replaced)', async function() {
|
|
599
|
-
const app = mockApp({
|
|
600
|
-
...baseAppManifest,
|
|
601
|
-
compatibility: '>=12.13.0',
|
|
602
|
-
drivers: [{
|
|
603
|
-
...baseDriverManifest,
|
|
604
|
-
capabilities: ['target_power', 'target_power_mode'],
|
|
605
|
-
capabilitiesOptions: {
|
|
606
|
-
target_power_mode: {
|
|
607
|
-
values: [
|
|
608
|
-
{ id: 'custom', title: { en: 'Custom' } },
|
|
609
|
-
],
|
|
610
|
-
},
|
|
611
|
-
},
|
|
612
|
-
}],
|
|
613
|
-
});
|
|
614
|
-
|
|
615
|
-
await assertValidates(app, {
|
|
616
|
-
debug: true,
|
|
617
|
-
publish: true,
|
|
618
|
-
verified: true,
|
|
619
|
-
});
|
|
620
|
-
});
|
|
621
|
-
|
|
622
|
-
it('`target_power_mode` without values array should pass', async function() {
|
|
623
|
-
const app = mockApp({
|
|
624
|
-
...baseAppManifest,
|
|
625
|
-
compatibility: '>=12.13.0',
|
|
626
|
-
drivers: [{
|
|
627
|
-
...baseDriverManifest,
|
|
628
|
-
capabilities: ['target_power', 'target_power_mode'],
|
|
629
|
-
capabilitiesOptions: {
|
|
630
|
-
target_power_mode: {
|
|
631
|
-
title: { en: 'Power Mode' },
|
|
632
|
-
},
|
|
633
|
-
},
|
|
634
|
-
}],
|
|
635
|
-
});
|
|
636
|
-
|
|
637
|
-
await assertValidates(app, {
|
|
638
|
-
debug: true,
|
|
639
|
-
publish: true,
|
|
640
|
-
verified: true,
|
|
641
|
-
});
|
|
642
|
-
});
|
|
643
|
-
|
|
644
|
-
/*
|
|
645
|
-
* target_power exclude validation
|
|
646
|
-
*/
|
|
647
|
-
|
|
648
|
-
it('`target_power` exclude must include 0 (excludeMin > 0 should fail)', async function() {
|
|
649
|
-
const app = mockApp({
|
|
650
|
-
...baseAppManifest,
|
|
651
|
-
compatibility: '>=12.13.0',
|
|
652
|
-
drivers: [{
|
|
653
|
-
...baseDriverManifest,
|
|
654
|
-
capabilities: ['target_power'],
|
|
655
|
-
capabilitiesOptions: {
|
|
656
|
-
target_power: {
|
|
657
|
-
excludeMin: 100, excludeMax: 1380, // Invalid: excludeMin > 0
|
|
658
|
-
},
|
|
659
|
-
},
|
|
660
|
-
}],
|
|
661
|
-
});
|
|
662
|
-
|
|
663
|
-
await assertValidates(app, {
|
|
664
|
-
debug: /capabilitiesOptions\.target_power\.excludeMin\/excludeMax must include 0/i,
|
|
665
|
-
publish: /capabilitiesOptions\.target_power\.excludeMin\/excludeMax must include 0/i,
|
|
666
|
-
verified: /capabilitiesOptions\.target_power\.excludeMin\/excludeMax must include 0/i,
|
|
667
|
-
});
|
|
668
|
-
});
|
|
669
|
-
|
|
670
|
-
it('`target_power` exclude must include 0 (excludeMax < 0 should fail)', async function() {
|
|
671
|
-
const app = mockApp({
|
|
672
|
-
...baseAppManifest,
|
|
673
|
-
compatibility: '>=12.13.0',
|
|
674
|
-
drivers: [{
|
|
675
|
-
...baseDriverManifest,
|
|
676
|
-
capabilities: ['target_power'],
|
|
677
|
-
capabilitiesOptions: {
|
|
678
|
-
target_power: {
|
|
679
|
-
excludeMin: -1380, excludeMax: -100, // Invalid: excludeMax < 0
|
|
680
|
-
},
|
|
681
|
-
},
|
|
682
|
-
}],
|
|
683
|
-
});
|
|
684
|
-
|
|
685
|
-
await assertValidates(app, {
|
|
686
|
-
debug: /capabilitiesOptions\.target_power\.excludeMin\/excludeMax must include 0/i,
|
|
687
|
-
publish: /capabilitiesOptions\.target_power\.excludeMin\/excludeMax must include 0/i,
|
|
688
|
-
verified: /capabilitiesOptions\.target_power\.excludeMin\/excludeMax must include 0/i,
|
|
689
|
-
});
|
|
690
|
-
});
|
|
691
|
-
|
|
692
|
-
it('`target_power` valid exclude that includes 0 should pass', async function() {
|
|
693
|
-
const app = mockApp({
|
|
694
|
-
...baseAppManifest,
|
|
695
|
-
compatibility: '>=12.13.0',
|
|
696
|
-
drivers: [{
|
|
697
|
-
...baseDriverManifest,
|
|
698
|
-
capabilities: ['target_power'],
|
|
699
|
-
capabilitiesOptions: {
|
|
700
|
-
target_power: {
|
|
701
|
-
excludeMin: 0, // Valid: includes 0
|
|
702
|
-
excludeMax: 1380,
|
|
703
|
-
},
|
|
704
|
-
},
|
|
705
|
-
}],
|
|
706
|
-
});
|
|
707
|
-
|
|
708
|
-
await assertValidates(app, {
|
|
709
|
-
debug: true,
|
|
710
|
-
publish: true,
|
|
711
|
-
verified: true,
|
|
712
|
-
});
|
|
713
|
-
});
|
|
714
|
-
|
|
715
|
-
it('`target_power` valid bidirectional exclude should pass', async function() {
|
|
716
|
-
const app = mockApp({
|
|
717
|
-
...baseAppManifest,
|
|
718
|
-
compatibility: '>=12.13.0',
|
|
719
|
-
drivers: [{
|
|
720
|
-
...baseDriverManifest,
|
|
721
|
-
capabilities: ['target_power'],
|
|
722
|
-
capabilitiesOptions: {
|
|
723
|
-
target_power: {
|
|
724
|
-
min: -11000,
|
|
725
|
-
max: 22000,
|
|
726
|
-
excludeMin: -1380,
|
|
727
|
-
excludeMax: 1380, // Valid: symmetric around 0
|
|
728
|
-
},
|
|
729
|
-
},
|
|
730
|
-
}],
|
|
731
|
-
});
|
|
732
|
-
|
|
733
|
-
await assertValidates(app, {
|
|
734
|
-
debug: true,
|
|
735
|
-
publish: true,
|
|
736
|
-
verified: true,
|
|
737
|
-
});
|
|
738
|
-
});
|
|
739
|
-
|
|
740
|
-
it('`target_power` without excludeMin/excludeMax should pass', async function() {
|
|
741
|
-
const app = mockApp({
|
|
742
|
-
...baseAppManifest,
|
|
743
|
-
compatibility: '>=12.13.0',
|
|
744
|
-
drivers: [{
|
|
745
|
-
...baseDriverManifest,
|
|
746
|
-
capabilities: ['target_power'],
|
|
747
|
-
capabilitiesOptions: {
|
|
748
|
-
target_power: {
|
|
749
|
-
min: -5000,
|
|
750
|
-
max: 5000,
|
|
751
|
-
},
|
|
752
|
-
},
|
|
753
|
-
}],
|
|
754
|
-
});
|
|
755
|
-
|
|
756
|
-
await assertValidates(app, {
|
|
757
|
-
debug: true,
|
|
758
|
-
publish: true,
|
|
759
|
-
verified: true,
|
|
760
|
-
});
|
|
761
|
-
});
|
|
762
|
-
|
|
763
|
-
/*
|
|
764
|
-
* target_power min/max validation (all devices)
|
|
765
|
-
*/
|
|
766
|
-
|
|
767
|
-
it('`target_power` min/max must include 0 (min > 0 should fail)', async function() {
|
|
768
|
-
const app = mockApp({
|
|
769
|
-
...baseAppManifest,
|
|
770
|
-
compatibility: '>=12.13.0',
|
|
771
|
-
drivers: [{
|
|
772
|
-
...baseDriverManifest,
|
|
773
|
-
capabilities: ['target_power'],
|
|
774
|
-
capabilitiesOptions: {
|
|
775
|
-
target_power: {
|
|
776
|
-
min: 100, // Invalid: min > 0
|
|
777
|
-
max: 5000,
|
|
778
|
-
},
|
|
779
|
-
},
|
|
780
|
-
}],
|
|
781
|
-
});
|
|
782
|
-
|
|
783
|
-
await assertValidates(app, {
|
|
784
|
-
debug: /capabilitiesOptions\.target_power\.min\/max must include 0/i,
|
|
785
|
-
publish: /capabilitiesOptions\.target_power\.min\/max must include 0/i,
|
|
786
|
-
verified: /capabilitiesOptions\.target_power\.min\/max must include 0/i,
|
|
787
|
-
});
|
|
788
|
-
});
|
|
789
|
-
|
|
790
|
-
it('`target_power` min/max must include 0 (max < 0 should fail)', async function() {
|
|
791
|
-
const app = mockApp({
|
|
792
|
-
...baseAppManifest,
|
|
793
|
-
compatibility: '>=12.13.0',
|
|
794
|
-
drivers: [{
|
|
795
|
-
...baseDriverManifest,
|
|
796
|
-
capabilities: ['target_power'],
|
|
797
|
-
capabilitiesOptions: {
|
|
798
|
-
target_power: {
|
|
799
|
-
min: -5000,
|
|
800
|
-
max: -100, // Invalid: max < 0
|
|
801
|
-
},
|
|
802
|
-
},
|
|
803
|
-
}],
|
|
804
|
-
});
|
|
805
|
-
|
|
806
|
-
await assertValidates(app, {
|
|
807
|
-
debug: /capabilitiesOptions\.target_power\.min\/max must include 0/i,
|
|
808
|
-
publish: /capabilitiesOptions\.target_power\.min\/max must include 0/i,
|
|
809
|
-
verified: /capabilitiesOptions\.target_power\.min\/max must include 0/i,
|
|
810
|
-
});
|
|
811
|
-
});
|
|
812
|
-
|
|
813
|
-
it('`target_power` valid min/max that includes 0 should pass', async function() {
|
|
814
|
-
const app = mockApp({
|
|
815
|
-
...baseAppManifest,
|
|
816
|
-
compatibility: '>=12.13.0',
|
|
817
|
-
drivers: [{
|
|
818
|
-
...baseDriverManifest,
|
|
819
|
-
capabilities: ['target_power'],
|
|
820
|
-
capabilitiesOptions: {
|
|
821
|
-
target_power: {
|
|
822
|
-
min: -5000,
|
|
823
|
-
max: 5000, // Valid: includes 0
|
|
824
|
-
},
|
|
825
|
-
},
|
|
826
|
-
}],
|
|
827
|
-
});
|
|
828
|
-
|
|
829
|
-
await assertValidates(app, {
|
|
830
|
-
debug: true,
|
|
831
|
-
publish: true,
|
|
832
|
-
verified: true,
|
|
833
|
-
});
|
|
834
|
-
});
|
|
835
|
-
});
|