From c8df9747ad40aadf47e8a6181b543239390dacc3 Mon Sep 17 00:00:00 2001 From: Koenkk Date: Tue, 8 May 2018 20:21:41 +0200 Subject: [PATCH] Refactor MFKZQ01LM converters to use homeassistant.sensor_action --- lib/converters/zigbee2mqtt.js | 20 ++++++++++---------- lib/devices.js | 5 +++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/converters/zigbee2mqtt.js b/lib/converters/zigbee2mqtt.js index 04b857a7..cff813ab 100644 --- a/lib/converters/zigbee2mqtt.js +++ b/lib/converters/zigbee2mqtt.js @@ -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'} } } }, diff --git a/lib/devices.js b/lib/devices.js index b76151e8..8ee7de30 100644 --- a/lib/devices.js +++ b/lib/devices.js @@ -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',