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.
Sub-equipment can be uploaded and uploaded one by one or in batches. Before the sub-device goes online, you need to register the identity of the sub-device on IoT Platform and establish the topological relationship between the sub-device and the gateway. When a sub-device goes online, IoT Platform verifies the identity of the sub-device based on the topology to determine whether the sub-device is capable of using the Gateway channel.
Description ●For sub-device offline and batch offline messages, only QoS = 0 is supported, but QoS = 1 is not supported. ●Under a gateway, the number of sub-devices online at the same time cannot exceed 1000. After the number of online sub-devices reaches 1000, the new sub-device online request will be rejected. ●When sending a batch of sub-device online/offline requests, the number of sub-devices in a single batch cannot exceed 50. ●The result of the batch offline request for the device is all successful or all failed, and data the response parameters contain specific device information.
Sub-device online
Data Uplink:
Request Topic: /ext/session/${productKey}/${deviceName}/combine/login
Response Topic:/ext/session/${productKey}/${deviceName}/combine/login_reply
Description Because sub-devices communicate with IoT platform through gateway channels, the preceding topics are the topics of the gateway devices. Variables in Topic ${productKey} and ${deviceName} replace with the corresponding information of the gateway device.
Request data format:
{
"id": "123",
"params": {
"productKey": "al12345****",
"deviceName": "device1234",
"clientId": "al12345****&device1234",
"timestamp": "1581417203000",
"signMethod": "hmacmd5",
"sign": "9B9C732412A4F84B981E1AB97CAB****",
"cleanSession": "true"
}
}Description In the message body, the parameter productKey and deviceName is the corresponding information of the sub-device.
Parameter description:
Parameters | Type | Description |
ID | String | Message ID number. A number of the String type. The value range is from 0 to 4294967295, and each message ID is unique in the current device. |
Params | Object | The input parameters of the request. See the following table params. |
params parameter description:
Parameters | Type | Description |
DeviceName | String | The device name of the sub-device. |
ProductKey | String | The ProductKey of the product to which the sub-device belongs. |
Sign | String | Child device signature. The signature method is the same as the directly connected device signature method. Signature method: 1 All parameters submitted to the server ( sign , signMethod and cleanSession except) sort in alphabetical order, and then splice the parameters and values in turn (without splice symbols). 2 The signature is calculated by using the signature algorithm specified by signMethod and the DeviceSecret value of the device. The results are calculated sign the value. Sign an example of the value calculation method is as follows: |
SignMethod | String | The signature method, which supports hmacSha1, hmacSha256, hmacMd5, and sha256. |
Timestamp | String | The millisecond timestamp. |
ClientId | String | Equipment identification. Can be productKey&deviceName |
CleanSession | String | ●If the value is true , all messages when the sub-device is offline are cleared, that is, all unreceived QoS1 messages are cleared. ●If the value is false , the message when the sub-device is offline is not sorted out. |
Alink response data format:
{
"id":"123",
"code":200,
"message":"success"
"data":{
"deviceName": "device1234",
"productKey": "al12345****"
}
}Parameters | Type | Description |
ID | String | The message ID. A number of the String type. The value range is from 0 to 4294967295. Each message ID is unique in the current device. |
Code | Integer | The result is returned, 200 representing success. |
Message | String | Returns the result information. |
Data | Object | The sub-device information returned when the request succeeds or fails. For details, see the following table data. |
Parameters | Type | Description |
DeviceName | String | The device name of the sub-device. |
ProductKey | String | The key of the product to which the sub-device belongs. |
Error message:
Error Code | Error Message | Description |
460 | Request parameter error | The request parameter is incorrect. |
429 | Rate limit, too many subDeviceOnline msg in one minute | Single device authentication is throttling too frequently. |
428 | Too many subdevices under gateway | Too many sub-devices are online at the same time under the Gateway. |
6401 | Topo relation not exist | There is no topological relationship between the Gateway and sub-devices. |
6100 | Device not found | The child device does not exist. |
521 | Device deleted | The child device has been deleted. |
522 | Device forbidden | The child device has been disabled. |
6287 | Invalid sign | The sub-device password or signature is incorrect. |
Batch launch of sub-devices
Important A maximum of 50 sub-devices can be requested to go online at a time.
Data Uplink:
●Request Topic: /ext/session/${productKey}/${deviceName}/combine/batch_login ●Response Topic: /ext/session/${productKey}/${deviceName}/combine/batch_login_reply
Description Because sub-devices communicate with IoT platform through gateway channels, the preceding topics are the topics of the gateway devices. Variables in Topic ${productKey} and ${deviceName} replace with the corresponding information of the gateway device.
Request data format:
{
"id": "123",
"params":{
"deviceList":[{
"productKey": "al12345****",
"deviceName": "device1234",
"clientId": "al12345****&device1234",
"timestamp": "1581417203000",
"cleanSession": "false",
"signMethod": "hmacmd5",
"sign": "9B9C732412A4F84B981E1AB97CAB****",
}, {
"productKey": "al12345****",
"deviceName": "device4321",
"clientId": "al12345****&device4321",
"timestamp": "1581417203000",
"cleanSession": "true",
"signMethod": "hmacmd5",
"sign": "9B9C732412A4F84B981E1AB97CAB****",
}]
}
}Description In the message body, the parameter productKey and deviceName is the corresponding information of the sub-device.
Parameters | Type | Description |
ID | String | Message ID number. A number of the String type. The value range is from 0 to 4294967295, and each message ID is unique in the current device. |
Params | Object | The input parameters of the request. The deviceList parameter contains the list of sub-device authentication parameters to be online. For more information, see the following table deviceList. |
Parameters | Type | Description |
DeviceName | String | The device name of the sub-device. |
ProductKey | String | The ProductKey of the product to which the sub-device belongs. |
Sign | String | Child device signature. The signature method is the same as the directly connected device signature method. Signature method: 1 All parameters submitted to the server ( sign , signMethod and cleanSession except) sort in alphabetical order, and then splice the parameters and values in turn (without splice symbols). 2 The signature is calculated by using the signature algorithm specified by signMethod and the DeviceSecret value of the device. The results are calculated sign the value. Sign an example of the value calculation method is as follows: |
SignMethod | String | The signature method, which supports hmacSha1, hmacSha256, hmacMd5, and sha256. |
Timestamp | String | The millisecond timestamp. |
ClientId | String | Equipment identification. Can be productKey&deviceName |
CleanSession | String | ●If the value is true , all messages when the sub-device is offline are cleared, that is, all unreceived QoS1 messages are cleared. ●If the value is false , the message when the sub-device is offline is not sorted out. |
Response data format:
{
"id":"123",
"code":"200",
"message":"success",
"data":[{
"productKey": "al12345****",
"deviceName": "device1234"
},{
"deviceName": "device4321",
"productKey": "al12345****"
}]
}Parameter description:
Parameters | Type | Description |
ID | String | The message ID. A number of the String type. The value range is from 0 to 4294967295. Each message ID is unique in the current device. |
Code | Integer | The result is returned, 200 representing success. |
Message | String | Returns the result information. |
Data | Object | The sub-device information returned when the request succeeds or fails. For details, see the following table data. |
Data parameter description:
Parameters | Type | Description |
DeviceName | String | The device name of the sub-device. |
ProductKey | String | The key of the product to which the sub-device belongs. |
Error message:
Error Code | Error Message | Description |
460 | Request parameter error | The request parameter is incorrect. |
429 | Rate limit, too many subDeviceOnline msg in one minute | Single device authentication is throttling too frequently. |
428 | Too many subdevices under gateway | Too many sub-devices are online at the same time under the Gateway. |
6401 | Topo relation not exist | There is no topological relationship between the Gateway and sub-devices. |
6100 | Device not found | The child device does not exist. |
521 | Device deleted | The child device has been deleted. |
522 | Device forbidden | The child device has been disabled. |
6287 | Invalid sign | The sub-device password or signature is incorrect. |