From 8f881b6c3564d2a602396627d40fde98961083ce Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Sat, 9 Feb 2019 01:20:53 +0100 Subject: [PATCH] Experimental support YRD426NRSC. https://github.com/Koenkk/zigbee2mqtt/issues/1032 --- converters/fromZigbee.js | 9 ++++++++- converters/toZigbee.js | 32 ++++++++++++++++++++++++++++++++ devices.js | 24 +++++++++++++++++++++++- 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/converters/fromZigbee.js b/converters/fromZigbee.js index 5d034774f5a79..7315439602a98 100644 --- a/converters/fromZigbee.js +++ b/converters/fromZigbee.js @@ -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', @@ -883,7 +890,7 @@ const converters = { }; }, }, - heiman_smoke_battery: { + battery_200: { cid: 'genPowerCfg', type: 'attReport', convert: (model, msg, publish, options) => { diff --git a/converters/toZigbee.js b/converters/toZigbee.js index 19150069e50c0..aa716db3eeb6d 100644 --- a/converters/toZigbee.js +++ b/converters/toZigbee.js @@ -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: { diff --git a/devices.js b/devices.js index cb0f8b59253a2..4e6146ed8b624 100644 --- a/devices.js +++ b/devices.js @@ -6,6 +6,7 @@ const tz = require('./converters/toZigbee'); const repInterval = { MAX: 58000, + HOUR: 3600, }; const generic = { @@ -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, ], @@ -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) =>