Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.7.0 #84

Open
wants to merge 3 commits into
base: 3.7.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions custom_components/localtuya/pytuya/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ class DecodeError(Exception):
COMMAND_OVERRIDE = "command_override"



# Tuya Device Dictionary - Command and Payload Overrides
#
# 'default' / 'type_0a' devices require the 0a command for the DP_QUERY request
Expand Down Expand Up @@ -424,6 +423,7 @@ def unpack_message(data, hmac_key=None, header=None, no_retcode=False, logger=No
header.seqno, header.cmd, retcode, payload[:-end_len], crc, crc == have_crc
)


def parse_header(data):
"""Unpack bytes into a TuyaHeader."""
header_len = struct.calcsize(MESSAGE_HEADER_FMT)
Expand Down Expand Up @@ -1363,8 +1363,13 @@ def _merge_payload_dicts(dict1, dict2):
# for Zigbee gateways, cid specifies the sub-device
json_data[PARAMETER_CID] = cid
if PARAMETER_DATA in json_data:
json_data[PARAMETER_DATA][PARAMETER_DATA] = cid
json_data[PARAMETER_DATA][PARAMETER_CID] = cid
json_data[PARAMETER_DATA]["ctype"] = 0
# remove all ids except cid for subdevices (needs better fix to payload def)
if command == CONTROL:
for k in ["gwId", "devId", "uid"]:
if k in json_data:
json_data.pop(k)
if PARAMETER_T in json_data:
if json_data[PARAMETER_T] == "int":
json_data[PARAMETER_T] = int(time.time())
Expand All @@ -1375,9 +1380,7 @@ def _merge_payload_dicts(dict1, dict2):
if PARAMETER_DP_ID in json_data:
json_data[PARAMETER_DP_ID] = data
elif PARAMETER_DATA in json_data:
json_data[PARAMETER_DATA] = {PROPERTY_DPS: data}
if cid is not None:
json_data[PARAMETER_DATA][PARAMETER_CID] = cid
json_data[PARAMETER_DATA][PROPERTY_DPS] = data
else:
json_data[PROPERTY_DPS] = data
elif command == CONTROL_NEW:
Expand Down