iobroker.zigbee 1.9.1 → 1.9.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/LICENSE +21 -21
- package/README.md +433 -425
- package/admin/adapter-settings.js +244 -244
- package/admin/admin.js +2991 -2991
- package/admin/i18n/de/translations.json +108 -108
- package/admin/i18n/en/translations.json +108 -108
- package/admin/i18n/es/translations.json +102 -102
- package/admin/i18n/fr/translations.json +108 -108
- package/admin/i18n/it/translations.json +102 -102
- package/admin/i18n/nl/translations.json +108 -108
- package/admin/i18n/pl/translations.json +108 -108
- package/admin/i18n/pt/translations.json +102 -102
- package/admin/i18n/ru/translations.json +108 -108
- package/admin/i18n/uk/translations.json +108 -108
- package/admin/i18n/zh-cn/translations.json +102 -102
- package/admin/img/philips_hue_lom001.png +0 -0
- package/admin/index.html +163 -163
- package/admin/index_m.html +1360 -1360
- package/admin/moment.min.js +1 -1
- package/admin/shuffle.min.js +2 -2
- package/admin/tab_m.html +1021 -1021
- package/admin/vis-network.min.css +1 -1
- package/admin/vis-network.min.js +26 -26
- package/admin/words.js +110 -110
- package/docs/de/basedocu.md +19 -19
- package/docs/de/readme.md +126 -126
- package/docs/en/readme.md +128 -128
- package/docs/flashing_via_arduino_(en).md +110 -110
- package/docs/ru/readme.md +28 -28
- package/docs/tutorial/groups-1.png +0 -0
- package/docs/tutorial/groups-2.png +0 -0
- package/docs/tutorial/tab-dev-1.png +0 -0
- package/io-package.json +27 -27
- package/lib/backup.js +171 -171
- package/lib/binding.js +319 -319
- package/lib/colors.js +465 -465
- package/lib/commands.js +4 -2
- package/lib/developer.js +151 -151
- package/lib/devicemgmt.js +374 -393
- package/lib/devices.js +3139 -3139
- package/lib/exclude.js +162 -162
- package/lib/exposes.js +41 -14
- package/lib/groups.js +345 -345
- package/lib/json.js +59 -59
- package/lib/networkmap.js +55 -55
- package/lib/ota.js +198 -198
- package/lib/rgb.js +297 -297
- package/lib/seriallist.js +48 -48
- package/lib/states.js +6420 -6420
- package/lib/statescontroller.js +25 -10
- package/lib/tools.js +54 -54
- package/lib/utils.js +165 -165
- package/lib/zbBaseExtension.js +36 -36
- package/lib/zbDelayedAction.js +144 -144
- package/lib/zbDeviceAvailability.js +319 -319
- package/lib/zbDeviceConfigure.js +148 -151
- package/lib/zbDeviceEvent.js +48 -48
- package/lib/zigbeecontroller.js +1014 -1014
- package/package.json +4 -4
- package/support/docgen.js +93 -93
package/lib/commands.js
CHANGED
|
@@ -88,7 +88,6 @@ class Commands {
|
|
|
88
88
|
break;
|
|
89
89
|
case 'setState':
|
|
90
90
|
if (obj && obj.message && typeof obj.message === 'object' && obj.message.id) {
|
|
91
|
-
// this.adapter.setState(obj.message.id, obj.message.val, false, obj.callback);
|
|
92
91
|
this.stController.setState_typed(obj.message.id, obj.message.val, false, undefined, obj.callback);
|
|
93
92
|
}
|
|
94
93
|
break;
|
|
@@ -107,7 +106,6 @@ class Commands {
|
|
|
107
106
|
this.setDeviceActivated(obj.from, obj.command, obj.message, obj.callback);
|
|
108
107
|
}
|
|
109
108
|
break;
|
|
110
|
-
|
|
111
109
|
}
|
|
112
110
|
}
|
|
113
111
|
}
|
|
@@ -474,13 +472,17 @@ class Commands {
|
|
|
474
472
|
async cleanDeviceStates(from, command, msg, callback) {
|
|
475
473
|
this.info(`State cleanup with ${JSON.stringify(msg)}`);
|
|
476
474
|
const devicesFromDB = await this.zbController.getClients(false);
|
|
475
|
+
|
|
477
476
|
for (const device of devicesFromDB) {
|
|
478
477
|
const entity = await this.zbController.resolveEntity(device);
|
|
478
|
+
|
|
479
479
|
if (entity) {
|
|
480
480
|
const model = (entity.mapped) ? entity.mapped.model : entity.device.modelID;
|
|
481
481
|
await this.stController.deleteOrphanedDeviceStates(device.ieeeAddr, model, msg.force);
|
|
482
482
|
}
|
|
483
483
|
}
|
|
484
|
+
// rebuild retainDeviceNamesDB
|
|
485
|
+
this.stController.rebuildRetainDeviceNames();
|
|
484
486
|
this.adapter.sendTo(from, command, {}, callback);
|
|
485
487
|
}
|
|
486
488
|
|
package/lib/developer.js
CHANGED
|
@@ -1,151 +1,151 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const ZigbeeHerdsman = require('zigbee-herdsman');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class Developer {
|
|
7
|
-
constructor(adapter) {
|
|
8
|
-
this.adapter = adapter;
|
|
9
|
-
this.adapter.on('message', this.onMessage.bind(this));
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
start(zbController, stController) {
|
|
13
|
-
this.zbController = zbController;
|
|
14
|
-
this.stController = stController;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
stop() {
|
|
18
|
-
delete this.zbController;
|
|
19
|
-
delete this.stController;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
info(msg) {
|
|
23
|
-
this.adapter.log.info(msg);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
error(msg) {
|
|
27
|
-
this.adapter.log.error(msg);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
debug(msg) {
|
|
31
|
-
this.adapter.log.debug(msg);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @param {ioBroker.Message} obj
|
|
36
|
-
*/
|
|
37
|
-
onMessage(obj) {
|
|
38
|
-
if (typeof obj === 'object' && obj.command) {
|
|
39
|
-
switch (obj.command) {
|
|
40
|
-
case 'reset':
|
|
41
|
-
this.zbController.reset(obj.message.mode, err =>
|
|
42
|
-
this.adapter.sendTo(obj.from, obj.command, err, obj.callback));
|
|
43
|
-
break;
|
|
44
|
-
case 'sendToZigbee':
|
|
45
|
-
this.sendToZigbee(obj);
|
|
46
|
-
break;
|
|
47
|
-
case 'getLibData':
|
|
48
|
-
// e.g. zcl lists
|
|
49
|
-
this.getLibData(obj);
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
getLibData(obj) {
|
|
56
|
-
const key = obj.message.key;
|
|
57
|
-
const zcl = ZigbeeHerdsman.Zcl;
|
|
58
|
-
const result = {};
|
|
59
|
-
if (key === 'cidList') {
|
|
60
|
-
result.list = zcl.Cluster;
|
|
61
|
-
} else if (key === 'attrIdList') {
|
|
62
|
-
const cid = obj.message.cid;
|
|
63
|
-
result.list = zcl.Utils.getCluster(cid).attributes;
|
|
64
|
-
} else if (key === 'cmdListFoundation') {
|
|
65
|
-
result.list = zcl.Foundation;
|
|
66
|
-
} else if (key === 'cmdListFunctional') {
|
|
67
|
-
result.list = null;
|
|
68
|
-
const cluster = zcl.Utils.getCluster(obj.message.cid);
|
|
69
|
-
if (typeof cluster != 'undefined') {
|
|
70
|
-
const extraCmd = cluster.commands;
|
|
71
|
-
result.list = extraCmd;
|
|
72
|
-
}
|
|
73
|
-
} else if (key === 'respCodes') {
|
|
74
|
-
result.list = zcl.Status;
|
|
75
|
-
} else if (key === 'typeList') {
|
|
76
|
-
result.list = zcl.DataType;
|
|
77
|
-
} else {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
result.key = key;
|
|
81
|
-
this.adapter.sendTo(obj.from, obj.command, result, obj.callback);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
async sendToZigbee(obj) {
|
|
85
|
-
const zcl = ZigbeeHerdsman.Zcl;
|
|
86
|
-
const devId = '0x' + obj.message.id.replace(this.adapter.namespace + '.', '');
|
|
87
|
-
const ep = obj.message.ep ? obj.message.ep : null;
|
|
88
|
-
const cid = obj.message.cid;
|
|
89
|
-
const cmdType = obj.message.cmdType;
|
|
90
|
-
let cmd;
|
|
91
|
-
const zclData = obj.message.zclData;
|
|
92
|
-
if (cmdType === 'functional') {
|
|
93
|
-
cmd = zcl.Utils.getCluster(cid).getCommand(obj.message.cmd);
|
|
94
|
-
} else if (cmdType === 'functionalResp') {
|
|
95
|
-
cmd = zcl.Utils.getCluster(cid).getCommandResponse(obj.message.cmd);
|
|
96
|
-
} else if (cmdType === 'foundation') {
|
|
97
|
-
cmd = zcl.Utils.getGlobalCommand((obj.message.cmd));
|
|
98
|
-
} else {
|
|
99
|
-
this.adapter.sendTo(obj.from, obj.command, {localErr: 'Invalid cmdType'}, obj.callback);
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const cfg = obj.message.hasOwnProperty('cfg') ? obj.message.cfg : null;
|
|
103
|
-
let publishTarget;
|
|
104
|
-
try {
|
|
105
|
-
publishTarget = this.zbController.getDevice(devId) ? devId : this.zbController.getGroup(parseInt(devId));
|
|
106
|
-
if (!publishTarget) {
|
|
107
|
-
this.adapter.sendTo(obj.from, obj.command, {localErr: `Device or group ${devId} not found!`}, obj.callback);
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
} catch (error) {
|
|
111
|
-
this.error(`SendToZigbee failed from publishTarget ${devId} (${error})`);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (!cid || !cmd) {
|
|
115
|
-
this.adapter.sendTo(obj.from, obj.command, {localErr: 'Incomplete data (cid or cmd)'}, obj.callback);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
this.debug(`Ready to send (ep: ${ep}, cid: ${cid}, cmd ${cmd.name}, zcl: ${JSON.stringify(zclData)})`);
|
|
119
|
-
|
|
120
|
-
try {
|
|
121
|
-
await this.zbController.publish(publishTarget, cid, cmd.name, zclData, cfg, ep, cmdType, (err, msg) => {
|
|
122
|
-
// map err and msg in one object for sendTo
|
|
123
|
-
const result = {};
|
|
124
|
-
result.msg = msg;
|
|
125
|
-
if (err) {
|
|
126
|
-
// err is an instance of Error class, it cannot be forwarded to sendTo, just get error code
|
|
127
|
-
result.error = err.code;
|
|
128
|
-
}
|
|
129
|
-
result.statusCode = 0;
|
|
130
|
-
this.adapter.sendTo(obj.from, obj.command, result, obj.callback);
|
|
131
|
-
}, obj.message.zclSeqNum);
|
|
132
|
-
} catch (exception) {
|
|
133
|
-
// report exceptions
|
|
134
|
-
// happens for example if user tries to send write command but did not provide value/type
|
|
135
|
-
// or unsupported attribute was addressed.
|
|
136
|
-
const ZclStatusError = require('zigbee-herdsman/dist/zcl/zclStatusError').default;
|
|
137
|
-
if (exception instanceof ZclStatusError) {
|
|
138
|
-
const result = {};
|
|
139
|
-
result.msg = `Zigbee error ${exception.code} received!`;
|
|
140
|
-
result.statusCode = exception.code;
|
|
141
|
-
this.adapter.sendTo(obj.from, obj.command, result, obj.callback);
|
|
142
|
-
} else {
|
|
143
|
-
this.error(`SendToZigbee failed! (${exception})`);
|
|
144
|
-
// exception (Error class) cannot be sent to adapter, send string message instead!
|
|
145
|
-
this.adapter.sendTo(obj.from, obj.command, {msg: exception.message}, obj.callback);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
module.exports = Developer;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const ZigbeeHerdsman = require('zigbee-herdsman');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Developer {
|
|
7
|
+
constructor(adapter) {
|
|
8
|
+
this.adapter = adapter;
|
|
9
|
+
this.adapter.on('message', this.onMessage.bind(this));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
start(zbController, stController) {
|
|
13
|
+
this.zbController = zbController;
|
|
14
|
+
this.stController = stController;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
stop() {
|
|
18
|
+
delete this.zbController;
|
|
19
|
+
delete this.stController;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
info(msg) {
|
|
23
|
+
this.adapter.log.info(msg);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
error(msg) {
|
|
27
|
+
this.adapter.log.error(msg);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
debug(msg) {
|
|
31
|
+
this.adapter.log.debug(msg);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @param {ioBroker.Message} obj
|
|
36
|
+
*/
|
|
37
|
+
onMessage(obj) {
|
|
38
|
+
if (typeof obj === 'object' && obj.command) {
|
|
39
|
+
switch (obj.command) {
|
|
40
|
+
case 'reset':
|
|
41
|
+
this.zbController.reset(obj.message.mode, err =>
|
|
42
|
+
this.adapter.sendTo(obj.from, obj.command, err, obj.callback));
|
|
43
|
+
break;
|
|
44
|
+
case 'sendToZigbee':
|
|
45
|
+
this.sendToZigbee(obj);
|
|
46
|
+
break;
|
|
47
|
+
case 'getLibData':
|
|
48
|
+
// e.g. zcl lists
|
|
49
|
+
this.getLibData(obj);
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
getLibData(obj) {
|
|
56
|
+
const key = obj.message.key;
|
|
57
|
+
const zcl = ZigbeeHerdsman.Zcl;
|
|
58
|
+
const result = {};
|
|
59
|
+
if (key === 'cidList') {
|
|
60
|
+
result.list = zcl.Cluster;
|
|
61
|
+
} else if (key === 'attrIdList') {
|
|
62
|
+
const cid = obj.message.cid;
|
|
63
|
+
result.list = zcl.Utils.getCluster(cid).attributes;
|
|
64
|
+
} else if (key === 'cmdListFoundation') {
|
|
65
|
+
result.list = zcl.Foundation;
|
|
66
|
+
} else if (key === 'cmdListFunctional') {
|
|
67
|
+
result.list = null;
|
|
68
|
+
const cluster = zcl.Utils.getCluster(obj.message.cid);
|
|
69
|
+
if (typeof cluster != 'undefined') {
|
|
70
|
+
const extraCmd = cluster.commands;
|
|
71
|
+
result.list = extraCmd;
|
|
72
|
+
}
|
|
73
|
+
} else if (key === 'respCodes') {
|
|
74
|
+
result.list = zcl.Status;
|
|
75
|
+
} else if (key === 'typeList') {
|
|
76
|
+
result.list = zcl.DataType;
|
|
77
|
+
} else {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
result.key = key;
|
|
81
|
+
this.adapter.sendTo(obj.from, obj.command, result, obj.callback);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async sendToZigbee(obj) {
|
|
85
|
+
const zcl = ZigbeeHerdsman.Zcl;
|
|
86
|
+
const devId = '0x' + obj.message.id.replace(this.adapter.namespace + '.', '');
|
|
87
|
+
const ep = obj.message.ep ? obj.message.ep : null;
|
|
88
|
+
const cid = obj.message.cid;
|
|
89
|
+
const cmdType = obj.message.cmdType;
|
|
90
|
+
let cmd;
|
|
91
|
+
const zclData = obj.message.zclData;
|
|
92
|
+
if (cmdType === 'functional') {
|
|
93
|
+
cmd = zcl.Utils.getCluster(cid).getCommand(obj.message.cmd);
|
|
94
|
+
} else if (cmdType === 'functionalResp') {
|
|
95
|
+
cmd = zcl.Utils.getCluster(cid).getCommandResponse(obj.message.cmd);
|
|
96
|
+
} else if (cmdType === 'foundation') {
|
|
97
|
+
cmd = zcl.Utils.getGlobalCommand((obj.message.cmd));
|
|
98
|
+
} else {
|
|
99
|
+
this.adapter.sendTo(obj.from, obj.command, {localErr: 'Invalid cmdType'}, obj.callback);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const cfg = obj.message.hasOwnProperty('cfg') ? obj.message.cfg : null;
|
|
103
|
+
let publishTarget;
|
|
104
|
+
try {
|
|
105
|
+
publishTarget = this.zbController.getDevice(devId) ? devId : this.zbController.getGroup(parseInt(devId));
|
|
106
|
+
if (!publishTarget) {
|
|
107
|
+
this.adapter.sendTo(obj.from, obj.command, {localErr: `Device or group ${devId} not found!`}, obj.callback);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
} catch (error) {
|
|
111
|
+
this.error(`SendToZigbee failed from publishTarget ${devId} (${error})`);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (!cid || !cmd) {
|
|
115
|
+
this.adapter.sendTo(obj.from, obj.command, {localErr: 'Incomplete data (cid or cmd)'}, obj.callback);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
this.debug(`Ready to send (ep: ${ep}, cid: ${cid}, cmd ${cmd.name}, zcl: ${JSON.stringify(zclData)})`);
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
await this.zbController.publish(publishTarget, cid, cmd.name, zclData, cfg, ep, cmdType, (err, msg) => {
|
|
122
|
+
// map err and msg in one object for sendTo
|
|
123
|
+
const result = {};
|
|
124
|
+
result.msg = msg;
|
|
125
|
+
if (err) {
|
|
126
|
+
// err is an instance of Error class, it cannot be forwarded to sendTo, just get error code
|
|
127
|
+
result.error = err.code;
|
|
128
|
+
}
|
|
129
|
+
result.statusCode = 0;
|
|
130
|
+
this.adapter.sendTo(obj.from, obj.command, result, obj.callback);
|
|
131
|
+
}, obj.message.zclSeqNum);
|
|
132
|
+
} catch (exception) {
|
|
133
|
+
// report exceptions
|
|
134
|
+
// happens for example if user tries to send write command but did not provide value/type
|
|
135
|
+
// or unsupported attribute was addressed.
|
|
136
|
+
const ZclStatusError = require('zigbee-herdsman/dist/zcl/zclStatusError').default;
|
|
137
|
+
if (exception instanceof ZclStatusError) {
|
|
138
|
+
const result = {};
|
|
139
|
+
result.msg = `Zigbee error ${exception.code} received!`;
|
|
140
|
+
result.statusCode = exception.code;
|
|
141
|
+
this.adapter.sendTo(obj.from, obj.command, result, obj.callback);
|
|
142
|
+
} else {
|
|
143
|
+
this.error(`SendToZigbee failed! (${exception})`);
|
|
144
|
+
// exception (Error class) cannot be sent to adapter, send string message instead!
|
|
145
|
+
this.adapter.sendTo(obj.from, obj.command, {msg: exception.message}, obj.callback);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
module.exports = Developer;
|