Skip to content

Commit

Permalink
fix lumi cube's rotation issue
Browse files Browse the repository at this point in the history
Signed-off-by: SchumyHao <[email protected]>
  • Loading branch information
schumyhaojl committed Mar 17, 2018
1 parent 0186c7f commit a22d5d1
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions pyzigate/attributes_helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#! /usr/bin/python3
import logging
from struct import unpack
from binascii import hexlify, unhexlify
from collections import OrderedDict
from time import strftime
Expand Down Expand Up @@ -73,16 +74,38 @@ def interpret_attributes(self, msg_data):
ZGT_LOG.info(' * Pressed: {} times'.format(clicks))
# Movement
elif cluster_id == b'000c': # Unknown cluster id
ZGT_LOG.info(' * Rotation horizontal')
if attribute_id == b'ff05':
if hexlify(attribute_data) == b'01f4':
ZGT_LOG.info(' * Rotation horizontal')
elif attribute_id == b'0055':
ZGT_LOG.info(' * Rotated: %s°' % (unpack('!f', attribute_data)[0]))
elif cluster_id == b'0012': # Unknown cluster id
if attribute_id == b'0055':
if hexlify(attribute_data) == b'0000':
ZGT_LOG.info(' * Shaking')
elif hexlify(attribute_data) == b'0055':
ZGT_LOG.info(' * Rotating vertical')
ZGT_LOG.info(' * Rotated: {}°'. format(int(hexlify(attribute_data), 16)))
elif hexlify(attribute_data) == b'0103':
elif hexlify(attribute_data) in [b'0100', b'0101', b'0102', b'0103', b'0104', b'0105']:
ZGT_LOG.info(' * Sliding')
else:
ZGT_LOG.info(' * Rotating vertical')
if hexlify(attribute_data) in [b'0050', b'0042',
b'0044', b'0060',
b'0045', b'0068',
b'0041', b'0048',

b'0063', b'005c',
b'0059', b'004b',
b'005d', b'006b',
b'005a', b'0053',

b'004a', b'0051',
b'0054', b'0062',
b'0069', b'004d',
b'006c', b'0065',]:
ZGT_LOG.info(' * Rotated: 90°')
if hexlify(attribute_data) in [b'0080', b'0083',
b'0081', b'0084',
b'0085', b'0082',]:
ZGT_LOG.info(' * Rotated: 180°')
# Illuminance Measurement
elif cluster_id == b'0400':
# MeasuredValue
Expand Down

0 comments on commit a22d5d1

Please sign in to comment.