Skip to content

Commit

Permalink
Merge pull request #58 from doudz/dev
Browse files Browse the repository at this point in the history
Fix manufacturer code in *_attribute_request
  • Loading branch information
doudz committed Dec 20, 2018
2 parents 0e200fb + 1971df6 commit 5cfb24d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 12 additions & 9 deletions zigate/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ def identify_trigger_effect(self, addr, endpoint, effect="blink"):
return self.send_data(0x00E0, data)

def read_attribute_request(self, addr, endpoint, cluster, attribute,
direction=0, manufacturer_specific=0, manufacturer_id=0):
direction=0, manufacturer_code=0):
'''
Read Attribute request
attribute can be a unique int or a list of int
Expand All @@ -1212,13 +1212,14 @@ def read_attribute_request(self, addr, endpoint, cluster, attribute,
if not isinstance(attribute, list):
attribute = [attribute]
length = len(attribute)
manufacturer_specific = manufacturer_code != 0
data = struct.pack('!BHBBHBBHB{}H'.format(length), 2, addr, 1, endpoint, cluster,
direction, manufacturer_specific,
manufacturer_id, length, *attribute)
manufacturer_code, length, *attribute)
self.send_data(0x0100, data)

def write_attribute_request(self, addr, endpoint, cluster, attributes,
direction=0, manufacturer_specific=0, manufacturer_id=0):
direction=0, manufacturer_code=0):
'''
Write Attribute request
attribute could be a tuple of (attribute_id, attribute_type, data)
Expand All @@ -1234,14 +1235,15 @@ def write_attribute_request(self, addr, endpoint, cluster, attributes,
fmt += 'HB' + data_type
attributes_data += attribute_tuple
length = len(attributes)
manufacturer_specific = manufacturer_code != 0
data = struct.pack('!BHBBHBBHB{}'.format(fmt), 2, addr, 1,
endpoint, cluster,
direction, manufacturer_specific,
manufacturer_id, length, *attributes_data)
manufacturer_code, length, *attributes_data)
self.send_data(0x0110, data)

def reporting_request(self, addr, endpoint, cluster, attribute, attribute_type,
direction=0, manufacturer_specific=0, manufacturer_id=0):
direction=0, manufacturer_code=0):
'''
Configure reporting request
for now support only one attribute
Expand All @@ -1258,9 +1260,10 @@ def reporting_request(self, addr, endpoint, cluster, attribute, attribute_type,
max_interval = 0
timeout = 0
change = 0
manufacturer_specific = manufacturer_code != 0
data = struct.pack('!BHBBHBBHBBBHHHHB', 2, addr, 1, endpoint, cluster,
direction, manufacturer_specific,
manufacturer_id, length, attribute_direction,
manufacturer_code, length, attribute_direction,
attribute_type, attribute_id, min_interval,
max_interval, timeout, change)
self.send_data(0x0120, data, 0x8120)
Expand Down Expand Up @@ -1470,15 +1473,15 @@ def ota_image_notify(self, addr, destination_endpoint=0x01, payload_type=0):
self.send_data(0x0505, data)

def attribute_discovery_request(self, addr, endpoint, cluster,
direction=0, manufacturer_specific=0,
manufacturer_id=0):
direction=0, manufacturer_code=0):
'''
Attribute discovery request
'''
addr = self.__addr(addr)
manufacturer_specific = manufacturer_code != 0
data = struct.pack('!BHBBHHBBHB', 2, addr, 1, endpoint, cluster,
0, direction, manufacturer_specific,
manufacturer_id, 255)
manufacturer_code, 255)
self.send_data(0x0140, data)

def available_actions(self, addr, endpoint=None):
Expand Down
2 changes: 1 addition & 1 deletion zigate/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# file that was distributed with this source code.
#

__version__ = '0.24.0'
__version__ = '0.24.1'

0 comments on commit 5cfb24d

Please sign in to comment.