Refactor MFKZQ01LM converters to use homeassistant.sensor_action

This commit is contained in:
Koenkk
2018-05-10 11:34:56 +03:00
committed by Marius Ciotlos
parent b41cacd992
commit c8df9747ad
2 changed files with 13 additions and 12 deletions
+10 -10
View File
@@ -112,7 +112,7 @@ const parsers = [
+---+
Side 5 is with the MI logo, side 3 contains the battery door.
presentValue = 0 = shake
presentValue = 2 = wakeup
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
@@ -122,25 +122,25 @@ const parsers = [
var v = msg.data.data['presentValue'];
switch (true) {
case (v == 0):
return {cube_action: 'shake'}
return {action: 'shake'}
break;
case (v == 2):
return {cube_action: 'wakeup'}
return {action: 'wakeup'}
break;
case (v == 3):
return {cube_action: 'fall'}
return {action: 'fall'}
break;
case (v >= 512): // double tap
return {cube_action: 'tap'}
return {action: 'tap'}
break;
case (v >= 256): // slide
return {cube_action: 'slide'}
return {action: 'slide'}
break;
case (v >= 128): // 180 flip
return {cube_action: 'flip180'}
return {action: 'flip180'}
break;
case (v >= 64): // 90 flip
return {cube_action: 'flip90'}
return {action: 'flip90'}
break;
}
}
@@ -162,9 +162,9 @@ const parsers = [
*/
var v = msg.data.data['presentValue'];
if (v < 0) {
return {cube_action: 'rotate', direction: 'left'}
return {action: 'rotate_left'}
} else {
return {cube_action: 'rotate', direction: 'right'}
return {action: 'rotate_right'}
}
}
},
+3 -2
View File
@@ -98,8 +98,9 @@ const devices = {
'lumi.sensor_cube': {
model: 'MFKZQ01LM',
vendor: 'Xiaomi',
description: 'MiJia Smart Home Cube',
homeassistant: [homeassistant.sensor_button]
description: 'Mi smart home cube',
supports: 'TODO',
homeassistant: [homeassistant.sensor_action]
},
'lumi.plug': {
model: 'ZNCZ02LM',