---
name: "predictLightScenes"
mode: "kit"
versionRequirements:
  - { name: "AIKit", version: "2.0.1" }
  - { name: "@ray-js/ray", version: "1.7.60" }
platform:
  - "iOS"
  - "Android"
async: true
title: "predictLightScenes"
---

## predictLightScenes

> [VERSION] AIKit >= 2.0.1 | @ray-js/ray >= 1.7.60

> [PLATFORM] iOS, Android

> ⚡ **Supports Promise** — Returns a Promise when success / fail / complete callbacks are omitted.

### Description

Predict lighting scene

### Parameters

| Property | Type | Required | Default | Since | Description |
| --- | --- | --- | --- | --- | --- |
| `roomId` | `number` | Yes | - | `2.0.1` | Room ID |
| `generateSceneStyles` | `SceneStyleInfo[]` | Yes | - | `2.0.1` | Scene style list, light-on percentage |
| `sceneType` | `number` | Yes | - | `2.0.1` | Scene type |
| `complete` | `() => void` | No | - | - | Completion callback (executed on both success and failure) |
| `success` | `(params: LightSceneGenerateLightSceneInfo[]) => void` | No | - | - | Callback on successful API call |
| `fail` | `(params: Object) => void` ↓see below | No | - | - | Failure callback |

#### fail callback parameters

| Property | Type | Description |
| --- | --- | --- |
| `errorMsg` | `string` | Error message |
| `errorCode` | `string \| number` | Error code |
| `innerError` | `Object` | Error extension |

##### fail(params).innerError properties

| Property | Type | Description |
| --- | --- | --- |
| `errorCode` | `string \| number` | Error extension code |
| `errorMsg` | `string` | Error extension message |


### Referenced Types

##### `interface` SceneStyleInfo

| Property | Type | Since | Description |
| --- | --- | --- | --- |
| `name` | `string` | `2.0.1` | Style name |
| `turnOnPercent` | `number` | `2.0.1` | Light-on percentage |
| `sceneDataList` | `SceneData[]` | `2.0.1` | Scene library data list; presence of this parameter distinguishes scene library from generative style |
| `nameRosettaKey` | `string` | `2.0.1` | Generated style name key, unique identifier |

##### `interface` LightSceneGenerateLightSceneInfo

| Property | Type | Since | Description |
| --- | --- | --- | --- |
| `parentRegionId` | `string` | `2.0.1` | Parent region ID |
| `sceneType` | `number` | `2.0.1` | Scene type |
| `name` | `string` | `2.0.1` | Scene name |
| `icon` | `string` | `2.0.1` | Scene icon |
| `matchType` | `number` | `2.0.1` | Match type |
| `actions` | `LightSceneGenerateLightSceneAction[]` | `2.0.1` | Scene action list |

##### `type` SceneData

| Property | Type | Since | Description |
| --- | --- | --- | --- |
| `productId` | `string` | `2.0.1` | Product ID |
| `sceneData` | `string` | `2.0.1` | Scenario library data |
| `sceneCellBackground` | `string` | `2.0.1` | Scenario image |
| `sceneId` | `string` | `2.0.1` | Scenario ID |
| `dpCode` | `string` | `2.0.1` | Scenario dpCode |

##### `type` LightSceneGenerateLightSceneAction

| Property | Type | Since | Description |
| --- | --- | --- | --- |
| `actionExecutor` | `string` | `2.0.1` | Action executor |
| `entityId` | `string` | `2.0.1` | Device or group ID |
| `entityName` | `string` | `2.0.1` | Device or group name |
| `executorProperty` | `Record<string, any>` | `2.0.1` | Actuator attributes |
| `extraProperty` | `Record<string, any>` | `2.0.1` | Extended attributes |


### Examples

#### Basic usage

```tsx
import { ai } from '@ray-js/ray'

const { predictLightScenes } = ai;

predictLightScenes({
  roomId: 0,
  generateSceneStyles: [{ name: 'example' }],
  sceneType: 0,
  success: (result) => {
    console.log('predictLightScenes success', result);
  },
  fail: (error) => {
    console.log('predictLightScenes fail', error.errorMsg);
  },
});
```
