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

## getLightAppAiRuleNames

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

> 💡 接口依赖云能力，需在 [小程序开发者平台](https://platform.tuya.com/miniapp/)开发设置 - 云能力 进行授权配置, 具体操作: 找到 小程序照明场景能力 卡片, 点击卡片右下角 授权 按钮, 完成该云能力授权。

### 描述

获取 App 端侧 AI 照明方案名称列表。该接口用于获取指定房间可用的灯光场景方案，包括基础场景（开/关）和 DIY 场景。返回的场景列表包含场景名称、颜色、图标、开灯百分比以及可选的场景数据列表。

### 参数

`Params`

| 参数 | 类型 | 必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| `data` | `GetLightAppAiRuleNamesParams` | 是 | - | 请求参数：ownerId（家庭 ID）、roomId（房间 ID）、sceneType（场景类型：1 基础场景开，2 基础场景关，3 DIY 场景） |

### 引用对象

##### `interface` GetLightAppAiRuleNamesParams

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `ownerId` | `string` | 家庭 ID |
| `roomId` | `number` | 房间 ID |
| `sceneType` | `number` | 场景类型 (1: 基础场景开, 2: 基础场景关, 3: DIY 场景) |

##### `interface` SceneData

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `productId` | `string` | 产品 ID |
| `sceneId` | `number` | 场景 ID |
| `sceneCellBackground` | `string` | 场景单元格背景 |
| `dpCode` | `string` | DP 编码 |
| `sceneData` | `string` | 可直接下发的场景 DP 数据 |


### 示例代码

#### 请求示例

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

const params = {
  ownerId: '2142765',
  roomId: 65570111,
  sceneType: 3,
};

getLightAppAiRuleNames(params)
  .then(result => {
    console.log('场景方案列表:', result);
    result.forEach(scene => {
      console.log(`场景名称: ${scene.name}`);
      console.log(`开灯比例: ${scene.turnOnPercent}%`);
      console.log(`颜色: ${scene.color}`);
    });
  })
  .catch(error => {
    console.error('获取场景列表失败:', error);
  });
```

#### 返回示例

```json
[
  { "color": "50657A", "name": "全亮", "turnOnPercent": 100 },
  { "color": "71C149", "name": "全关" },
  { "color": "50657A", "name": "聊天", "turnOnPercent": 60 },
  { "color": "EA903A", "name": "家人互动", "turnOnPercent": 60 },
  { "color": "BA7B69", "name": "亲子互动", "turnOnPercent": 60 },
  { "color": "4E7ACE", "name": "接待", "turnOnPercent": 60 },
  {
    "color": "DC4F58",
    "name": "场景 31",
    "sceneDataList": [{ "sceneId": 112000112, "sceneData": "******" }]
  },
  {
    "color": "EA903A",
    "name": "场景 32",
    "sceneDataList": [{ "sceneId": 112000212, "sceneData": "******" }]
  }
]
```
