Skip to content

Commit

Permalink
Experimental support YRD426NRSC. Koenkk/zigbee2mqtt#1032
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Feb 9, 2019
1 parent 5db7531 commit 8f881b6
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
9 changes: 8 additions & 1 deletion converters/fromZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ const holdUpdateBrightness324131092621 = (deviceID) => {


const converters = {
YRD426NRSC_lock: {
cid: 'closuresDoorLock',
type: 'attReport',
convert: (model, msg, publish, options) => {
return {state: msg.data.data.lockState === 2 ? 'UNLOCK' : 'LOCK'};
},
},
AC0251100NJ_on: {
cid: 'genOnOff',
type: 'cmdOn',
Expand Down Expand Up @@ -883,7 +890,7 @@ const converters = {
};
},
},
heiman_smoke_battery: {
battery_200: {
cid: 'genPowerCfg',
type: 'attReport',
convert: (model, msg, publish, options) => {
Expand Down
32 changes: 32 additions & 0 deletions converters/toZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,38 @@ const converters = {
}
},
},
YRD426NRSC_lock: {
key: ['state'],
convert: (key, value, message, type, postfix) => {
const cid = 'closuresDoorLock';
const attrId = 'lockState';

if (type === 'set') {
if (typeof value !== 'string') {
return;
}

return {
cid: cid,
cmd: `${value.toLowerCase()}Door`,
cmdType: 'functional',
zclData: {
'pincodevalue': '',
},
cfg: cfg.default,
readAfterWriteTime: 200,
};
} else if (type === 'get') {
return {
cid: cid,
cmd: 'read',
cmdType: 'foundation',
zclData: [{attrId: zclId.attr(cid, attrId).value}],
cfg: cfg.default,
};
}
},
},

// Ignore converters
ignore_transition: {
Expand Down
24 changes: 23 additions & 1 deletion devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const tz = require('./converters/toZigbee');

const repInterval = {
MAX: 58000,
HOUR: 3600,
};

const generic = {
Expand Down Expand Up @@ -2085,7 +2086,7 @@ const devices = [
supports: 'smoke',
fromZigbee: [
fz.heiman_smoke,
fz.heiman_smoke_battery,
fz.battery_200,
fz.heiman_smoke_enrolled,
fz.ignore_power_change,
],
Expand Down Expand Up @@ -2437,6 +2438,27 @@ const devices = [
description: 'LED E14/230V C35 5W TB 440LM ZIGBEE DIM',
extend: generic.light_onoff_brightness,
},

// Yale
{
zigbeeModel: ['YRD446 BLE TSDB'],
model: 'YRD426NRSC',
vendor: 'Yale',
description: 'Assure lock',
supports: 'lock/unlock, battery',
fromZigbee: [fz.YRD426NRSC_lock, fz.battery_200],
toZigbee: [tz.YRD426NRSC_lock],
configure: (ieeeAddr, shepherd, coordinator, callback) => {
const device = shepherd.find(ieeeAddr, 1);

const actions = [
(cb) => device.report('closuresDoorLock', 'lockState', 0, repInterval.HOUR, 0, cb),
(cb) => device.report('genPowerCfg', 'batteryPercentageRemaining', 0, repInterval.MAX, 0, cb),
];

execute(device, actions, callback);
},
},
];

module.exports = devices.map((device) =>
Expand Down

0 comments on commit 8f881b6

Please sign in to comment.