设备属性API
ty.device.setDeviceProperty
设置设备属性
需引入
DeviceKit,且在>=1.2.6版本才可使用
请求参数
Object object
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| deviceId | string |
是 | deviceId | |
| code | string |
是 | the custom data key | |
| value | string |
是 | the custom data value | |
| complete | function |
否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
| success | function |
否 | 接口调用成功的回调函数 | |
| fail | function |
否 | 接口调用失败的回调函数 |
返回结果
- success
| 属性 | 类型 | 说明 |
|---|---|---|
| deviceId | string |
deviceId |
| result | boolean |
set DeviceProperty successfully |
- fail
| 属性 | 类型 | 说明 |
|---|---|---|
| errorMsg | string |
插件错误信息 |
| errorCode | string |
错误码 |
| innerError | object |
插件外部依赖错误信息 {errorMsg: string, errorCode: string } |
请求示例
ty.device.setDeviceProperty({
deviceId: '64710761ecfabcaaf553',
code: 'netName',
value: 'Tuya-Test123',
})
.then((res) => {
console.log(res);
})
.catch((error) => {
console.log(error);
});
返回示例
{
"result": true,
"deviceId": '64710761ecfabcaaf553'
}
TuyaDeviceKitAPI:设备属性管理与事件处理

最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



