From 606242dc75a5e6b048fdf219030dc2fd6f585549 Mon Sep 17 00:00:00 2001 From: Lukas Drbal Date: Sat, 15 Oct 2022 22:54:00 +0200 Subject: [PATCH] Add support for subdevices connected to gateway Closes https://github.com/jasonacox/tinytuya/issues/221 --- tinytuya/core.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tinytuya/core.py b/tinytuya/core.py index 028bde50..aa40c50d 100644 --- a/tinytuya/core.py +++ b/tinytuya/core.py @@ -562,13 +562,14 @@ def device_info( dev_id ): class XenonDevice(object): def __init__( - self, dev_id, address=None, local_key="", dev_type="default", connection_timeout=5, version=3.1, persist=False + self, dev_id, address=None, local_key="", dev_type="default", connection_timeout=5, version=3.1, persist=False, dev_cid = None ): """ Represents a Tuya device. Args: dev_id (str): The device id. + dev_cid (str: Optional sub device id. Default to None. address (str): The network address. local_key (str, optional): The encryption key. Defaults to None. @@ -577,6 +578,7 @@ def __init__( """ self.id = dev_id + self.cid = dev_cid self.address = address self.connection_timeout = connection_timeout self.retry = True @@ -1259,6 +1261,8 @@ def generate_payload(self, command, data=None, gwId=None, devId=None, uid=None): json_data["uid"] = uid else: json_data["uid"] = self.id + if self.cid is not None: + json_data["cid"] = self.cid if "t" in json_data: if json_data['t'] == "int": json_data["t"] = int(time.time())