iobroker.zigbee 1.8.0 → 1.8.3
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/.eslintignore +2 -0
- package/.eslintrc.json +37 -0
- package/.github/FUNDING.yml +3 -0
- package/.github/auto-merge.yml +17 -0
- package/.github/dependabot.yml +24 -0
- package/.github/stale.yml +13 -0
- package/.github/workflows/codeql.yml +41 -0
- package/.github/workflows/dependabot-automerge.yml +22 -0
- package/.github/workflows/test-and-release.yml +149 -0
- package/.releaseconfig.json +3 -0
- package/.travis/wiki.sh +28 -0
- package/.travis.yml +41 -0
- package/README.md +32 -9
- package/admin/admin.js +466 -482
- package/admin/i18n/de/translations.json +2 -2
- package/admin/index_m.html +1 -1
- package/admin/tab_m.html +3 -44
- package/admin/words.js +2 -2
- package/gulpfile.js +464 -0
- package/io-package.json +19 -26
- package/lib/backup.js +2 -2
- package/lib/binding.js +24 -23
- package/lib/colors.js +14 -16
- package/lib/commands.js +82 -89
- package/lib/developer.js +7 -6
- package/lib/devices.js +153 -144
- package/lib/exclude.js +36 -30
- package/lib/exposes.js +111 -106
- package/lib/groups.js +54 -53
- package/lib/json.js +4 -3
- package/lib/networkmap.js +2 -2
- package/lib/ota.js +15 -23
- package/lib/rgb.js +44 -47
- package/lib/seriallist.js +16 -21
- package/lib/states.js +496 -482
- package/lib/statescontroller.js +164 -170
- package/lib/utils.js +21 -22
- package/lib/zbBaseExtension.js +4 -4
- package/lib/zbDelayedAction.js +13 -5
- package/lib/zbDeviceAvailability.js +44 -47
- package/lib/zbDeviceConfigure.js +19 -7
- package/lib/zbDeviceEvent.js +4 -3
- package/lib/zigbeecontroller.js +96 -88
- package/main.js +133 -149
- package/package.json +15 -29
- package/test/integration.js +5 -0
- package/test/mocha.custom.opts +2 -0
- package/test/mocha.setup.js +14 -0
- package/test/package.js +5 -0
- package/test/unit.js +5 -0
- package/docs/de/img/CC2531.png +0 -0
- package/docs/de/img/CC2538_CC2592_PA.PNG +0 -0
- package/docs/de/img/CC2591.png +0 -0
- package/docs/de/img/boards.jpg +0 -0
- package/docs/de/img/cc26x2r.PNG +0 -0
- package/docs/de/img/results.jpg +0 -0
- package/docs/de/img/sku_429478_2.png +0 -0
- package/docs/de/img/sku_429601_2.png +0 -0
- package/docs/de/readme.md +0 -27
- package/docs/en/img/CC2531.png +0 -0
- package/docs/en/img/CC2591.png +0 -0
- package/docs/en/img/deconz.png +0 -0
- package/docs/en/img/sku_429478_2.png +0 -0
- package/docs/en/img/sku_429601_2.png +0 -0
- package/docs/en/readme.md +0 -30
- package/docs/flashing_via_arduino_(en).md +0 -110
- package/docs/ru/img/CC2531.png +0 -0
- package/docs/ru/img/CC2591.png +0 -0
- package/docs/ru/img/sku_429478_2.png +0 -0
- package/docs/ru/img/sku_429601_2.png +0 -0
- package/docs/ru/readme.md +0 -28
- package/docs/tutorial/CC2530_20190425.zip +0 -0
- package/docs/tutorial/CC2530_CC2591_20190515.zip +0 -0
- package/docs/tutorial/CC2530_CC2592_20190515.zip +0 -0
- package/docs/tutorial/CC2531_20190425.zip +0 -0
- package/docs/tutorial/adm5_1.PNG +0 -0
- package/docs/tutorial/adm5_2.PNG +0 -0
- package/docs/tutorial/cat.PNG +0 -0
- package/docs/tutorial/groups-1.png +0 -0
- package/docs/tutorial/groups-2.png +0 -0
- package/docs/tutorial/inst.PNG +0 -0
- package/docs/tutorial/reflash-finish.PNG +0 -0
- package/docs/tutorial/reflash-step0.png +0 -0
- package/docs/tutorial/reflash-step1.PNG +0 -0
- package/docs/tutorial/reflash-step2.PNG +0 -0
- package/docs/tutorial/settings.png +0 -0
- package/docs/tutorial/tab-dev-1.png +0 -0
- package/docs/tutorial/zigbee.png +0 -0
- package/docs/tutorial/zigbee15.png +0 -0
package/lib/devices.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const states = require('
|
|
4
|
-
const utils = require('
|
|
5
|
-
const rgb = require('
|
|
6
|
-
const applyExposes = require('
|
|
3
|
+
const states = require(__dirname + '/states.js').states;
|
|
4
|
+
const utils = require(__dirname + '/utils.js');
|
|
5
|
+
const rgb = require(__dirname + '/rgb.js');
|
|
6
|
+
const applyExposes = require(__dirname + '/exposes.js').applyExposes;
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
// return list of changing states when incoming state is changed
|
|
@@ -23,7 +23,7 @@ const comb = {
|
|
|
23
23
|
// index: -1, // before main change
|
|
24
24
|
// timeout: 0,
|
|
25
25
|
index: 1, // after main change
|
|
26
|
-
timeout,
|
|
26
|
+
timeout: timeout,
|
|
27
27
|
}];
|
|
28
28
|
}
|
|
29
29
|
} else if (disableQueue || options.state) {
|
|
@@ -32,7 +32,7 @@ const comb = {
|
|
|
32
32
|
stateDesc: states.state,
|
|
33
33
|
value: false,
|
|
34
34
|
index: 1, // after main change
|
|
35
|
-
timeout,
|
|
35
|
+
timeout: timeout,
|
|
36
36
|
}];
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -42,22 +42,20 @@ const comb = {
|
|
|
42
42
|
if (state.id === states.effect_json.id) {
|
|
43
43
|
const effectjson = {};
|
|
44
44
|
try {
|
|
45
|
-
if (options.hasOwnProperty('effect_speed'))
|
|
45
|
+
if (options.hasOwnProperty('effect_speed'))
|
|
46
46
|
effectjson.speed = options.effect_speed;
|
|
47
|
-
|
|
48
|
-
if (options.hasOwnProperty('effect_type')) {
|
|
47
|
+
if (options.hasOwnProperty('effect_type'))
|
|
49
48
|
effectjson.effect = options.effect_type;
|
|
50
|
-
|
|
51
|
-
if (options.hasOwnProperty('effect_colors'))
|
|
49
|
+
|
|
50
|
+
if (options.hasOwnProperty('effect_colors'))
|
|
52
51
|
effectjson.colors = rgb.colorsArrayFromString(options.effect_colors);
|
|
53
|
-
}
|
|
54
52
|
// effectjson = JSON.parse(value);
|
|
55
53
|
}
|
|
56
54
|
catch {
|
|
57
55
|
const effectjson = {
|
|
58
|
-
colors:
|
|
59
|
-
speed:
|
|
60
|
-
effect:
|
|
56
|
+
colors:[{r: 255,g: 0,b: 0},{r: 0,g: 255,b: 0},{r: 0,g: 0,b: 255}],
|
|
57
|
+
speed:10,
|
|
58
|
+
effect:'glow',
|
|
61
59
|
};
|
|
62
60
|
if (options.hasOwnProperty('effect_speed'))
|
|
63
61
|
effectjson.speed = options.effect_speed;
|
|
@@ -133,30 +131,29 @@ const freepad_states = [states.battery];
|
|
|
133
131
|
|
|
134
132
|
function getKey(object, value) {
|
|
135
133
|
for (const key in object) {
|
|
136
|
-
if (object[key]
|
|
137
|
-
return key;
|
|
138
|
-
}
|
|
134
|
+
if (object[key]==value) return key;
|
|
139
135
|
}
|
|
140
136
|
}
|
|
141
137
|
|
|
142
138
|
const unitLookup = {
|
|
143
139
|
'temperature': 'C',
|
|
144
|
-
'humidity':
|
|
145
|
-
'altitude':
|
|
146
|
-
'pressure':
|
|
147
|
-
'quality':
|
|
148
|
-
'particle_size':
|
|
149
|
-
'voltage':
|
|
150
|
-
'current':
|
|
151
|
-
'energy':
|
|
152
|
-
'power':
|
|
153
|
-
'frequency':
|
|
154
|
-
'power_factor':
|
|
155
|
-
'illuminance_lux':
|
|
140
|
+
'humidity':'%',
|
|
141
|
+
'altitude':'m',
|
|
142
|
+
'pressure':'Pa',
|
|
143
|
+
'quality':'ppm',
|
|
144
|
+
'particle_size':'psize',
|
|
145
|
+
'voltage':'V',
|
|
146
|
+
'current':'A',
|
|
147
|
+
'energy':'Wh',
|
|
148
|
+
'power':'W',
|
|
149
|
+
'frequency':'Hz',
|
|
150
|
+
'power_factor':'pf',
|
|
151
|
+
'illuminance_lux':'lx',
|
|
152
|
+
|
|
156
153
|
};
|
|
157
154
|
|
|
158
155
|
const generator = {
|
|
159
|
-
gledopto: entity => {
|
|
156
|
+
gledopto: (entity) => {
|
|
160
157
|
if (entity.mapped.model === 'GL-C-008-2ID') {
|
|
161
158
|
return gl_lightStatesWithColor.concat(gl8_white_channel);
|
|
162
159
|
} else if (entity.mapped.model === 'GL-C-007-2ID') {
|
|
@@ -165,75 +162,86 @@ const generator = {
|
|
|
165
162
|
return lightStatesWithColor;
|
|
166
163
|
}
|
|
167
164
|
},
|
|
168
|
-
freepad: entity => {
|
|
165
|
+
freepad: (entity) => {
|
|
169
166
|
const freepad_st = [];
|
|
170
167
|
const ecount = entity.device.endpoints.length;
|
|
171
168
|
for (let i = 1; i <= ecount; i++) {
|
|
172
|
-
freepad_st.push(
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
169
|
+
freepad_st.push(
|
|
170
|
+
{
|
|
171
|
+
id: `btn${i}_single`,
|
|
172
|
+
prop: 'action',
|
|
173
|
+
name: `Button ${i} click event`,
|
|
174
|
+
icon: undefined,
|
|
175
|
+
role: 'button',
|
|
176
|
+
write: false,
|
|
177
|
+
read: true,
|
|
178
|
+
type: 'boolean',
|
|
179
|
+
isEvent: true,
|
|
180
|
+
getter: payload => (payload.action === `button_${i}_single`) ? true : undefined,
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
freepad_st.push(
|
|
184
|
+
{
|
|
185
|
+
id: `btn${i}_double`,
|
|
186
|
+
prop: 'action',
|
|
187
|
+
name: `Button ${i} double click event`,
|
|
188
|
+
icon: undefined,
|
|
189
|
+
role: 'button',
|
|
190
|
+
write: false,
|
|
191
|
+
read: true,
|
|
192
|
+
type: 'boolean',
|
|
193
|
+
isEvent: true,
|
|
194
|
+
getter: payload => (payload.action === `button_${i}_double`) ? true : undefined,
|
|
195
|
+
}
|
|
196
|
+
);
|
|
197
|
+
freepad_st.push(
|
|
198
|
+
{
|
|
199
|
+
id: `btn${i}_hold`,
|
|
200
|
+
prop: 'action',
|
|
201
|
+
name: `Button ${i} hold`,
|
|
202
|
+
icon: undefined,
|
|
203
|
+
role: 'button',
|
|
204
|
+
write: false,
|
|
205
|
+
read: true,
|
|
206
|
+
type: 'boolean',
|
|
207
|
+
getter: payload => (payload.action === `button_${i}_hold`) ? true : (payload.action === `button_${i}_release`) ? false : undefined,
|
|
208
|
+
}
|
|
209
|
+
);
|
|
210
|
+
freepad_st.push(
|
|
211
|
+
{
|
|
212
|
+
id: `btn${i}_triple`,
|
|
213
|
+
prop: 'action',
|
|
214
|
+
name: `Button ${i} triple click event`,
|
|
215
|
+
icon: undefined,
|
|
216
|
+
role: 'button',
|
|
217
|
+
write: false,
|
|
218
|
+
read: true,
|
|
219
|
+
type: 'boolean',
|
|
220
|
+
isEvent: true,
|
|
221
|
+
getter: payload => (payload.action === `button_${i}_triple`) ? true : undefined,
|
|
222
|
+
lazy: true,
|
|
223
|
+
}
|
|
224
|
+
);
|
|
225
|
+
freepad_st.push(
|
|
226
|
+
{
|
|
227
|
+
id: `btn${i}_quadruple`,
|
|
228
|
+
prop: 'action',
|
|
229
|
+
name: `Button ${i} quadruple click event`,
|
|
230
|
+
icon: undefined,
|
|
231
|
+
role: 'button',
|
|
232
|
+
write: false,
|
|
233
|
+
read: true,
|
|
234
|
+
type: 'boolean',
|
|
235
|
+
isEvent: true,
|
|
236
|
+
getter: payload => (payload.action === `button_${i}_quadruple`) ? true : undefined,
|
|
237
|
+
lazy: true,
|
|
238
|
+
}
|
|
239
|
+
);
|
|
240
|
+
|
|
233
241
|
}
|
|
234
242
|
return freepad_states.concat(freepad_st);
|
|
235
243
|
},
|
|
236
|
-
ptvo_switch_channels: entity =>{
|
|
244
|
+
ptvo_switch_channels: (entity) =>{
|
|
237
245
|
const devstates = [states.ptvo_trigger,states.ptvo_interval];
|
|
238
246
|
for (const endpoint of entity.device.endpoints) {
|
|
239
247
|
const epID = endpoint.ID;
|
|
@@ -261,9 +269,7 @@ const generator = {
|
|
|
261
269
|
|
|
262
270
|
if (payload.hasOwnProperty(`device_${epName}`)) {
|
|
263
271
|
id = (typeof(payload[`device_${epName}`]) == 'string' ? payload[`device_${epName}`].replace(/[-. ]/g, ''):'unset');
|
|
264
|
-
} else if (payload.hasOwnProperty(`voltage_${epName}`))
|
|
265
|
-
id = 'voltage';
|
|
266
|
-
}
|
|
272
|
+
} else if (payload.hasOwnProperty(`voltage_${epName}`)) id = 'voltage';
|
|
267
273
|
let unit = undefined;
|
|
268
274
|
let measurement = undefined;
|
|
269
275
|
for (const item in payload) {
|
|
@@ -277,12 +283,12 @@ const generator = {
|
|
|
277
283
|
}
|
|
278
284
|
}
|
|
279
285
|
}
|
|
280
|
-
if (measurement && id
|
|
281
|
-
rv.stateid =
|
|
286
|
+
if (measurement && id != 'voltage')
|
|
287
|
+
rv.stateid = id + '_'+measurement;
|
|
282
288
|
else
|
|
283
289
|
rv.stateid = id;
|
|
284
290
|
rv.value = payload[epName];
|
|
285
|
-
rv.name = measurement?
|
|
291
|
+
rv.name = (measurement? measurement + ' 0x'+ id: '0x'+id);
|
|
286
292
|
rv.unit = unit;
|
|
287
293
|
rv.role = measurement;
|
|
288
294
|
|
|
@@ -300,8 +306,8 @@ const generator = {
|
|
|
300
306
|
write: true,
|
|
301
307
|
read: true,
|
|
302
308
|
type: 'boolean',
|
|
303
|
-
getter: payload => payload[`state_${epName}`] === 'ON',
|
|
304
|
-
setter: value => value ? 'ON' : 'OFF',
|
|
309
|
+
getter: payload => (payload[`state_${epName}`] === 'ON'),
|
|
310
|
+
setter: (value) => (value) ? 'ON' : 'OFF',
|
|
305
311
|
epname: epName,
|
|
306
312
|
setattr: 'state',
|
|
307
313
|
});
|
|
@@ -317,7 +323,7 @@ const generator = {
|
|
|
317
323
|
read: true,
|
|
318
324
|
type: 'boolean',
|
|
319
325
|
isEvent: true,
|
|
320
|
-
getter: payload => payload.action === `single_${epName}` ? true : undefined,
|
|
326
|
+
getter: payload => (payload.action === `single_${epName}`) ? true : undefined,
|
|
321
327
|
});
|
|
322
328
|
devstates.push({
|
|
323
329
|
id: `channel_${epID}.double`,
|
|
@@ -329,7 +335,7 @@ const generator = {
|
|
|
329
335
|
read: true,
|
|
330
336
|
type: 'boolean',
|
|
331
337
|
isEvent: true,
|
|
332
|
-
getter: payload => payload.action === `double_${epName}` ? true : undefined,
|
|
338
|
+
getter: payload => (payload.action === `double_${epName}`) ? true : undefined,
|
|
333
339
|
});
|
|
334
340
|
devstates.push({
|
|
335
341
|
id: `channel_${epID}.tripple`,
|
|
@@ -341,7 +347,7 @@ const generator = {
|
|
|
341
347
|
read: true,
|
|
342
348
|
type: 'boolean',
|
|
343
349
|
isEvent: true,
|
|
344
|
-
getter: payload => payload.action === `tripple_${epName}` ? true : undefined,
|
|
350
|
+
getter: payload => (payload.action === `tripple_${epName}`) ? true : undefined,
|
|
345
351
|
});
|
|
346
352
|
}
|
|
347
353
|
if (endpoint.supportsOutputCluster('genLevelCtrl')) {
|
|
@@ -356,8 +362,12 @@ const generator = {
|
|
|
356
362
|
unit: '',
|
|
357
363
|
min: 0,
|
|
358
364
|
max: 100,
|
|
359
|
-
getter: payload =>
|
|
360
|
-
|
|
365
|
+
getter: payload => {
|
|
366
|
+
return utils.bulbLevelToAdapterLevel(payload[`brightness_${epName}`]);
|
|
367
|
+
},
|
|
368
|
+
setter: (value) => {
|
|
369
|
+
return utils.adapterLevelToBulbLevel(value);
|
|
370
|
+
},
|
|
361
371
|
epname: epName,
|
|
362
372
|
setattr: 'brightness',
|
|
363
373
|
});
|
|
@@ -376,7 +386,9 @@ const generator = {
|
|
|
376
386
|
getter: payload => { //l3=0 brightness_l3=0
|
|
377
387
|
return payload[`${epName}`]; //return payload[`brightness_${epName}`];
|
|
378
388
|
},
|
|
379
|
-
setter: value =>
|
|
389
|
+
setter: (value) => {
|
|
390
|
+
return value;
|
|
391
|
+
},
|
|
380
392
|
epname: epName
|
|
381
393
|
});
|
|
382
394
|
}
|
|
@@ -426,15 +438,9 @@ const generator = {
|
|
|
426
438
|
read: true,
|
|
427
439
|
type: 'boolean',
|
|
428
440
|
getter: payload => {
|
|
429
|
-
if ((payload.action_group % ecount) != (epidx % ecount))
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
if (payload.action === 'brightness_move_up') {
|
|
433
|
-
return true;
|
|
434
|
-
}
|
|
435
|
-
if (payload.action === 'brightness_stop') {
|
|
436
|
-
return false;
|
|
437
|
-
}
|
|
441
|
+
if ((payload.action_group % ecount) != (epidx % ecount)) return undefined;
|
|
442
|
+
if (payload.action == 'brightness_move_up') return true;
|
|
443
|
+
if (payload.action == 'brightness_stop') return false;
|
|
438
444
|
return undefined;
|
|
439
445
|
},
|
|
440
446
|
});
|
|
@@ -448,15 +454,9 @@ const generator = {
|
|
|
448
454
|
read: true,
|
|
449
455
|
type: 'boolean',
|
|
450
456
|
getter: payload => {
|
|
451
|
-
if ((payload.action_group % ecount) != (epidx % ecount))
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
if (payload.action === 'brightness_move_down') {
|
|
455
|
-
return true;
|
|
456
|
-
}
|
|
457
|
-
if (payload.action === 'brightness_stop') {
|
|
458
|
-
return false;
|
|
459
|
-
}
|
|
457
|
+
if ((payload.action_group % ecount) != (epidx % ecount)) return undefined;
|
|
458
|
+
if (payload.action == 'brightness_move_down') return true;
|
|
459
|
+
if (payload.action == 'brightness_stop') return false;
|
|
460
460
|
return undefined;
|
|
461
461
|
},
|
|
462
462
|
});
|
|
@@ -502,8 +502,8 @@ const generator = {
|
|
|
502
502
|
write: true,
|
|
503
503
|
read: true,
|
|
504
504
|
type: 'boolean',
|
|
505
|
-
getter: payload => payload[`state_${epName}`] === 'ON',
|
|
506
|
-
setter: value => value ? 'ON' : 'OFF',
|
|
505
|
+
getter: payload => (payload[`state_${epName}`] === 'ON'),
|
|
506
|
+
setter: (value) => (value) ? 'ON' : 'OFF',
|
|
507
507
|
epname: epName,
|
|
508
508
|
setattr: 'state',
|
|
509
509
|
});
|
|
@@ -519,7 +519,7 @@ const generator = {
|
|
|
519
519
|
read: true,
|
|
520
520
|
type: 'boolean',
|
|
521
521
|
isEvent: true,
|
|
522
|
-
getter: payload => payload.action === `single_${epName}` ? true : undefined,
|
|
522
|
+
getter: payload => (payload.action === `single_${epName}`) ? true : undefined,
|
|
523
523
|
});
|
|
524
524
|
devstates.push({
|
|
525
525
|
id: `btn_${epID}_double`,
|
|
@@ -531,7 +531,7 @@ const generator = {
|
|
|
531
531
|
read: true,
|
|
532
532
|
type: 'boolean',
|
|
533
533
|
isEvent: true,
|
|
534
|
-
getter: payload => payload.action === `double_${epName}` ? true : undefined,
|
|
534
|
+
getter: payload => (payload.action === `double_${epName}`) ? true : undefined,
|
|
535
535
|
});
|
|
536
536
|
devstates.push({
|
|
537
537
|
id: `btn_${epID}_tripple`,
|
|
@@ -543,7 +543,7 @@ const generator = {
|
|
|
543
543
|
read: true,
|
|
544
544
|
type: 'boolean',
|
|
545
545
|
isEvent: true,
|
|
546
|
-
getter: payload => payload.action === `tripple_${epName}` ? true : undefined,
|
|
546
|
+
getter: payload => (payload.action === `tripple_${epName}`) ? true : undefined,
|
|
547
547
|
});
|
|
548
548
|
}
|
|
549
549
|
if (endpoint.supportsOutputCluster('genLevelCtrl')) {
|
|
@@ -558,8 +558,12 @@ const generator = {
|
|
|
558
558
|
unit: '',
|
|
559
559
|
min: 0,
|
|
560
560
|
max: 100,
|
|
561
|
-
getter: payload =>
|
|
562
|
-
|
|
561
|
+
getter: payload => {
|
|
562
|
+
return utils.bulbLevelToAdapterLevel(payload[`brightness_${epName}`]);
|
|
563
|
+
},
|
|
564
|
+
setter: (value) => {
|
|
565
|
+
return utils.adapterLevelToBulbLevel(value);
|
|
566
|
+
},
|
|
563
567
|
epname: epName,
|
|
564
568
|
setattr: 'brightness',
|
|
565
569
|
});
|
|
@@ -820,7 +824,7 @@ const devices = [
|
|
|
820
824
|
models: ['ZNCLDJ11LM'],
|
|
821
825
|
icon: 'img/aqara_curtain.png',
|
|
822
826
|
states: [states.curtain_position, states.curtain_running, states.curtain_stop, states.curtain_xiaomi_reverse_direction,
|
|
823
|
-
|
|
827
|
+
states.curtain_xiaomi_reset_limits, states.curtain_xiaomi_hand_open],
|
|
824
828
|
},
|
|
825
829
|
{
|
|
826
830
|
models: ['WXCJKG11LM'],
|
|
@@ -3040,7 +3044,7 @@ const devices = [
|
|
|
3040
3044
|
states: generator.icasa_remote,
|
|
3041
3045
|
},
|
|
3042
3046
|
|
|
3043
|
-
|
|
3047
|
+
/* images only for admin */
|
|
3044
3048
|
{
|
|
3045
3049
|
models: ['E1812'],
|
|
3046
3050
|
icon: 'img/ikea_E1812.png',
|
|
@@ -3071,12 +3075,13 @@ const devices = [
|
|
|
3071
3075
|
},
|
|
3072
3076
|
{
|
|
3073
3077
|
models: ['TI0001-cover'],
|
|
3074
|
-
|
|
3078
|
+
icon: 'img/TI0001-cover.png',
|
|
3075
3079
|
},
|
|
3076
3080
|
{
|
|
3077
3081
|
models: ['E1603/E1702/E1708'],
|
|
3078
3082
|
icon: 'img/ikea_control_outlet.png',
|
|
3079
3083
|
},
|
|
3084
|
+
|
|
3080
3085
|
];
|
|
3081
3086
|
|
|
3082
3087
|
const commonStates = [
|
|
@@ -3089,11 +3094,12 @@ const commonStates = [
|
|
|
3089
3094
|
|
|
3090
3095
|
const groupStates = [states.brightness_step].concat(lightStatesWithColor);
|
|
3091
3096
|
|
|
3097
|
+
|
|
3092
3098
|
function getByModel() {
|
|
3093
3099
|
const byModel = new Map();
|
|
3094
3100
|
for (const device of devices) {
|
|
3095
3101
|
for (const model of device.models) {
|
|
3096
|
-
const stripModel = model.replace(
|
|
3102
|
+
const stripModel = model.replace(/\0.*$/g, '').trim();
|
|
3097
3103
|
byModel.set(stripModel, device);
|
|
3098
3104
|
}
|
|
3099
3105
|
}
|
|
@@ -3115,22 +3121,25 @@ function fillStatesWithExposes(allExcludesObj) {
|
|
|
3115
3121
|
function removeEmptyStates(devices) {
|
|
3116
3122
|
for (const device of devices) {
|
|
3117
3123
|
if (Array.isArray(device.states)) {
|
|
3118
|
-
device.states = device.states.filter(el => el !== undefined);
|
|
3124
|
+
device.states = device.states.filter((el) => el !== undefined);
|
|
3119
3125
|
}
|
|
3120
3126
|
}
|
|
3121
3127
|
}
|
|
3122
3128
|
|
|
3129
|
+
|
|
3123
3130
|
function findModel(model) {
|
|
3124
3131
|
const byModel = getByModel();
|
|
3125
|
-
const stripModel = (model) ? model.replace(
|
|
3132
|
+
const stripModel = (model) ? model.replace(/\0.*$/g, '').trim() : '';
|
|
3126
3133
|
return byModel.get(stripModel);
|
|
3127
3134
|
}
|
|
3128
3135
|
|
|
3136
|
+
|
|
3137
|
+
|
|
3129
3138
|
module.exports = {
|
|
3130
|
-
devices,
|
|
3131
|
-
commonStates,
|
|
3132
|
-
groupStates,
|
|
3139
|
+
devices: devices,
|
|
3140
|
+
commonStates: commonStates,
|
|
3141
|
+
groupStates: groupStates,
|
|
3133
3142
|
groupsState: states.groups,
|
|
3134
|
-
fillStatesWithExposes,
|
|
3135
|
-
findModel
|
|
3143
|
+
fillStatesWithExposes: fillStatesWithExposes,
|
|
3144
|
+
findModel: findModel
|
|
3136
3145
|
};
|
package/lib/exclude.js
CHANGED
|
@@ -27,12 +27,13 @@ class Exclude {
|
|
|
27
27
|
debug(msg) {
|
|
28
28
|
this.adapter.log.debug(msg);
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
warn(msg) {
|
|
32
32
|
this.adapter.log.warn(msg);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
|
|
36
|
+
|
|
36
37
|
/**
|
|
37
38
|
* @param {ioBroker.Message} obj
|
|
38
39
|
*/
|
|
@@ -41,21 +42,24 @@ class Exclude {
|
|
|
41
42
|
switch (obj.command) {
|
|
42
43
|
case 'addExclude':
|
|
43
44
|
if (obj && obj.message && typeof obj.message === 'object') {
|
|
44
|
-
this.addExclude(obj.from, obj.command, obj.message, err
|
|
45
|
-
this.adapter.sendTo(obj.from, obj.command, err, obj.callback)
|
|
45
|
+
this.addExclude(obj.from, obj.command, obj.message, (err)=>{
|
|
46
|
+
this.adapter.sendTo(obj.from, obj.command, err, obj.callback);
|
|
47
|
+
});
|
|
46
48
|
}
|
|
47
49
|
break;
|
|
48
50
|
|
|
49
51
|
case 'getExclude':
|
|
50
52
|
if (obj && obj.message && typeof obj.message === 'object') {
|
|
51
|
-
this.getExclude(exclude
|
|
52
|
-
this.adapter.sendTo(obj.from, obj.command, exclude, obj.callback)
|
|
53
|
+
this.getExclude((exclude)=>{
|
|
54
|
+
this.adapter.sendTo(obj.from, obj.command, exclude, obj.callback);
|
|
55
|
+
});
|
|
53
56
|
}
|
|
54
57
|
break;
|
|
55
58
|
case 'delExclude':
|
|
56
59
|
if (obj && obj.message) {
|
|
57
|
-
this.delExclude(obj.from, obj.command, obj.message, err
|
|
58
|
-
this.adapter.sendTo(obj.from, obj.command, err, obj.callback)
|
|
60
|
+
this.delExclude(obj.from, obj.command, obj.message, (err)=>{
|
|
61
|
+
this.adapter.sendTo(obj.from, obj.command, err, obj.callback);
|
|
62
|
+
});
|
|
59
63
|
}
|
|
60
64
|
break;
|
|
61
65
|
}
|
|
@@ -65,14 +69,13 @@ class Exclude {
|
|
|
65
69
|
getExcludeId(exclude_target) {
|
|
66
70
|
return `${this.extractDeviceId(exclude_target)}`;
|
|
67
71
|
}
|
|
68
|
-
|
|
72
|
+
|
|
69
73
|
extractDeviceId(stateId) {
|
|
70
|
-
if (stateId)
|
|
74
|
+
if (stateId)
|
|
71
75
|
return stateId.replace(`${this.adapter.namespace}.`, '');
|
|
72
|
-
}
|
|
73
76
|
return '';
|
|
74
77
|
}
|
|
75
|
-
|
|
78
|
+
|
|
76
79
|
extractExcludeId(stateId) {
|
|
77
80
|
return stateId.replace(`${this.adapter.namespace}.exclude.`, '');
|
|
78
81
|
}
|
|
@@ -91,25 +94,27 @@ class Exclude {
|
|
|
91
94
|
{
|
|
92
95
|
type: 'state',
|
|
93
96
|
common: {name: exclude_mod},
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
}, () => {
|
|
98
|
+
this.adapter.setState(stateId, exclude_mod, true, () => {
|
|
99
|
+
callback();
|
|
100
|
+
});
|
|
101
|
+
}
|
|
97
102
|
);
|
|
98
103
|
} catch (error) {
|
|
99
104
|
this.error(`Failed to addExclude ${error.stack}`);
|
|
100
105
|
throw new Error(`Failed to addExclude ${error.stack}`);
|
|
101
106
|
}
|
|
102
107
|
}
|
|
103
|
-
|
|
104
108
|
async delExclude(from, command, exclude_id, callback) {
|
|
105
109
|
try {
|
|
106
|
-
this.debug(
|
|
110
|
+
this.debug('delExclude message: ' + JSON.stringify(exclude_id));
|
|
107
111
|
const stateId = `exclude.${exclude_id}`;
|
|
108
112
|
this.adapter.getStateAsync(stateId)
|
|
109
113
|
.then(async (stateV) => {
|
|
110
|
-
this.debug(
|
|
111
|
-
this.adapter.deleteState(null, 'exclude', exclude_id, async () =>
|
|
112
|
-
callback()
|
|
114
|
+
this.debug('found state: ' + JSON.stringify(stateV));
|
|
115
|
+
this.adapter.deleteState(null, 'exclude', exclude_id, async () => {
|
|
116
|
+
callback();
|
|
117
|
+
});
|
|
113
118
|
});
|
|
114
119
|
} catch (error) {
|
|
115
120
|
this.error(`Failed to delExclude ${error.stack}`);
|
|
@@ -125,31 +130,32 @@ class Exclude {
|
|
|
125
130
|
const exc = [];
|
|
126
131
|
states.forEach(state => {
|
|
127
132
|
if (state._id.startsWith(`${this.adapter.namespace}.exclude`)) {
|
|
128
|
-
exc.push(new Promise(resolve =>
|
|
129
|
-
this.adapter.getStateAsync(state._id)
|
|
133
|
+
exc.push(new Promise(resolve => {
|
|
134
|
+
return this.adapter.getStateAsync(state._id)
|
|
130
135
|
.then(stateVa => {
|
|
131
136
|
if (stateVa !== null) {
|
|
132
137
|
const val = {
|
|
133
138
|
id: this.extractExcludeId(state._id),
|
|
134
|
-
name: stateVa.val
|
|
139
|
+
name : stateVa.val
|
|
135
140
|
};
|
|
136
141
|
if (this.extractExcludeId(state._id) !== 'all') {
|
|
137
142
|
exclude.push(val);
|
|
138
143
|
}
|
|
139
144
|
}
|
|
140
145
|
resolve();
|
|
141
|
-
})
|
|
146
|
+
});
|
|
147
|
+
}));
|
|
142
148
|
}
|
|
143
149
|
});
|
|
144
|
-
return Promise.all(exc)
|
|
145
|
-
.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
callback(exclude));
|
|
150
|
+
return Promise.all(exc).then(() => {
|
|
151
|
+
const arrExclude = JSON.stringify(exclude);
|
|
152
|
+
this.debug('getExclude result: ' + arrExclude);
|
|
153
|
+
this.adapter.setState('exclude.all', arrExclude, true, () => {
|
|
154
|
+
callback(exclude);
|
|
150
155
|
});
|
|
156
|
+
});
|
|
151
157
|
} else {
|
|
152
|
-
this.debug(
|
|
158
|
+
this.debug('getExclude result: ' + JSON.stringify(exclude));
|
|
153
159
|
callback(exclude);
|
|
154
160
|
}
|
|
155
161
|
});
|