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

## getDeviceConfig

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

### 描述

获取设备服务配置项

### 参数

`Params`

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

### 引用对象

##### `type` GetDeviceConfigParams

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `devId` | `string` | 设备 id |
| `serviceBusinessType` | `"aiSmartFreeEvent" \| "aiSmartFreeEventImage2Text"` | 智能事件业务类型 |

##### `interface` DeviceServiceConfigItemDto

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

##### `enum` VisionEventType

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

##### `enum` DeviceServiceConfigState

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


### 示例代码

#### 请求示例

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

getDeviceConfig({ devId: 'vdevo1', serviceBusinessType: 'aiSmartFreeEvent' })
  .then((r) => console.log(r))
  .catch(console.error);
```

#### 返回示例

```json
{
  "uuid": "vdevo176127325226099",
  "hadService": true,
  "switchState": 1,
  "configItemList": [
    {
      "configId": 1,
      "configCode": "cloudStorage",
      "configType": 0,
      "configValue": "1",
      "configState": 1
    }
  ]
}
```
