---
name: "updateDeviceConfig"
mode: "kit"
versionRequirements:
  - { name: "@tuya-miniapp/cloud-api", version: "1.0.5" }
---

## updateDeviceConfig

> [VERSION] @tuya-miniapp/cloud-api >= 1.0.5

### 描述

设备服务配置项修改

### 参数

`Params`

| 参数 | 类型 | 必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| `params` | `UpdateDeviceConfigParams` | 是 | - | 请求体 |

### 引用对象

##### `type` UpdateDeviceConfigParams

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `devId` | `string` | 设备 id |
| `configId` | `number` | 配置项 id（可选） |
| `configCode` | `string` | 配置编码 |
| `configValue` | `string` | 配置取值（可选） |
| `configType` | `"VisionEventType.PRESET" \\| "VisionEventType.CUSTOM"` | 配置类型 |
| `enableState` | `"DeviceServiceConfigState.Delete" \\| "DeviceServiceConfigState.Available" \\| "DeviceServiceConfigState.Unavailable"` | 启用状态（与 configState 对应） |
| `serviceBusinessType` | `"aiSmartFreeEvent" \| "aiSmartFreeEventImage2Text"` | 智能事件业务类型 |

##### `enum` VisionEventType

| 枚举值 | 实际值 | 描述 |
| --- | --- | --- |
| `VisionEventType.PRESET` | `0` | 预置事件 |
| `VisionEventType.CUSTOM` | `1` | 自定义事件 |

##### `enum` DeviceServiceConfigState

| 枚举值 | 实际值 | 描述 |
| --- | --- | --- |
| `DeviceServiceConfigState.Delete` | `0` | 已删除 |
| `DeviceServiceConfigState.Available` | `1` | 可用 |
| `DeviceServiceConfigState.Unavailable` | `2` | 不可用 |

##### `interface` DeviceServiceConfigItemDto

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `configId` | `number` | 配置项 id |
| `configCode` | `string` | 配置编码 |
| `configType` | `"VisionEventType.PRESET" \\| "VisionEventType.CUSTOM"` | 配置类型（预置 / 自定义） |
| `configValue` | `string` | 配置取值 |
| `configCodeIcon` | `string` | 配置图标（可选） |
| `configState` | `"DeviceServiceConfigState.Delete" \\| "DeviceServiceConfigState.Available" \\| "DeviceServiceConfigState.Unavailable"` | 配置状态 |


### 示例代码

#### 请求示例

```typescript
import { updateDeviceConfig } from '@tuya-miniapp/cloud-api';

updateDeviceConfig({
  devId: 'vdevo1',
  serviceBusinessType: 'aiSmartFreeEvent',
  configCode: 'person',
  configType: 0,
  enableState: 1,
})
  .then((id) => console.log(id))
  .catch(console.error);
```

#### 返回示例

```json
1
```
