<h2 id="auto-generate-lighting-scenes" class="nx-font-semibold nx-tracking-tight nx-text-slate-900 dark:nx-text-slate-100 nx-mt-10 nx-border-b nx-pb-1 nx-text-3xl nx-border-neutral-200/70 contrast-more:nx-border-neutral-400 dark:nx-border-primary-100/10 contrast-more:dark:nx-border-neutral-400">Auto-Generate Lighting Scenes<span className="tag_h2">On-App AI</span></h2>


### Feature Introduction

The AI Generative Lighting Scene module leverages On-App AI on-device capabilities, combined with room space and lighting device capabilities, to automatically generate usable and executable lighting atmosphere solutions for users. The system recommends 9 lighting scenes and supports replacement, preview, and save functions, enabling quick creation of lighting environments without professional configuration.

This module is suitable for various lighting scene needs including home lighting, hotel apartments, commercial spaces, etc., improving the efficiency and experience of creating lighting atmospheres for users.

<Image
  src='/images/solution/aiLightingScene/auto_scene_en.jpg'
  style={{
    borderRadius: '10px',
    boxShadow: '0 0 5px rgba(0,0,0,0.3)',
    maxWidth: '240px',
    marginTop: '20px',
  }}
/>

### Feature Description

**1. Auto-Generate Lighting Scenes**

- The system intelligently generates 9 candidate lighting scenes based on room information and lighting capabilities, each scene includes:

- Scene name

- Color/brightness/color temperature scheme

- Lighting control actions (action list)

Users can directly click to preview or save.

**2. Replace Lighting Solutions**

- Supports replacing individual scenes

- Supports batch replacement of unselected scenes

- AI will regenerate lighting configurations

Used to obtain lighting effects that better match preferences.

**3. Lighting Scene Preview**

- Click on a card to preview in real-time:

- Lights change immediately

- Does not affect device persistent configuration

- Can revert upon exit

Enhances experience certainty.

**4. Multi-Select Save to Cloud Scenes**

- Users can select favorite lighting solutions

- Once saved, they can be invoked and executed in the App long-term.

> Non-administrator accounts will be blocked from save operations


### Interaction Flow

```mermaid
sequenceDiagram
    participant U as User
    participant UI as Frontend Page
    participant Room as Room Data Service
    participant AI as AI Lighting Engine
    participant Dev as Lighting Device
    participant Cloud as Cloud Scene Library

    U->>UI: Enter AI lighting page
    UI->>Room: Get home/room information
    Room-->>UI: Return roomId

    UI->>Cloud: Get available lighting style data
    Cloud-->>UI: Return style list
    UI->>UI: Sample generate 9 candidates

    UI->>AI: predictLightScenes(9 items)
    AI-->>UI: Return lighting action configuration
    UI->>U: Display recommended lighting scenes


    U->>UI: Click preview
    UI->>Dev: Send lighting actions
    Dev-->>U: Real-time lighting effect


    U->>UI: Click refresh (single/all)
    UI->>AI: Regenerate action configuration
    AI-->>UI: Return solutions
    UI->>U: Display new lighting cards


    U->>UI: Select multiple scenes
    U->>UI: Click save
    UI->>Cloud: Batch saveScene
    Cloud-->>UI: Return success/failure
    UI->>U: Show status
```

### Dynamic Dataset

```mermaid
flowchart LR
    subgraph BD[Business Definition]
        A[Lighting Style Library] --> B[Room Attributes]
        B --> C[Device Capability Model]
    end

    subgraph AI[AI Lighting Generation Model]
        C --> D[Style Matching]
        D --> E[Lighting Parameter Inference]
        E --> F[Device Action Generation]
    end

    subgraph DS[Scene Dataset]
        F --> G["Lighting Scene Dataset\n(Name+Parameters+Action)"]
    end
```

**Lighting Scene Data Generation Process Description:**

- Lighting Style Library: Preset atmosphere styles (e.g., reading, cinema, party)

- Room Attributes: Region ID / light group information

- Device Capabilities: Brightness / color temperature / RGB / controllable attributes

- Style Matching: Filter applicable lighting strategies

- Parameter Inference: Generate target lighting effects

- Action Generation: Output device control instructions

### Module Working Principle

The module core is based on the following logic:

#### 1. Get room information when entering the page

```ts
const homeId = await getAppHomeId();
const { roomId } = await getRoomList();
```
#### 2. Get lighting scene candidate set

```ts
const list = await getSceneDataList(homeId, roomId);
```
#### 3. Perform AI lighting prediction

```ts
predictLightScenes({
  roomId,
  generateSceneStyles: list,
  sceneType,
})

```
#### 4. Support single card refresh / batch refresh

```ts
refresh(item)
refreshAll()
```
#### 5. Preview lighting effects

```ts
previewScene({
  actions,
  parentRegionId: roomId
})
```

#### 6. Batch save

```ts
await Promise.all(selectedList.map(saveScene));
```
