diff --git a/converters/fromZigbee.js b/converters/fromZigbee.js index 114d1fe1cc032..19b0f4c70b1a1 100644 --- a/converters/fromZigbee.js +++ b/converters/fromZigbee.js @@ -802,6 +802,8 @@ const converters = { convert: (model, msg, publish, options) => { if (msg.data.data['61440']) { return {state: msg.data.data['onOff'] === 1 ? 'ON' : 'OFF'}; + } else { + return {click: 'single'}; } }, }, @@ -815,6 +817,10 @@ const converters = { const payload = {}; payload[key] = msg.data.data['onOff'] === 1 ? 'ON' : 'OFF'; return payload; + } else { + const mapping = {4: 'left', 5: 'right', 6: 'both'}; + const button = mapping[msg.endpoints[0].epId]; + return {click: button}; } }, }, diff --git a/converters/toZigbee.js b/converters/toZigbee.js index bffd192ee50b0..e8db0a9afce6c 100644 --- a/converters/toZigbee.js +++ b/converters/toZigbee.js @@ -856,6 +856,52 @@ const converters = { } }, }, + xiaomi_decoupled_mode: { + key: ['decoupled_mode'], + convert: (key, value, message, type, postfix) => { + const cid = 'genBasic'; + const lookupAttrId = { + 'single': 0xFF22, + 'left': 0xFF22, + 'right': 0xFF23, + }; + const lookupState = { + 'decoupled': 0xFE, + 'toggle_left': 0x12, + 'toggle_right': 0x22, + }; + let button; + if (value.hasOwnProperty('button')) { + button = value.button; + } else { + button = 'single'; + } + if (type === 'set') { + return { + cid: cid, + cmd: 'write', + cmdType: 'foundation', + zclData: [{ + attrId: lookupAttrId[button], + dataType: 0x20, + attrData: lookupState[value.state], + }], + cfg: cfg.xiaomi, + }; + } else if (type === 'get') { + return { + cid: cid, + cmd: 'read', + cmdType: 'foundation', + zclData: [{ + attrId: lookupAttrId[button], + dataType: 0x20, + }], + cfg: cfg.xiaomi, + }; + } + }, + }, STS_PRS_251_beep: { key: ['beep'], convert: (key, value, message, type, postfix) => { diff --git a/devices.js b/devices.js index 4043f15b2af4e..c6db30f166378 100644 --- a/devices.js +++ b/devices.js @@ -212,9 +212,9 @@ const devices = [ fromZigbee: [ fz.QBKG04LM_QBKG11LM_state, fz.ignore_onoff_change, fz.ignore_basic_change, fz.ignore_basic_report, ], - toZigbee: [tz.on_off], + toZigbee: [tz.on_off, tz.xiaomi_decoupled_mode], ep: (device) => { - return {'': 2}; + return {'system': 1, 'default': 2}; }, }, { @@ -238,9 +238,9 @@ const devices = [ fromZigbee: [ fz.QBKG03LM_QBKG12LM_state, fz.QBKG03LM_buttons, fz.ignore_basic_change, fz.ignore_basic_report, ], - toZigbee: [tz.on_off], + toZigbee: [tz.on_off, tz.xiaomi_decoupled_mode], ep: (device) => { - return {'left': 2, 'right': 3}; + return {'system': 1, 'left': 2, 'right': 3}; }, }, {