zigbee-herdsman-converters 14.0.533 → 14.0.536
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/converters/fromZigbee.js +3 -3
- package/converters/toZigbee.js +1 -1
- package/devices/aubess.js +21 -0
- package/devices/danfoss.js +1 -1
- package/devices/gledopto.js +1 -1
- package/devices/m/303/274ller_licht.js +4 -12
- package/devices/perenio.js +2 -1
- package/devices/somgoms.js +1 -1
- package/devices/sonoff.js +12 -0
- package/devices/sunricher.js +2 -1
- package/devices/third_reality.js +8 -1
- package/devices/tuya.js +2 -1
- package/devices/zemismart.js +30 -1
- package/lib/constants.js +2 -1
- package/lib/zosung.js +241 -0
- package/package.json +1 -1
package/converters/fromZigbee.js
CHANGED
|
@@ -5267,7 +5267,7 @@ const converters = {
|
|
|
5267
5267
|
const value = tuya.getDataValue(dpValue);
|
|
5268
5268
|
const state = value ? 'ON' : 'OFF';
|
|
5269
5269
|
if (multiEndpoint) {
|
|
5270
|
-
const lookup = {1: 'l1', 2: 'l2', 3: 'l3', 4: 'l4'};
|
|
5270
|
+
const lookup = {1: 'l1', 2: 'l2', 3: 'l3', 4: 'l4', 5: 'l5', 6: 'l6'};
|
|
5271
5271
|
const endpoint = lookup[dp];
|
|
5272
5272
|
if (endpoint in model.endpoint(msg.device)) {
|
|
5273
5273
|
return {[`state_${endpoint}`]: state};
|
|
@@ -7304,9 +7304,9 @@ const converters = {
|
|
|
7304
7304
|
const value = tuya.getDataValue(dpValue);
|
|
7305
7305
|
switch (dp) {
|
|
7306
7306
|
case 2:
|
|
7307
|
-
return {illuminance_lux: value
|
|
7307
|
+
return {illuminance_lux: value};
|
|
7308
7308
|
case 4:
|
|
7309
|
-
return {battery: value
|
|
7309
|
+
return {battery: value};
|
|
7310
7310
|
case 1:
|
|
7311
7311
|
return {battery_low: value.toFixed(1)};
|
|
7312
7312
|
default:
|
package/converters/toZigbee.js
CHANGED
|
@@ -3842,7 +3842,7 @@ const converters = {
|
|
|
3842
3842
|
tuya_switch_state: {
|
|
3843
3843
|
key: ['state'],
|
|
3844
3844
|
convertSet: async (entity, key, value, meta) => {
|
|
3845
|
-
const lookup = {l1: 1, l2: 2, l3: 3, l4: 4};
|
|
3845
|
+
const lookup = {l1: 1, l2: 2, l3: 3, l4: 4, l5: 5, l6: 6};
|
|
3846
3846
|
const multiEndpoint = utils.getMetaValue(entity, meta.mapped, 'multiEndpoint', 'allEqual', false);
|
|
3847
3847
|
const keyid = multiEndpoint ? lookup[meta.endpoint_name] : 1;
|
|
3848
3848
|
await tuya.sendDataPointBool(entity, keyid, value === 'ON');
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const zosung = require('../lib/zosung');
|
|
2
|
+
const fzZosung = zosung.fzZosung;
|
|
3
|
+
const tzZosung = zosung.tzZosung;
|
|
4
|
+
const ez = zosung.presetsZosung;
|
|
5
|
+
|
|
6
|
+
module.exports = [
|
|
7
|
+
{
|
|
8
|
+
fingerprint: [{modelID: 'TS1201', manufacturerName: '_TZ3290_acv1iuslxi3shaaj'}],
|
|
9
|
+
model: 'ZXZIR-02',
|
|
10
|
+
vendor: 'AUBESS',
|
|
11
|
+
description: 'Universal smart IR remote control',
|
|
12
|
+
fromZigbee: [
|
|
13
|
+
fzZosung.zosung_send_ir_code_00, fzZosung.zosung_send_ir_code_01, fzZosung.zosung_send_ir_code_02,
|
|
14
|
+
fzZosung.zosung_send_ir_code_03, fzZosung.zosung_send_ir_code_04, fzZosung.zosung_send_ir_code_05,
|
|
15
|
+
],
|
|
16
|
+
toZigbee: [
|
|
17
|
+
tzZosung.zosung_ir_code_to_send, tzZosung.zosung_learn_ir_code,
|
|
18
|
+
],
|
|
19
|
+
exposes: [ez.learn_ir_code(), ez.learned_ir_code(), ez.ir_code_to_send()],
|
|
20
|
+
},
|
|
21
|
+
];
|
package/devices/danfoss.js
CHANGED
|
@@ -88,7 +88,7 @@ module.exports = [
|
|
|
88
88
|
'Valve Characteristic Lost'),
|
|
89
89
|
exposes.binary('adaptation_run_settings', ea.ALL, true, false)
|
|
90
90
|
.withDescription('Automatic adaptation run enabled (the one during the night)'),
|
|
91
|
-
exposes.enum('adaptation_run_control', ea.ALL, ['
|
|
91
|
+
exposes.enum('adaptation_run_control', ea.ALL, ['none', 'initiate_adaptation', 'cancel_adaptation'])
|
|
92
92
|
.withDescription('Adaptation run control: Initiate Adaptation Run or Cancel Adaptation Run'),
|
|
93
93
|
exposes.numeric('regulation_setpoint_offset', ea.ALL)
|
|
94
94
|
.withDescription('Regulation SetPoint Offset in range -2.5°C to 2.5°C in steps of 0.1°C. Value 2.5°C = 25.')
|
package/devices/gledopto.js
CHANGED
|
@@ -267,7 +267,7 @@ module.exports = [
|
|
|
267
267
|
vendor: 'Gledopto',
|
|
268
268
|
ota: ota.zigbeeOTA,
|
|
269
269
|
description: 'Zigbee LED Controller RGB+CCT (pro)',
|
|
270
|
-
whiteLabel: [{vendor: 'Gledopto', model: 'GL-C-001P'}],
|
|
270
|
+
whiteLabel: [{vendor: 'Gledopto', model: 'GL-C-001P'}, {vendor: 'Gledopto', model: 'GL-C-002P'}],
|
|
271
271
|
extend: gledoptoExtend.light_onoff_brightness_colortemp_color({colorTempRange: [158, 495], noConfigure: true}),
|
|
272
272
|
meta: {disableDefaultResponse: true},
|
|
273
273
|
configure: async (device, coordinatorEndpoint, logger) => {
|
|
@@ -8,7 +8,7 @@ const e = exposes.presets;
|
|
|
8
8
|
module.exports = [
|
|
9
9
|
{
|
|
10
10
|
zigbeeModel: ['tint-ExtendedColor'],
|
|
11
|
-
model: '404036/45327',
|
|
11
|
+
model: '404036/45327/45317',
|
|
12
12
|
vendor: 'Müller Licht',
|
|
13
13
|
description: 'Tint LED white+color',
|
|
14
14
|
extend: extend.light_onoff_brightness_colortemp_color({colorTempRange: [153, 556]}),
|
|
@@ -157,18 +157,10 @@ module.exports = [
|
|
|
157
157
|
toZigbee: [],
|
|
158
158
|
},
|
|
159
159
|
{
|
|
160
|
-
zigbeeModel: ['tint-ColorTemperature'],
|
|
161
|
-
model: '404037',
|
|
160
|
+
zigbeeModel: ['tint-ColorTemperature', 'tint-ColorTemperature2'],
|
|
161
|
+
model: '404037/404038',
|
|
162
162
|
vendor: 'Müller Licht',
|
|
163
|
-
description: '
|
|
164
|
-
extend: extend.light_onoff_brightness_colortemp(),
|
|
165
|
-
toZigbee: extend.light_onoff_brightness_colortemp().toZigbee.concat([tz.tint_scene]),
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
zigbeeModel: ['tint-ColorTemperature2'],
|
|
169
|
-
model: '404038',
|
|
170
|
-
vendor: 'Müller Licht',
|
|
171
|
-
description: 'Tint retro filament LED-bulb E27, Globe bulb gold, white+ambiance (1800-6500K), dimmable, 5,5W',
|
|
163
|
+
description: 'CCT LED-bulb',
|
|
172
164
|
extend: extend.light_onoff_brightness_colortemp({colorTempRange: [153, 555]}),
|
|
173
165
|
toZigbee: extend.light_onoff_brightness_colortemp().toZigbee.concat([tz.tint_scene]),
|
|
174
166
|
},
|
package/devices/perenio.js
CHANGED
|
@@ -207,11 +207,12 @@ module.exports = [
|
|
|
207
207
|
description: 'Door sensor',
|
|
208
208
|
fromZigbee: [fz.ias_contact_alarm_1, fz.battery, fz.ignore_basic_report, fz.ias_contact_alarm_1_report],
|
|
209
209
|
toZigbee: [],
|
|
210
|
-
exposes: [e.contact(), e.battery()],
|
|
210
|
+
exposes: [e.contact(), e.battery(), e.battery_voltage()],
|
|
211
211
|
configure: async (device, coordinatorEndpoint, logger) => {
|
|
212
212
|
const endpoint = device.getEndpoint(1);
|
|
213
213
|
await reporting.bind(endpoint, coordinatorEndpoint, ['genPowerCfg']);
|
|
214
214
|
await reporting.batteryPercentageRemaining(endpoint);
|
|
215
|
+
await reporting.batteryVoltage(endpoint);
|
|
215
216
|
},
|
|
216
217
|
},
|
|
217
218
|
{
|
package/devices/somgoms.js
CHANGED
|
@@ -26,7 +26,7 @@ module.exports = [
|
|
|
26
26
|
exposes: [e.cover_position().setAccess('position', ea.STATE_SET)],
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
|
-
|
|
29
|
+
fingerprint: [{modelID: 'TS0601', manufacturerName: '_TZE200_sbordckq'}],
|
|
30
30
|
model: 'SM-1CTW-EU',
|
|
31
31
|
vendor: 'Somgoms',
|
|
32
32
|
description: 'Curtain switch',
|
package/devices/sonoff.js
CHANGED
|
@@ -164,4 +164,16 @@ module.exports = [
|
|
|
164
164
|
description: 'Zigbee smart plug',
|
|
165
165
|
extend: extend.switch(),
|
|
166
166
|
},
|
|
167
|
+
{
|
|
168
|
+
zigbeeModel: ['S40LITE'],
|
|
169
|
+
model: 'S40ZBTPB',
|
|
170
|
+
vendor: 'SONOFF',
|
|
171
|
+
description: '15A Zigbee smart plug',
|
|
172
|
+
extend: extend.switch(),
|
|
173
|
+
fromZigbee: [fz.on_off_skip_duplicate_transaction],
|
|
174
|
+
configure: async (device, coordinatorEndpoint, logger) => {
|
|
175
|
+
const endpoint = device.getEndpoint(1);
|
|
176
|
+
await reporting.bind(endpoint, coordinatorEndpoint, ['genOnOff']);
|
|
177
|
+
},
|
|
178
|
+
},
|
|
167
179
|
];
|
package/devices/sunricher.js
CHANGED
|
@@ -281,7 +281,8 @@ module.exports = [
|
|
|
281
281
|
},
|
|
282
282
|
},
|
|
283
283
|
{
|
|
284
|
-
fingerprint: [{modelID: 'GreenPower_2', ieeeAddr: /^0x00000000010.....$/}
|
|
284
|
+
fingerprint: [{modelID: 'GreenPower_2', ieeeAddr: /^0x00000000010.....$/},
|
|
285
|
+
{modelID: 'GreenPower_2', ieeeAddr: /^0x0000000001b.....$/}],
|
|
285
286
|
model: 'SR-ZGP2801K2-DIM',
|
|
286
287
|
vendor: 'Sunricher',
|
|
287
288
|
description: 'Pushbutton transmitter module',
|
package/devices/third_reality.js
CHANGED
|
@@ -73,8 +73,11 @@ module.exports = [
|
|
|
73
73
|
description: 'Wireless motion sensor',
|
|
74
74
|
fromZigbee: [fz.ias_occupancy_alarm_1, fz.battery],
|
|
75
75
|
toZigbee: [],
|
|
76
|
-
meta: {battery: {dontDividePercentage: true}},
|
|
77
76
|
exposes: [e.occupancy(), e.battery_low(), e.battery(), e.battery_voltage()],
|
|
77
|
+
configure: async (device, coordinatorEndpoint, logger) => {
|
|
78
|
+
device.powerSource = 'Battery';
|
|
79
|
+
device.save();
|
|
80
|
+
},
|
|
78
81
|
},
|
|
79
82
|
{
|
|
80
83
|
zigbeeModel: ['3RDS17BZ'],
|
|
@@ -85,6 +88,10 @@ module.exports = [
|
|
|
85
88
|
toZigbee: [],
|
|
86
89
|
meta: {battery: {dontDividePercentage: true}},
|
|
87
90
|
exposes: [e.contact(), e.battery_low(), e.battery(), e.battery_voltage()],
|
|
91
|
+
configure: async (device, coordinatorEndpoint, logger) => {
|
|
92
|
+
device.powerSource = 'Battery';
|
|
93
|
+
device.save();
|
|
94
|
+
},
|
|
88
95
|
},
|
|
89
96
|
{
|
|
90
97
|
zigbeeModel: ['3RSP019BZ'],
|
package/devices/tuya.js
CHANGED
|
@@ -14,7 +14,7 @@ const TS011Fplugs = ['_TZ3000_5f43h46b', '_TZ3000_cphmq0q7', '_TZ3000_dpo1ysak',
|
|
|
14
14
|
'_TZ3000_jvzvulen', '_TZ3000_mraovvmm', '_TZ3000_nfnmi125', '_TZ3000_ps3dmato', '_TZ3000_w0qqde0g', '_TZ3000_u5u4cakc',
|
|
15
15
|
'_TZ3000_rdtixbnu', '_TZ3000_typdpbpg', '_TZ3000_kx0pris5', '_TZ3000_amdymr7l', '_TZ3000_z1pnpsdo', '_TZ3000_ksw8qtmt',
|
|
16
16
|
'_TZ3000_nzkqcvvs', '_TZ3000_1h2x4akh', '_TZ3000_9vo5icau', '_TZ3000_cehuw1lw', '_TZ3000_ko6v90pg', '_TZ3000_f1bapcit',
|
|
17
|
-
'_TZ3000_cjrngdr3', '_TZ3000_zloso4jk', '
|
|
17
|
+
'_TZ3000_cjrngdr3', '_TZ3000_zloso4jk', '_TZ3000_r6buo8ba'];
|
|
18
18
|
|
|
19
19
|
const tzLocal = {
|
|
20
20
|
TS0504B_color: {
|
|
@@ -223,6 +223,7 @@ module.exports = [
|
|
|
223
223
|
{
|
|
224
224
|
fingerprint: [{modelID: 'TS0001', manufacturerName: '_TZ3000_hktqahrq'}, {manufacturerName: '_TZ3000_hktqahrq'},
|
|
225
225
|
{manufacturerName: '_TZ3000_q6a3tepg'}, {modelID: 'TS000F', manufacturerName: '_TZ3000_m9af2l6g'},
|
|
226
|
+
{modelID: 'TS000F', manufacturerName: '_TZ3000_mx3vgyea'},
|
|
226
227
|
{modelID: 'TS0001', manufacturerName: '_TZ3000_npzfdcof'},
|
|
227
228
|
{modelID: 'TS0001', manufacturerName: '_TZ3000_5ng23zjs'},
|
|
228
229
|
{modelID: 'TS0001', manufacturerName: '_TZ3000_rmjr4ufz'},
|
package/devices/zemismart.js
CHANGED
|
@@ -130,7 +130,7 @@ module.exports = [
|
|
|
130
130
|
'button_6_hold', 'button_6_single', 'button_6_double'])],
|
|
131
131
|
},
|
|
132
132
|
{
|
|
133
|
-
fingerprint: [{modelID: 'TS011F', manufacturerName: '_TZ3000_zigisuyh'}],
|
|
133
|
+
fingerprint: [{modelID: 'TS011F', manufacturerName: '_TZ3000_zigisuyh'}, {modelID: 'TS011F', manufacturerName: '_TZ3000_v4mevirn'}],
|
|
134
134
|
model: 'ZIGBEE-B09-UK',
|
|
135
135
|
vendor: 'Zemismart',
|
|
136
136
|
description: 'Zigbee smart outlet universal socket with USB port',
|
|
@@ -189,4 +189,33 @@ module.exports = [
|
|
|
189
189
|
toZigbee: [tz.tuya_cover_control, tz.tuya_cover_options, tz.tuya_data_point_test],
|
|
190
190
|
exposes: [e.cover_position().setAccess('position', ea.STATE_SET)],
|
|
191
191
|
},
|
|
192
|
+
{
|
|
193
|
+
fingerprint: [{modelID: 'TS0601', manufacturerName: '_TZE200_9mahtqtg'}],
|
|
194
|
+
model: 'TB26-6',
|
|
195
|
+
vendor: 'Zemismart',
|
|
196
|
+
description: '6-gang smart wall switch',
|
|
197
|
+
exposes: [e.switch().withEndpoint('l1').setAccess('state', ea.STATE_SET),
|
|
198
|
+
e.switch().withEndpoint('l2').setAccess('state', ea.STATE_SET),
|
|
199
|
+
e.switch().withEndpoint('l3').setAccess('state', ea.STATE_SET),
|
|
200
|
+
e.switch().withEndpoint('l4').setAccess('state', ea.STATE_SET),
|
|
201
|
+
e.switch().withEndpoint('l5').setAccess('state', ea.STATE_SET),
|
|
202
|
+
e.switch().withEndpoint('l6').setAccess('state', ea.STATE_SET)],
|
|
203
|
+
fromZigbee: [fz.ignore_basic_report, fz.tuya_switch],
|
|
204
|
+
toZigbee: [tz.tuya_switch_state],
|
|
205
|
+
meta: {multiEndpoint: true},
|
|
206
|
+
endpoint: (device) => {
|
|
207
|
+
return {'l1': 1, 'l2': 1, 'l3': 1, 'l4': 1, 'l5': 1, 'l6': 1};
|
|
208
|
+
},
|
|
209
|
+
configure: async (device, coordinatorEndpoint, logger) => {
|
|
210
|
+
await reporting.bind(device.getEndpoint(1), coordinatorEndpoint, ['genOnOff']);
|
|
211
|
+
if (device.getEndpoint(2)) await reporting.bind(device.getEndpoint(2), coordinatorEndpoint, ['genOnOff']);
|
|
212
|
+
if (device.getEndpoint(3)) await reporting.bind(device.getEndpoint(3), coordinatorEndpoint, ['genOnOff']);
|
|
213
|
+
if (device.getEndpoint(4)) await reporting.bind(device.getEndpoint(4), coordinatorEndpoint, ['genOnOff']);
|
|
214
|
+
if (device.getEndpoint(5)) await reporting.bind(device.getEndpoint(5), coordinatorEndpoint, ['genOnOff']);
|
|
215
|
+
if (device.getEndpoint(6)) await reporting.bind(device.getEndpoint(6), coordinatorEndpoint, ['genOnOff']);
|
|
216
|
+
// Reports itself as battery which is not correct: https://github.com/Koenkk/zigbee2mqtt/issues/6190
|
|
217
|
+
device.powerSource = 'Mains (single phase)';
|
|
218
|
+
device.save();
|
|
219
|
+
},
|
|
220
|
+
},
|
|
192
221
|
];
|
package/lib/constants.js
CHANGED
package/lib/zosung.js
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const exposes = require('./exposes');
|
|
4
|
+
const ea = exposes.access;
|
|
5
|
+
|
|
6
|
+
function nextSeq(entity) {
|
|
7
|
+
entity.seq = ((entity.seq || -1)+1) % 0x10000;
|
|
8
|
+
return entity.seq;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function messagesGet(entity, seq) {
|
|
12
|
+
const info = entity.irMessageInfo;
|
|
13
|
+
if (info.seq!=seq) {
|
|
14
|
+
throw new Error(`Unexpected sequence value (expected: ${info.seq} current: ${seq}).`);
|
|
15
|
+
}
|
|
16
|
+
return info.data;
|
|
17
|
+
}
|
|
18
|
+
function messagesSet(entity, seq, data) {
|
|
19
|
+
entity.irMessageInfo={seq: seq, data: data};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function messagesClear(entity, seq) {
|
|
23
|
+
const info = entity.irMessageInfo;
|
|
24
|
+
if (info.seq!=seq) {
|
|
25
|
+
throw new Error(`Unexpected sequence value (expected: ${info.seq} current: ${seq}).`);
|
|
26
|
+
}
|
|
27
|
+
delete entity.irMessageInfo;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function calcArrayCrc(values) {
|
|
31
|
+
return Array.from(values.values()).reduce((a, b)=>a+b)%0x100;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function calcStringCrc(str) {
|
|
35
|
+
return str.split('').map((x)=>x.charCodeAt(0)).reduce((a, b)=>a+b)%0x100;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
const fzZosung = {
|
|
40
|
+
zosung_send_ir_code_01: {
|
|
41
|
+
cluster: 'zosungIRTransmit',
|
|
42
|
+
type: ['commandZosungSendIRCode01'],
|
|
43
|
+
convert: (model, msg, publish, options, meta) => {
|
|
44
|
+
meta.logger.debug(`"IR-Message-Code01" received (msg:${JSON.stringify(msg.data)})`);
|
|
45
|
+
const seq = msg.data.seq;
|
|
46
|
+
const irMsg = messagesGet(msg.endpoint, seq);
|
|
47
|
+
meta.logger.debug(`IRCode to send: ${JSON.stringify(irMsg)} (seq:${seq})`);
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
zosung_send_ir_code_02: {
|
|
51
|
+
cluster: 'zosungIRTransmit',
|
|
52
|
+
type: ['commandZosungSendIRCode02'],
|
|
53
|
+
convert: async (model, msg, publish, options, meta) => {
|
|
54
|
+
meta.logger.debug(`"IR-Message-Code02" received (msg:${JSON.stringify(msg.data)})`);
|
|
55
|
+
const seq = msg.data.seq;
|
|
56
|
+
const position = msg.data.position;
|
|
57
|
+
const irMsg = messagesGet(msg.endpoint, seq);
|
|
58
|
+
const part = irMsg.substring(position, position+0x32);
|
|
59
|
+
const sum = calcStringCrc(part);
|
|
60
|
+
await msg.endpoint.command('zosungIRTransmit', 'zosungSendIRCode03',
|
|
61
|
+
{
|
|
62
|
+
zero: 0,
|
|
63
|
+
seq: seq,
|
|
64
|
+
position: position,
|
|
65
|
+
msgpart: Buffer.from(part),
|
|
66
|
+
msgpartcrc: sum,
|
|
67
|
+
},
|
|
68
|
+
{disableDefaultResponse: true});
|
|
69
|
+
meta.logger.debug(`Sent IRCode part: ${part} (sum: ${sum}, seq:${seq})`);
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
zosung_send_ir_code_04: {
|
|
73
|
+
cluster: 'zosungIRTransmit',
|
|
74
|
+
type: ['commandZosungSendIRCode04'],
|
|
75
|
+
convert: async (model, msg, publish, options, meta) => {
|
|
76
|
+
meta.logger.debug(`"IR-Message-Code04" received (msg:${JSON.stringify(msg.data)})`);
|
|
77
|
+
const seq = msg.data.seq;
|
|
78
|
+
await msg.endpoint.command('zosungIRTransmit', 'zosungSendIRCode05',
|
|
79
|
+
{
|
|
80
|
+
seq: seq,
|
|
81
|
+
zero: 0,
|
|
82
|
+
},
|
|
83
|
+
{disableDefaultResponse: true});
|
|
84
|
+
messagesClear(msg.endpoint, seq);
|
|
85
|
+
meta.logger.debug(`IRCode has been successfuly sent. (seq:${seq})`);
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
zosung_send_ir_code_00: {
|
|
89
|
+
cluster: 'zosungIRTransmit',
|
|
90
|
+
type: ['commandZosungSendIRCode00'],
|
|
91
|
+
convert: async (model, msg, publish, options, meta) => {
|
|
92
|
+
meta.logger.debug(`"IR-Message-Code00" received (msg:${JSON.stringify(msg.data)})`);
|
|
93
|
+
const seq = msg.data.seq;
|
|
94
|
+
const length = msg.data.length;
|
|
95
|
+
messagesSet(msg.endpoint, seq, {position: 0, buf: Buffer.alloc(length)});
|
|
96
|
+
await msg.endpoint.command('zosungIRTransmit', 'zosungSendIRCode01',
|
|
97
|
+
{
|
|
98
|
+
zero: 0,
|
|
99
|
+
seq: seq,
|
|
100
|
+
length: length,
|
|
101
|
+
unk1: msg.data.unk1,
|
|
102
|
+
unk2: msg.data.unk2,
|
|
103
|
+
unk3: msg.data.unk3,
|
|
104
|
+
cmd: msg.data.cmd,
|
|
105
|
+
unk4: msg.data.unk4,
|
|
106
|
+
},
|
|
107
|
+
{disableDefaultResponse: true});
|
|
108
|
+
meta.logger.debug(`"IR-Message-Code00" response sent.`);
|
|
109
|
+
await msg.endpoint.command('zosungIRTransmit', 'zosungSendIRCode02',
|
|
110
|
+
{
|
|
111
|
+
seq: msg.data.seq,
|
|
112
|
+
position: 0,
|
|
113
|
+
maxlen: 0x38,
|
|
114
|
+
},
|
|
115
|
+
{disableDefaultResponse: true});
|
|
116
|
+
meta.logger.debug(`"IR-Message-Code00" transfer started.`);
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
zosung_send_ir_code_03: {
|
|
120
|
+
cluster: 'zosungIRTransmit',
|
|
121
|
+
type: ['zosungSendIRCode03Resp'],
|
|
122
|
+
convert: async (model, msg, publish, options, meta) => {
|
|
123
|
+
meta.logger.debug(`"IR-Message-Code03" received (msg:${JSON.stringify(msg.data)})`);
|
|
124
|
+
const seq = msg.data.seq;
|
|
125
|
+
const rcv = messagesGet(msg.endpoint, seq);
|
|
126
|
+
if (rcv.position==msg.data.position) {
|
|
127
|
+
const rcvMsgPart = msg.data.msgpart;
|
|
128
|
+
const sum = calcArrayCrc(rcvMsgPart);
|
|
129
|
+
const expectedPartCrc = msg.data.msgpartcrc;
|
|
130
|
+
if (sum==expectedPartCrc) {
|
|
131
|
+
const position = rcvMsgPart.copy(rcv.buf, rcv.position);
|
|
132
|
+
rcv.position += position;
|
|
133
|
+
if (rcv.position<rcv.buf.length) {
|
|
134
|
+
await msg.endpoint.command('zosungIRTransmit', 'zosungSendIRCode02',
|
|
135
|
+
{
|
|
136
|
+
seq: seq,
|
|
137
|
+
position: rcv.position,
|
|
138
|
+
maxlen: 0x38,
|
|
139
|
+
},
|
|
140
|
+
{disableDefaultResponse: true});
|
|
141
|
+
} else {
|
|
142
|
+
await msg.endpoint.command('zosungIRTransmit', 'zosungSendIRCode04',
|
|
143
|
+
{
|
|
144
|
+
zero0: 0,
|
|
145
|
+
seq: seq,
|
|
146
|
+
zero1: 0,
|
|
147
|
+
},
|
|
148
|
+
{disableDefaultResponse: true});
|
|
149
|
+
}
|
|
150
|
+
meta.logger.debug(`${rcvMsgPart.length} bytes received.`);
|
|
151
|
+
} else {
|
|
152
|
+
meta.logger.error(`Invalid msg part CRC: ${sum} expecting: ${expectedPartCrc}.`);
|
|
153
|
+
}
|
|
154
|
+
} else {
|
|
155
|
+
meta.logger.error(`Unexpected IR code position: ${JSON.stringify(msg.data)}, expecting: ${rcv.position}.`);
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
zosung_send_ir_code_05: {
|
|
160
|
+
cluster: 'zosungIRTransmit',
|
|
161
|
+
type: ['zosungSendIRCode05Resp'],
|
|
162
|
+
convert: async (model, msg, publish, options, meta) => {
|
|
163
|
+
meta.logger.debug(`"IR-Message-Code05" received (msg:${JSON.stringify(msg.data)})`);
|
|
164
|
+
const seq = msg.data.seq;
|
|
165
|
+
const rcv = messagesGet(msg.endpoint, seq);
|
|
166
|
+
const learnedIRCode = rcv.buf.toString('base64');
|
|
167
|
+
meta.logger.debug(`Received: ${learnedIRCode}`);
|
|
168
|
+
messagesClear(msg.endpoint, seq);
|
|
169
|
+
await msg.endpoint.command('zosungIRControl', 'zosungControlIRCommand00',
|
|
170
|
+
{
|
|
171
|
+
data: Buffer.from(JSON.stringify({'study': 1})),
|
|
172
|
+
},
|
|
173
|
+
{disableDefaultResponse: true});
|
|
174
|
+
return {
|
|
175
|
+
learned_ir_code: learnedIRCode,
|
|
176
|
+
};
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const tzZosung = {
|
|
182
|
+
zosung_ir_code_to_send: {
|
|
183
|
+
key: ['ir_code_to_send'],
|
|
184
|
+
convertSet: async (entity, key, value, meta) => {
|
|
185
|
+
if (!value) {
|
|
186
|
+
meta.logger.error(`There is no IR code to send`);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const irMsg = JSON.stringify({
|
|
190
|
+
'key_num': 1,
|
|
191
|
+
'delay': 300,
|
|
192
|
+
'key1': {
|
|
193
|
+
'num': 1,
|
|
194
|
+
'freq': 38000,
|
|
195
|
+
'type': 1,
|
|
196
|
+
'key_code': value,
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
meta.logger.debug(`Sending IR code: ${JSON.stringify(value)}`);
|
|
200
|
+
const seq = nextSeq(entity);
|
|
201
|
+
messagesSet(entity, seq, irMsg);
|
|
202
|
+
await entity.command('zosungIRTransmit', 'zosungSendIRCode00',
|
|
203
|
+
{
|
|
204
|
+
seq: seq,
|
|
205
|
+
length: irMsg.length,
|
|
206
|
+
unk1: 0x00000000,
|
|
207
|
+
unk2: 0xe004,
|
|
208
|
+
unk3: 0x01,
|
|
209
|
+
cmd: 0x02,
|
|
210
|
+
unk4: 0x0000,
|
|
211
|
+
},
|
|
212
|
+
{disableDefaultResponse: true});
|
|
213
|
+
meta.logger.debug(`Sending IR code initiated.`);
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
zosung_learn_ir_code: {
|
|
217
|
+
key: ['learn_ir_code'],
|
|
218
|
+
convertSet: async (entity, key, value, meta) => {
|
|
219
|
+
meta.logger.debug(`Starting IR Code Learning...`);
|
|
220
|
+
await entity.command('zosungIRControl', 'zosungControlIRCommand00',
|
|
221
|
+
{
|
|
222
|
+
data: Buffer.from(JSON.stringify({'study': 0})),
|
|
223
|
+
},
|
|
224
|
+
{disableDefaultResponse: true});
|
|
225
|
+
meta.logger.debug(`IR Code Learning started.`);
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
const presetsZosung = {
|
|
232
|
+
learn_ir_code: () => exposes.switch().withState('learn_ir_code', false, 'Turn on to learn new IR code', ea.SET),
|
|
233
|
+
learned_ir_code: () => exposes.text('learned_ir_code', ea.STATE).withDescription('The IR code learned by device'),
|
|
234
|
+
ir_code_to_send: () => exposes.text('ir_code_to_send', ea.SET).withDescription('The IR code to send by device'),
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
module.exports = {
|
|
238
|
+
fzZosung,
|
|
239
|
+
tzZosung,
|
|
240
|
+
presetsZosung,
|
|
241
|
+
};
|