DISCLAIMER
Please note that all content presented on this page is provided by Tuya (HK) Limited. Alibaba Cloud makes no representations and warranties, explicit or implied, as to the authenticity or accuracy of any such content, nor makes any guarantee to the condition, quality, durability, performance, reliability, merchantability or fitness for a particular purpose, or non-infringement of any products and/or services made available by Tuya (HK) Limited.
Call this operation to add device topological relationships in batches.
Instructions for use
A single call can add up to 10 sub-devices to a gateway.
The interface caller must be the Owner of the Gateway.
If the incoming sub-device has a topological relationship, the original gateway of the sub-device is replaced with the current gateway.
When the topology relationship between any sub-device and the Gateway fails to be established, the system rolls back and all the incoming sub-devices fail to establish the topology relationship with the current gateway.
If you call this interface to add the topological relationship between a gateway and a sub-device, the topology relationship between the Gateway and the sub-device will be added through the Topic:
/sys/${productKey}/${deviceName}/thing/topo/change notify the gateway.
Request Parameters
Name | Type | Required | Sample Values | Description |
Action | String | Yes | BatchAddThingTopo | System defined parameters. Value: BatchAddThingTopo. |
GwDeviceName | String | Yes | Gateway | The name of the gateway device. |
GwProductKey | String | Yes | A1vL7cp * * * * | The ProductKey of the product to which the gateway device belongs. |
TopoAddItem.N.DeviceName | String | Yes | Light | The name of the sub-device to access the gateway. |
TopoAddItem.N.ProductKey | String | Yes | A1BwAGV * * * * | The ProductKey of the sub-device to be connected to the Gateway. |
TopoAddItem.N.Sign | String | Yes | next * * * * | Add the signature of the topological relationship. According to the signature calculation method SignMethod(deviceSecret,content) , the calculated result is used as the value of Sign. Among them, content is the result of sorting all sub-device parameters (except Sign and SignMethod) submitted to the server in ascending alphabetical order (without splice symbols). For example, if the passed-in device parameter is ClientId = 868575026974305, DeviceName = 868575026974305, ProductKey = a1PB5fp1234, SignMethod = hmacmd5, timestamp = 1646277090411, and deviceSecret = 1234 then the signature is calculated hmacmd5(1234) ; The signature is calculated kan . |
TopoAddItem.N.SignMethod | String | Yes | HmacMd5 | The signature method. Support hmacSha1 , hmacSha256 , hmacMd5 . |
TopoAddItem.N.Timestamp | String | No | 1579335899000 | UTC timestamp. Not required. |
TopoAddItem.N.ClientID | String | No | A1BwAGV **** device1 | The device ID. You can use the SN code or MAC address of the device. Not required parameter. |
Note: When calling an API, in addition to the API-specific request parameters described in this topic, you must also pass in the common request parameters. For more information about common request parameters, see Common parameters.
Return data
Name | Type | Sample Values | Description |
Code | String | Iot.system.SystemException | The error code returned when the call fails. For more information, see Error codes. |
ErrorMessage | String | System exception | Error information returned when the call fails. |
RequestID | String | E55E50B7-40EE-4B6B-8BBE-D3ED55CCF565 | The unique identifier generated for this request. |
Success | Boolean | True | Indicates whether the call succeeded. ●True : The call succeeded. ●False : The call failed. |
Example
Request Example
curl 'https://si-d6e8d812acb848958054.tuyacloud.com:8686/?Action=BatchAddThingTopo&GwProductKey=k1ymv1DuLfE&GwDeviceName=myTestDevice&SignatureNonce=cd890a9c7af147e3932f4ea0c100329a&TopoAddItem.1.ProductKey=k1ymv5ZxdaN&AccessKeyId=xMr9wgwXQLhv5AUa65o0****&TopoAddItem.1.SignMethod=hmacSha1&TopoAddItem.1.DeviceName=53a23b050706&TopoAddItem.1.Sign=e9551310ab7c8c32f876df919247eda3c18ba550&SignatureMethod=HMAC-SHA1&Timestamp=2024-11-19T08%3A59%3A50Z&Signature=8yATgT7GBO9LqAZR6psY4vUw07E%3D'Normal Return Example
{
"RequestId": "2E19BDAF-0FD0-4608-9F41-82D230CFEE38",
"Success": true
}