Call this interface to set the property value for the specified device.
Because the attribute setting command issued by the cloud is asynchronous with the device receiving and executing the command, when this interface is called, the returned success result only indicates that the request issued by the cloud for attribute setting is successful, and cannot guarantee that the device has received and executed the request. The device SDK must successfully respond to the cloud request to set the device attribute value before the device attribute value is actually set.
| Name | Type | Required | Sample Values | Description |
|---|---|---|---|---|
| Action | String | Yes | SetDeviceProperty | System defined parameters. Value: SetDeviceProperty. |
| Items | String | Yes | {"Switch":1,"Color":"blue"} | The attribute information to be set. The data format is JSON. Each attribute information is given identifier and Attribute value (key:value) composition, multiple attributes separated by commas. For example, set the following two properties of a smart light: ●The identifier is Switch the switch property of the data type is Bool , the setting value is 1 (On). ●The identifier is Color the light color property of the data type String , the setting value is blue . The JSON format of the attribute information to be set is as follows: Items={"Switch":1,"Color":"blue"} |
| ProductKey | String | No | A1BwAGV * * * * | The product to which the device belongs ProductKey . |
| DeviceName | String | No | Light | The device name. |
| IoTID | String | No | **** 00100 | The device ID. The ID issued by IoT platform for the device. The unique identifier of the device. |
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.
| Name | Type | Sample Values | Description |
|---|---|---|---|
| Code | String | Iot.system.SystemException | The error code returned when the call fails. For more information, see Error codes. |
| Data | Struct | The data returned when the call is successful. | |
| MessageId | String | Abcabc123 | The ID of the message that the cloud sends attribute settings to the device. |
| 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. |
curl 'https://si-d6e8d******848958054.tuyacloud.com:8686/?Action=SetDeviceProperty&SignatureNonce=105918e0402545458ed4cf0fa3be3537&AccessKeyId=xMr9wgwXQLhv5AUa65o03mcD&SignatureMethod=HMAC-SHA1&Items=%7B%22rain%22%3A3%7D&Timestamp=2024-11-19T10%3A16%3A17Z&ProductKey=k1ymv1DuLfE&DeviceName=myTestDevice&Signature=2XbIvrEvlDzkI26xL%2BG7qtLTIkA%3D'
{
"RequestId":"57b144cf-09fc-4916-a272-a62902d5b207",
"Success": true,
"Data": {
"MessageId":"abcabc123"
}
}