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

## getLightAppAiRuleNames

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

> 💡 This API relies on cloud capabilities. In the [Mini App Developer Platform](https://platform.tuya.com/miniapp/), go to Development Settings > Cloud Capabilities to configure authorization. Steps: find the 'Mini App Lighting Scene Capability' card, click the Authorize button at the bottom-right of the card, and complete the authorization.

### Description

Get the list of AI lighting scene names on the App side. This API returns the lighting scenes available for a specified room, including basic scenes (on/off) and DIY scenes. Each item includes the scene name, color, icon, turn-on percentage, and an optional scene data list.

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | `GetLightAppAiRuleNamesParams` | Yes | Request parameters: ownerId (Home ID), roomId (Room ID), sceneType (scene type: 1 basic scene on, 2 basic scene off, 3 DIY scene) |

### Return Value

Type: `Promise<LightAppAiNameInfo[]>`

Array of scene info objects (nameRosettaKey, name, turnOnPercent, color, icon, sceneDataList, id, etc.; see the Return Parameters table and the SceneData structure for details)

##### LightAppAiNameInfo

| Property | Type | Description |
| --- | --- | --- |
| `nameRosettaKey` | `string` | i18n key for the name |
| `name` | `string` | Scene name |
| `turnOnPercent` | `number` | Percentage of lights turned on out of the total |
| `color` | `string` | Color |
| `icon` | `string` | Icon |
| `sceneDataList` | `SceneData[]` | Scene data list |
| `id` | `number` | Server record ID (if any) |

### Referenced Types

##### `interface` GetLightAppAiRuleNamesParams

| Property | Type | Description |
| --- | --- | --- |
| `ownerId` | `string` | Home ID |
| `roomId` | `number` | Room ID |
| `sceneType` | `number` | Scene type (1: basic scene – on, 2: basic scene – off, 3: DIY scene) |

##### `interface` SceneData

| Property | Type | Description |
| --- | --- | --- |
| `productId` | `string` | Product ID |
| `sceneId` | `number` | Scene ID |
| `sceneCellBackground` | `string` | Scene cell background |
| `dpCode` | `string` | DP code |
| `sceneData` | `string` | Scene DP data that can be sent directly |


### Examples

#### Request example

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

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

getLightAppAiRuleNames(params)
  .then(result => {
    console.log('Scene presets:', result);
    result.forEach(scene => {
      console.log(`Scene name: ${scene.name}`);
      console.log(`Turn-on percentage: ${scene.turnOnPercent}%`);
      console.log(`Color: ${scene.color}`);
    });
  })
  .catch(error => {
    console.error('Failed to get scene list:', error);
  });
```

#### Response example

```json
[
  { "color": "50657A", "name": "All On", "turnOnPercent": 100 },
  { "color": "71C149", "name": "All Off" },
  { "color": "50657A", "name": "Chat", "turnOnPercent": 60 },
  { "color": "EA903A", "name": "Family Interaction", "turnOnPercent": 60 },
  { "color": "BA7B69", "name": "Parent-Child Interaction", "turnOnPercent": 60 },
  { "color": "4E7ACE", "name": "Reception", "turnOnPercent": 60 },
  {
    "color": "DC4F58",
    "name": "Scene 31",
    "sceneDataList": [{ "sceneId": 112000112, "sceneData": "******" }]
  },
  {
    "color": "EA903A",
    "name": "Scene 32",
    "sceneDataList": [{ "sceneId": 112000212, "sceneData": "******" }]
  }
]
```


### Additional notes

1. The `sceneDataList` field distinguishes scene types:
   - When it has data: the scene is a scene-library scene; you can send `sceneData` to the device directly.
   - When it has no data or is empty: the scene is an AI generative style scene and needs further handling.
2. The returned scene list is generated dynamically based on device capabilities in the room. Different rooms may return different lists.
3. The `turnOnPercent` field indicates what proportion of lights will be turned on in this scene, useful for UI or scene descriptions.
4. The `color` field is a hexadecimal color value **without** the `#` prefix. Add `#` when using it, for example `#50657A`.
