iobroker.zigbee2mqtt 0.1.0 → 0.2.0
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/README.md +14 -0
- package/admin/i18n/de/translations.json +7 -4
- package/admin/i18n/en/translations.json +6 -3
- package/admin/i18n/es/translations.json +6 -3
- package/admin/i18n/fr/translations.json +6 -3
- package/admin/i18n/it/translations.json +6 -3
- package/admin/i18n/nl/translations.json +6 -3
- package/admin/i18n/pl/translations.json +6 -3
- package/admin/i18n/pt/translations.json +6 -3
- package/admin/i18n/ru/translations.json +6 -3
- package/admin/i18n/zh-cn/translations.json +6 -3
- package/admin/jsonConfig.json +8 -3
- package/io-package.json +45 -6
- package/lib/exposes.js +195 -163
- package/lib/groups.js +27 -4
- package/lib/states.js +59 -36
- package/lib/utils.js +1 -1
- package/main.js +111 -101
- package/package.json +1 -1
package/lib/exposes.js
CHANGED
|
@@ -87,6 +87,7 @@ function genState(expose, role, name, desc) {
|
|
|
87
87
|
|
|
88
88
|
for (const val of expose.values) {
|
|
89
89
|
state.states[val] = val;
|
|
90
|
+
state.type = typeof (val);
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
if (expose.endpoint) {
|
|
@@ -118,7 +119,7 @@ function genState(expose, role, name, desc) {
|
|
|
118
119
|
return state;
|
|
119
120
|
}
|
|
120
121
|
|
|
121
|
-
function createFromExposes(deviceID, ieee_address, definitions, power_source) {
|
|
122
|
+
function createFromExposes(deviceID, ieee_address, definitions, power_source, scenes, useKelvin) {
|
|
122
123
|
const states = [];
|
|
123
124
|
// make the different (set and get) part of state is updatable if different exposes is used for get and set
|
|
124
125
|
// as example:
|
|
@@ -282,6 +283,7 @@ function createFromExposes(deviceID, ieee_address, definitions, power_source) {
|
|
|
282
283
|
min: 0, // ignore expose.value_min
|
|
283
284
|
max: 100, // ignore expose.value_max
|
|
284
285
|
inOptions: true,
|
|
286
|
+
unit: '%',
|
|
285
287
|
getter: (value) => {
|
|
286
288
|
return utils.bulbLevelToAdapterLevel(value[stateNameB]);
|
|
287
289
|
},
|
|
@@ -318,10 +320,9 @@ function createFromExposes(deviceID, ieee_address, definitions, power_source) {
|
|
|
318
320
|
write: true,
|
|
319
321
|
read: true,
|
|
320
322
|
type: 'number',
|
|
321
|
-
|
|
322
|
-
//
|
|
323
|
-
|
|
324
|
-
max: undefined,
|
|
323
|
+
min: undefined, //useKelvin == true ? expose.value_min : utils.miredKelvinConversion(expose.value_min),
|
|
324
|
+
max: undefined, //useKelvin == true ? expose.value_min : utils.miredKelvinConversion(expose.value_max),
|
|
325
|
+
unit: useKelvin == true ? 'K' : 'mired',
|
|
325
326
|
setter: (value) => {
|
|
326
327
|
return utils.toMired(value);
|
|
327
328
|
},
|
|
@@ -330,6 +331,14 @@ function createFromExposes(deviceID, ieee_address, definitions, power_source) {
|
|
|
330
331
|
const transitionTime = hasTransitionTime ? options.transition_time : 0;
|
|
331
332
|
return { ...options, transition: transitionTime };
|
|
332
333
|
},
|
|
334
|
+
getter: (payload) => {
|
|
335
|
+
if (useKelvin == true) {
|
|
336
|
+
return utils.miredKelvinConversion(payload.color_temp);
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
return payload.color_temp;
|
|
340
|
+
}
|
|
341
|
+
},
|
|
333
342
|
epname: expose.endpoint,
|
|
334
343
|
setattr: 'color_temp',
|
|
335
344
|
}, prop.access);
|
|
@@ -377,163 +386,164 @@ function createFromExposes(deviceID, ieee_address, definitions, power_source) {
|
|
|
377
386
|
}, 2);
|
|
378
387
|
break;
|
|
379
388
|
}
|
|
380
|
-
case 'color_hs': {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
}
|
|
389
|
+
// case 'color_hs': {
|
|
390
|
+
// const stateNameH = expose.endpoint ? `color_${expose.endpoint}` : 'color';
|
|
391
|
+
// pushToStates({
|
|
392
|
+
// id: stateNameH,
|
|
393
|
+
// prop: expose.endpoint ? `color_${expose.endpoint}` : 'color',
|
|
394
|
+
// name: `Color ${expose.endpoint ? expose.endpoint : ''}`.trim(),
|
|
395
|
+
// icon: undefined,
|
|
396
|
+
// role: 'level.color.rgb',
|
|
397
|
+
// write: true,
|
|
398
|
+
// read: true,
|
|
399
|
+
// type: 'string',
|
|
400
|
+
// setter: (value) => {
|
|
401
|
+
// const _rgb = colors.ParseColor(value);
|
|
402
|
+
// const hsv = rgb.rgbToHSV(_rgb.r, _rgb.g, _rgb.b, true);
|
|
403
|
+
// return {
|
|
404
|
+
// hue: Math.min(Math.max(hsv.h, 1), 359),
|
|
405
|
+
// saturation: hsv.s,
|
|
406
|
+
// // brightness: Math.floor(hsv.v * 2.55),
|
|
407
|
+
|
|
408
|
+
// };
|
|
409
|
+
// },
|
|
410
|
+
// setterOpt: (_value, options) => {
|
|
411
|
+
// const hasTransitionTime = options && options.hasOwnProperty('transition_time');
|
|
412
|
+
// const transitionTime = hasTransitionTime ? options.transition_time : 0;
|
|
413
|
+
// return { ...options, transition: transitionTime };
|
|
414
|
+
// },
|
|
415
|
+
// epname: expose.endpoint,
|
|
416
|
+
// setattr: 'color',
|
|
417
|
+
// }, prop.access);
|
|
418
|
+
// pushToStates({
|
|
419
|
+
// id: expose.endpoint ? `hue_${expose.endpoint}` : 'hue',
|
|
420
|
+
// prop: expose.endpoint ? `color_${expose.endpoint}` : 'color',
|
|
421
|
+
// name: `Hue ${expose.endpoint ? expose.endpoint : ''}`.trim(),
|
|
422
|
+
// icon: undefined,
|
|
423
|
+
// role: 'level.color.hue',
|
|
424
|
+
// write: true,
|
|
425
|
+
// read: false,
|
|
426
|
+
// type: 'number',
|
|
427
|
+
// min: 0,
|
|
428
|
+
// max: 360,
|
|
429
|
+
// inOptions: true,
|
|
430
|
+
// setter: (value, options) => {
|
|
431
|
+
// return {
|
|
432
|
+
// hue: value,
|
|
433
|
+
// saturation: options.saturation,
|
|
434
|
+
// };
|
|
435
|
+
// },
|
|
436
|
+
// setterOpt: (_value, options) => {
|
|
437
|
+
// const hasTransitionTime = options && options.hasOwnProperty('transition_time');
|
|
438
|
+
// const transitionTime = hasTransitionTime ? options.transition_time : 0;
|
|
439
|
+
// const hasHueCalibrationTable = options && options.hasOwnProperty('hue_calibration');
|
|
440
|
+
// if (hasHueCalibrationTable)
|
|
441
|
+
// try {
|
|
442
|
+
// return { ...options, transition: transitionTime, hue_correction: JSON.parse(options.hue_calibration) };
|
|
443
|
+
// }
|
|
444
|
+
// catch (err) {
|
|
445
|
+
// const hue_correction_table = [];
|
|
446
|
+
// options.hue_calibration.split(',').forEach(element => {
|
|
447
|
+
// const match = /([0-9]+):([0-9]+)/.exec(element);
|
|
448
|
+
// if (match && match.length == 3)
|
|
449
|
+
// hue_correction_table.push({ in: Number(match[1]), out: Number(match[2]) });
|
|
450
|
+
// });
|
|
451
|
+
// if (hue_correction_table.length > 0)
|
|
452
|
+
// return { ...options, transition: transitionTime, hue_correction: hue_correction_table };
|
|
453
|
+
// }
|
|
454
|
+
// return { ...options, transition: transitionTime };
|
|
455
|
+
// },
|
|
456
|
+
|
|
457
|
+
// }, prop.access);
|
|
458
|
+
// pushToStates({
|
|
459
|
+
// id: expose.endpoint ? `saturation_${expose.endpoint}` : 'saturation',
|
|
460
|
+
// prop: expose.endpoint ? `color_${expose.endpoint}` : 'color',
|
|
461
|
+
// name: `Saturation ${expose.endpoint ? expose.endpoint : ''}`.trim(),
|
|
462
|
+
// icon: undefined,
|
|
463
|
+
// role: 'level.color.saturation',
|
|
464
|
+
// write: true,
|
|
465
|
+
// read: false,
|
|
466
|
+
// type: 'number',
|
|
467
|
+
// min: 0,
|
|
468
|
+
// max: 100,
|
|
469
|
+
// inOptions: true,
|
|
470
|
+
// setter: (value, options) => {
|
|
471
|
+
// return {
|
|
472
|
+
// hue: options.hue,
|
|
473
|
+
// saturation: value,
|
|
474
|
+
// };
|
|
475
|
+
// },
|
|
476
|
+
// setterOpt: (_value, options) => {
|
|
477
|
+
// const hasTransitionTime = options && options.hasOwnProperty('transition_time');
|
|
478
|
+
// const transitionTime = hasTransitionTime ? options.transition_time : 0;
|
|
479
|
+
// const hasHueCalibrationTable = options && options.hasOwnProperty('hue_calibration');
|
|
480
|
+
// if (hasHueCalibrationTable)
|
|
481
|
+
// try {
|
|
482
|
+
// return { ...options, transition: transitionTime, hue_correction: JSON.parse(options.hue_calibration) };
|
|
483
|
+
// }
|
|
484
|
+
// catch (err) {
|
|
485
|
+
// const hue_correction_table = [];
|
|
486
|
+
// options.hue_calibration.split(',').forEach(element => {
|
|
487
|
+
// const match = /([0-9]+):([0-9]+)/.exec(element);
|
|
488
|
+
// if (match && match.length == 3)
|
|
489
|
+
// hue_correction_table.push({ in: Number(match[1]), out: Number(match[2]) });
|
|
490
|
+
// });
|
|
491
|
+
// if (hue_correction_table.length > 0)
|
|
492
|
+
// return { ...options, transition: transitionTime, hue_correction: hue_correction_table };
|
|
493
|
+
// }
|
|
494
|
+
// return { ...options, transition: transitionTime };
|
|
495
|
+
// },
|
|
496
|
+
|
|
497
|
+
// }, prop.access);
|
|
498
|
+
// pushToStates(statesDefs.hue_move, prop.access);
|
|
499
|
+
// pushToStates(statesDefs.saturation_move, prop.access);
|
|
500
|
+
// pushToStates({
|
|
501
|
+
// id: 'hue_calibration',
|
|
502
|
+
// prop: 'color',
|
|
503
|
+
// name: 'Hue color calibration table',
|
|
504
|
+
// icon: undefined,
|
|
505
|
+
// role: 'table',
|
|
506
|
+
// write: true,
|
|
507
|
+
// read: false,
|
|
508
|
+
// type: 'string',
|
|
509
|
+
// inOptions: true,
|
|
510
|
+
// setter: (_value, options) => {
|
|
511
|
+
// return {
|
|
512
|
+
// hue: options.hue,
|
|
513
|
+
// saturation: options.saturation,
|
|
514
|
+
// };
|
|
515
|
+
// },
|
|
516
|
+
// setterOpt: (_value, options) => {
|
|
517
|
+
// const hasTransitionTime = options && options.hasOwnProperty('transition_time');
|
|
518
|
+
// const transitionTime = hasTransitionTime ? options.transition_time : 0;
|
|
519
|
+
// const hasHueCalibrationTable = options && options.hasOwnProperty('hue_calibration');
|
|
520
|
+
// if (hasHueCalibrationTable)
|
|
521
|
+
// try {
|
|
522
|
+
// return { ...options, transition: transitionTime, hue_correction: JSON.parse(options.hue_calibration) };
|
|
523
|
+
// }
|
|
524
|
+
// catch (err) {
|
|
525
|
+
// const hue_correction_table = [];
|
|
526
|
+
// options.hue_calibration.split(',').forEach(element => {
|
|
527
|
+
// const match = /([0-9]+):([0-9]+)/.exec(element);
|
|
528
|
+
// if (match && match.length == 3)
|
|
529
|
+
// hue_correction_table.push({ in: Number(match[1]), out: Number(match[2]) });
|
|
530
|
+
// });
|
|
531
|
+
// if (hue_correction_table.length > 0)
|
|
532
|
+
// return { ...options, transition: transitionTime, hue_correction: hue_correction_table };
|
|
533
|
+
// }
|
|
534
|
+
// return { ...options, transition: transitionTime };
|
|
535
|
+
// },
|
|
536
|
+
|
|
537
|
+
// }, prop.access);
|
|
538
|
+
// break;
|
|
539
|
+
// }
|
|
531
540
|
default:
|
|
532
541
|
pushToStates(genState(prop), prop.access);
|
|
533
542
|
break;
|
|
534
543
|
}
|
|
535
544
|
}
|
|
536
|
-
|
|
545
|
+
// First don't create a transition_time datapoint, this will be set in the backend
|
|
546
|
+
//pushToStates(statesDefs.transition_time, 2);
|
|
537
547
|
break;
|
|
538
548
|
|
|
539
549
|
case 'switch':
|
|
@@ -720,8 +730,13 @@ function createFromExposes(deviceID, ieee_address, definitions, power_source) {
|
|
|
720
730
|
case 'running_mode':
|
|
721
731
|
pushToStates(statesDefs.climate_running_mode, prop.access);
|
|
722
732
|
break;
|
|
723
|
-
default:
|
|
724
|
-
|
|
733
|
+
default: {
|
|
734
|
+
if (prop.name.includes('heating_setpoint')) {
|
|
735
|
+
pushToStates(genState(prop, 'level.temperature'), prop.access);
|
|
736
|
+
} else {
|
|
737
|
+
pushToStates(genState(prop), prop.access);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
725
740
|
break;
|
|
726
741
|
}
|
|
727
742
|
}
|
|
@@ -776,7 +791,7 @@ function createFromExposes(deviceID, ieee_address, definitions, power_source) {
|
|
|
776
791
|
// Add default states
|
|
777
792
|
pushToStates(statesDefs.available, 1);
|
|
778
793
|
|
|
779
|
-
const
|
|
794
|
+
const newDevice = {
|
|
780
795
|
id: deviceID,
|
|
781
796
|
ieee_address: ieee_address,
|
|
782
797
|
icon: icon,
|
|
@@ -784,14 +799,31 @@ function createFromExposes(deviceID, ieee_address, definitions, power_source) {
|
|
|
784
799
|
states: states,
|
|
785
800
|
};
|
|
786
801
|
|
|
787
|
-
|
|
802
|
+
// Create buttons for scenes
|
|
803
|
+
for (const scene of scenes) {
|
|
804
|
+
const sceneSate = {
|
|
805
|
+
id: `scene_${scene.id}`,
|
|
806
|
+
prop: `scene_recall`,
|
|
807
|
+
name: scene.name,
|
|
808
|
+
icon: undefined,
|
|
809
|
+
role: 'button',
|
|
810
|
+
write: true,
|
|
811
|
+
read: true,
|
|
812
|
+
type: 'boolean',
|
|
813
|
+
setter: (value) => (value) ? scene.id : undefined
|
|
814
|
+
};
|
|
815
|
+
// @ts-ignore
|
|
816
|
+
newDevice.states.push(sceneSate);
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
return newDevice;
|
|
788
820
|
}
|
|
789
821
|
|
|
790
|
-
function defineDeviceFromExposes(devices, deviceID, ieee_address, definitions, power_source) {
|
|
822
|
+
function defineDeviceFromExposes(devices, deviceID, ieee_address, definitions, power_source, scenes, useKelvin) {
|
|
791
823
|
// if the device is already present in the cache, remove it
|
|
792
824
|
utils.removeDeviceByIeee(devices, ieee_address);
|
|
793
825
|
if (definitions.hasOwnProperty('exposes')) {
|
|
794
|
-
const newDevice = createFromExposes(deviceID, ieee_address, definitions, power_source);
|
|
826
|
+
const newDevice = createFromExposes(deviceID, ieee_address, definitions, power_source, scenes, useKelvin);
|
|
795
827
|
devices.push(newDevice);
|
|
796
828
|
}
|
|
797
829
|
}
|
package/lib/groups.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const states = require('./states').states;
|
|
2
2
|
const utils = require('./utils');
|
|
3
3
|
|
|
4
|
-
function defineGroupDevice(devices, groupID, ieee_address, scenes) {
|
|
4
|
+
function defineGroupDevice(devices, groupID, ieee_address, scenes, useKelvin) {
|
|
5
5
|
const newDevice = {
|
|
6
6
|
id: groupID,
|
|
7
7
|
ieee_address: ieee_address,
|
|
@@ -9,15 +9,38 @@ function defineGroupDevice(devices, groupID, ieee_address, scenes) {
|
|
|
9
9
|
states: [
|
|
10
10
|
states.state,
|
|
11
11
|
states.brightness,
|
|
12
|
-
states.colortemp,
|
|
13
12
|
states.color,
|
|
14
13
|
states.brightness_move,
|
|
15
14
|
states.colortemp_move,
|
|
16
|
-
states.transition_time,
|
|
17
|
-
//states.brightness_step
|
|
18
15
|
],
|
|
19
16
|
};
|
|
20
17
|
|
|
18
|
+
const colortemp = {
|
|
19
|
+
id: 'colortemp',
|
|
20
|
+
prop: 'color_temp',
|
|
21
|
+
name: 'Color temperature',
|
|
22
|
+
icon: undefined,
|
|
23
|
+
role: 'level.color.temperature',
|
|
24
|
+
write: true,
|
|
25
|
+
read: true,
|
|
26
|
+
type: 'number',
|
|
27
|
+
unit: useKelvin == true ? 'K' : 'mired',
|
|
28
|
+
setter: (value) => {
|
|
29
|
+
return utils.toMired(value);
|
|
30
|
+
},
|
|
31
|
+
getter: (payload) => {
|
|
32
|
+
if (useKelvin == true) {
|
|
33
|
+
return utils.miredKelvinConversion(payload.color_temp);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
return payload.color_temp;
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
newDevice.states.push(colortemp);
|
|
43
|
+
|
|
21
44
|
// Create buttons for scenes
|
|
22
45
|
for (const scene of scenes) {
|
|
23
46
|
const sceneSate = {
|