Added xiaomi cube

This commit is contained in:
Marius Ciotlos 2018-05-07 22:40:38 +03:00
parent 080feddf28
commit 50103e381c
2 changed files with 89 additions and 0 deletions

View File

@ -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',

View File

@ -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',