Skip to content

Commit

Permalink
Added handling for illuminance measurement cluster (0x0400)
Browse files Browse the repository at this point in the history
  • Loading branch information
ISO-B committed Feb 22, 2018
1 parent 54bc898 commit 0186c7f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
36 changes: 36 additions & 0 deletions pyzigate/attributes_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,42 @@ def interpret_attributes(self, msg_data):
ZGT_LOG.info(' * Rotated: {}°'. format(int(hexlify(attribute_data), 16)))
elif hexlify(attribute_data) == b'0103':
ZGT_LOG.info(' * Sliding')
# Illuminance Measurement
elif cluster_id == b'0400':
# MeasuredValue
if attribute_id == b'0000':
illuminance = int.from_bytes(attribute_data, 'big', signed=True)
self.set_device_property(device_addr, endpoint, ZGT_ILLUMINANCE_MEASUREMENT, illuminance)
# MinMeasuredValue
elif attribute_id == b'0001':
if attribute_data == b'FFFF':
ZGT_LOG.info('Minimum illuminance is unused.')
else:
illuminance = int.from_bytes(attribute_data, 'big', signed=True)
ZGT_LOG.info('Minimum illuminance is ', illuminance)
# MaxMeasuredValue
elif attribute_id == b'0002':
if attribute_data == b'FFFF':
ZGT_LOG.info('Maximum illuminance is unused.')
else:
illuminance = int.from_bytes(attribute_data, 'big', signed=True)
ZGT_LOG.info('Maximum illuminance is ', illuminance)
# Tolerance
elif attribute_id == b'0003':
illuminance = int.from_bytes(attribute_data, 'big', signed=True)
ZGT_LOG.info('Illuminance tolerance is ', illuminance)
# Sensor type
elif attribute_id == b'0004':
sensor_type = 'Unknown'
if attribute_data == b'00':
sensor_type = 'Photodiode'
elif attribute_data == b'01':
sensor_type = 'CMOS'
elif b'02' <= attribute_data <= b'3F':
sensor_type = 'Reserved'
elif b'40' <= attribute_data <= b'FE':
sensor_type = 'Reserved for manufacturer'
ZGT_LOG.info('Sensor type is: ', sensor_type)
# Temperature
elif cluster_id == b'0402':
temperature = int.from_bytes(attribute_data, 'big', signed=True) / 100
Expand Down
1 change: 1 addition & 0 deletions pyzigate/zgt_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
ZGT_DETAILED_PRESSURE = 'detailed pressure'
ZGT_HUMIDITY = 'humidity'
ZGT_LAST_SEEN = 'last seen'
ZGT_ILLUMINANCE_MEASUREMENT = 'illuminance'
ZGT_EVENT = 'event'
ZGT_EVENT_PRESENCE = 'presence detected'
ZGT_STATE = 'state'
Expand Down

0 comments on commit 0186c7f

Please sign in to comment.