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

## getDeviceConfig

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

### 方法签名

```typescript
getDeviceConfig(params: GetDeviceConfigParams)
```

### 描述

获取设备服务配置项

### 参数

`Params`

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

### 返回值

类型: `Promise<GetDeviceConfigResult & Object>`

配置查询结果，并附带请求上下文中的 uuid（见实现返回类型）
| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `uuid` | `string` | 设备 uuid |

### 引用对象

##### `type` GetDeviceConfigParams

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

##### `type` GetDeviceConfigResult

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `hadService` | `boolean` | 是否已开通相关服务 |
| `switchState` | `0 \| 1` | 总开关状态（0 / 1） |
| `configItemList` | `DeviceServiceConfigItemDto[]` | 配置项列表 |


### 合法值

##### `GetDeviceConfigParams.serviceBusinessType`

| 值 | 说明 | 最低版本 |
| --- | --- | --- |
| `aiSmartFreeEvent` | - | - |
| `aiSmartFreeEventImage2Text` | - | - |

##### `GetDeviceConfigResult.switchState`

| 值 | 说明 | 最低版本 |
| --- | --- | --- |
| `0` | - | - |
| `1` | - | - |


### 示例代码

#### 请求示例

```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
    }
  ]
}
```
