diff --git a/lib/converters/zigbee2mqtt.js b/lib/converters/zigbee2mqtt.js index 0201128c..ba8a077f 100644 --- a/lib/converters/zigbee2mqtt.js +++ b/lib/converters/zigbee2mqtt.js @@ -94,6 +94,89 @@ const parsers = [ type: 'attReport', convert: (msg) => {return {temperature: parseFloat(msg.data.data['measuredValue']) / 100.0}} }, + { + devices: ['MFKZQ01LM'], + cid: 'genMultistateInput', + type: 'attReport', + convert: (msg) => { + /* + +---+ + | 2 | + +---+---+---+ + | 4 | 0 | 1 | + +---+---+---+ + |M5I| + +---+ + | 3 | + +---+ + Side 5 is with the MI logo, side 3 contains the battery door. + presentValue = 0 = shake + presentValue = 2 = wakeup + presentValue = 3 = fly/fall + presentValue = y + x * 8 + 64 = 90º Flip from side x on top to side y on top + presentValue = x + 128 = 180º flip to side x on top + presentValue = x + 256 = push/slide cube while side x is on top + presentValue = x + 512 = double tap while side x is on top + */ + var v = msg.data.data['presentValue']; + switch (true) { + case (v == 0): + return {cube_action: 'shake'} + break; + case (v == 2): + return {cube_action: 'wakeup'} + break; + case (v == 3): + return {cube_action: 'fall'} + break; + case (v >= 512): // double tap + return {cube_action: 'tap'} + break; + case (v >= 256): // slide + return {cube_action: 'slide'} + break; + case (v >= 128): // 180 flip + return {cube_action: 'flip180'} + break; + case (v >= 64): // 90 flip + return {cube_action: 'flip90'} + break; + } + } + }, + { + devices: ['MFKZQ01LM'], + cid: 'genMultistateInput', + type: 'devChange', + convert: () => null + }, + { + devices: ['MFKZQ01LM'], + cid: 'genAnalogInput', + type: 'attReport', + convert: (msg) => { + /* + 65285: 500, presentValue = rotation angel left < 0, rigth > 0 + 65285: 360, presentValue = ? angel + 65285: 110, presentValue = ? angel + 65285: 420, presentValue = ? angel + 65285: 320, presentValue = ? angel + 65285: 330, presentValue = ? angel + */ + var v = msg.data.data['presentValue']; + if (v < 0) { + return {cube_action: 'rotate', direction: 'left'} + } else { + return {cube_action: 'rotate', direction: 'right'} + } + } + }, + { + devices: ['MFKZQ01LM'], + cid: 'genAnalogInput', + type: 'devChange', + convert: () => null + }, { devices: ['WSDCGQ01LM', 'WSDCGQ11LM'], cid: 'msRelativeHumidity', diff --git a/lib/devices.js b/lib/devices.js index 344edf58..b76151e8 100644 --- a/lib/devices.js +++ b/lib/devices.js @@ -95,6 +95,12 @@ const devices = { supports: 'water leak true/false', homeassistant: [homeassistant.binary_sensor_water_leak] }, + 'lumi.sensor_cube': { + model: 'MFKZQ01LM', + vendor: 'Xiaomi', + description: 'MiJia Smart Home Cube', + homeassistant: [homeassistant.sensor_button] + }, 'lumi.plug': { model: 'ZNCZ02LM', description: 'Mi power plug ZigBee',