Skip to content

Commit

Permalink
Add JS-MC-SENSOR-ZB & fix the status of JAVIS lock (#3325)
Browse files Browse the repository at this point in the history
* supported javis microwave sensor

* format code

* update javis microwave sensor

* fix fomat code

* format code

* Update javis.js

* Update javis.js

Co-authored-by: TheEnd98 <49032426+TheEnd98@users.noreply.github.com>
Co-authored-by: Chinh Nguyen <dinhchinh@gmail.com>
Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
  • Loading branch information
4 people committed Nov 11, 2021
1 parent 141a5d8 commit 012f07c
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 1 deletion.
76 changes: 76 additions & 0 deletions converters/fromZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -5962,6 +5962,11 @@ const converters = {
};

const data = utf8FromStr(msg['data']['16896']);

clearTimeout(globalStore.getValue(msg.endpoint, 'timer'));
const timer = setTimeout(() => publish({action: 'lock', state: 'LOCK'}), 2 * 1000);
globalStore.putValue(msg.endpoint, 'timer', timer);

return {
action: 'unlock',
action_user: data[3],
Expand All @@ -5970,6 +5975,77 @@ const converters = {
};
},
},
javis_microwave_sensor: {
cluster: 'manuSpecificTuya',
type: ['commandSetDataResponse', 'commandGetData'],
convert: (model, msg, publish, options, meta) => {
const dp = msg.data.dp;
const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
const lookup = {
0: 'no_motion',
1: 'big_motion',
2: 'minor_motion',
3: 'breathing',
4: 'abnormal_state',
5: 'initializing',
6: 'initialization_completed',
};
switch (dp) {
case 1:
return {
states: lookup[value],
occupancy: (0 < value && value < 5) ? true: false,
};
case 2:
return {
sensitivity: value,
};
case 101:
return {
illuminance_lux: value,
};
case 102:
if (meta.device.manufacturerName === '_TZE200_kagkgk0i') {
return {
illuminance_calibration: value,
};
} else {
return {
keep_time: value,
};
}
case 103:
return {
led_enable: value == 1 ? true : false,
};
case 104:
return {illuminance_lux: value};
case 105:
return {
illuminance_calibration: value,
};
case 106:
if (meta.device.manufacturerName === '_TZE200_kagkgk0i') {
return {
keep_time: value,
};
} else {
break;
}
case 107:
if (meta.device.manufacturerName === '_TZE200_kagkgk0i') {
return {
led_enable: value == 1 ? true : false,
};
} else {
break;
}
default:
meta.logger.warn(`zigbee-herdsman-converters:javis_microwave_sensor: NOT RECOGNIZED ` +
`DP #${dp} with data ${JSON.stringify(msg.data)}`);
}
},
},
diyruz_freepad_config: {
cluster: 'genOnOffSwitchCfg',
type: ['readResponse'],
Expand Down
40 changes: 40 additions & 0 deletions converters/toZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -6108,6 +6108,46 @@ const converters = {
}
},
},
javis_microwave_sensor: {
key: [
'illuminance_calibration', 'led_enable',
'sensitivity', 'keep_time',
],
convertSet: async (entity, key, value, meta) => {
switch (key) {
case 'illuminance_calibration':// (10--100) sensor illuminance sensitivity
if (meta.device.manufacturerName === '_TZE200_kagkgk0i') {
await tuya.sendDataPointRaw(entity, 102, [value]);
break;
} else {
tuya.sendDataPointRaw(entity, 105, [value]);
break;
}
case 'led_enable':// OK (value true/false or 1/0)
if (meta.device.manufacturerName === '_TZE200_kagkgk0i') {
await tuya.sendDataPointRaw(entity, 107, [value ? 1 : 0]);
break;
} else {
await tuya.sendDataPointRaw(entity, 103, [value ? 1 : 0]);
break;
}

case 'sensitivity':// value: 25, 50, 75, 100
await tuya.sendDataPointRaw(entity, 2, [value]);
break;
case 'keep_time': // value 0 --> 7 corresponding 5s, 30s, 1, 3, 5, 10, 20, 30 min
if (meta.device.manufacturerName === '_TZE200_kagkgk0i') {
await tuya.sendDataPointRaw(entity, 106, [value]);
break;
} else {
await tuya.sendDataPointRaw(entity, 102, [value]);
break;
}
default: // Unknown key
throw new Error(`Unhandled key ${key}`);
}
},
},
moes_thermostat_tv: {
key: [
'system_mode', 'window_detection', 'frost_detection', 'child_lock',
Expand Down
22 changes: 21 additions & 1 deletion devices/javis.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
const exposes = require('../lib/exposes');
const fz = {...require('../converters/fromZigbee'), legacy: require('../lib/legacy').fromZigbee};
const tz = require('../converters/toZigbee');
const e = exposes.presets;
const ea = exposes.access;

module.exports = [
{
zigbeeModel: ['JAVISLOCK'],
fingerprint: [{modelID: 'doorlock_5001', manufacturerName: 'Lmiot'}],
fingerprint: [{modelID: 'doorlock_5001', manufacturerName: 'Lmiot'},
{modelID: 'E321V000A03', manufacturerName: 'Vensi'}],
model: 'JS-SLK2-ZB',
vendor: 'JAVIS',
description: 'Intelligent biometric digital lock',
fromZigbee: [fz.javis_lock_report, fz.battery],
toZigbee: [],
exposes: [e.battery(), e.action(['unlock'])],
},
{
zigbeeModel: ['JAVISSENSOR'],
fingerprint: [{modelID: 'TS0601', manufacturerName: '_TZE200_lgstepha'},
{modelID: 'TS0601', manufacturerName: '_TZE200_kagkgk0i'},
{modelID: 'TS0601', manufacturerName: '_TZE200_i0b1dbqu'}],
model: 'JS-MC-SENSOR-ZB',
vendor: 'JAVIS',
description: 'Microwave sensor',
fromZigbee: [fz.javis_microwave_sensor, fz.ignore_basic_report],
toZigbee: [tz.javis_microwave_sensor],
exposes: [e.occupancy(), e.illuminance_lux(),
exposes.binary('led_enable', ea.STATE_SET, true, false).withDescription('Enabled LED'),
exposes.enum('keep_time', ea.STATE_SET, ['0', '1', '2', '3', '4', '5', '6', '7'])
.withDescription('PIR keep time 0:5s|1:30s|2:60s|3:180s|4:300s|5:600s|6:1200s|7:1800s'),
exposes.enum('sensitivity', ea.STATE_SET, ['25', '50', '75', '100']),
exposes.numeric('illuminance_calibration', ea.STATE_SET).withDescription('Illuminance calibration')],
},
];

0 comments on commit 012f07c

Please sign in to comment.