On this page

getLightAppAiRuleNames(data: GetLightAppAiRuleNamesParams)

Requires:
@tuya-miniapp/cloud-api≥1.2.0

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

ParameterTypeRequiredDescription
YesRequest 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<GetLightAppAiRuleNamesResult>
Array of scene info objects (nameRosettaKey, name, turnOnPercent, color, icon, sceneDataList, id, etc.; see the Return Parameters table and the SceneData structure for details)

Referenced Types

typeGetLightAppAiRuleNamesResult
LightAppAiNameInfo[]

Examples

Request example

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

[
  { "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.