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

## getSceneAndAuto

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

> 💡 接口依赖云能力，需在 [小程序开发者平台](https://platform.tuya.com/miniapp/)开发设置-云能力 进行授权配置。

### 描述

面板获取设备所有场景和自动化

### 参数

`Params`

| 参数 | 类型 | 必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| `devOrGroupId` | `string` | 是 | - | 设备 ID 或群组 ID，用于查询与该设备或群组相关的所有场景和自动化 |

### 引用对象

##### `interface` SceneOrAuto

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `background` | `string` | 场景背景 |
| `displayColor` | `string` | 场景展示颜色 |
| `displayIcon` | `string` | 场景展示图标 |
| `enabled` | `boolean` | 场景是否启用 |
| `id` | `string` | 场景 ID |
| `name` | `string` | 场景名称 |
| `sceneIcons` | `SceneIcon[]` | 场景图标列表 只有 Auto 自动化存在该字段，Scene 一键执行不存在 |

##### `type` SceneIcon

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `defaultIconName` | `string` | 默认图标资源名 |
| `isRemoved` | `boolean` | 是否已移除 |
| `removeIconName` | `string` | 移除态图标资源名 |
| `type` | `"action" \| "arrow" \| "condition"` | 图标语义：动作 / 箭头 / 条件 |
| `url` | `string` | 图标 URL |


### 示例代码

#### 请求示例

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

getSceneAndAuto('device_id_123456')
  .then(response => {
    console.log('自动化列表:', response.autos);
    console.log('一键执行列表:', response.scenes);
  })
  .catch(error => {
    console.error('Failed to get scene and auto:', error);
  });
```

#### 返回示例

```json
{
  "autos": [
    {
      "background": "#FF5722",
      "displayColor": "#FF5722",
      "displayIcon": "https://example.com/icon.png",
      "enabled": true,
      "id": "auto_123",
      "name": "自动开灯",
      "sceneIcons": [
        {
          "defaultIconName": "condition_icon",
          "isRemoved": false,
          "removeIconName": "",
          "type": "condition",
          "url": "https://example.com/condition_icon.png"
        },
        {
          "defaultIconName": "arrow_icon",
          "isRemoved": false,
          "removeIconName": "",
          "type": "arrow",
          "url": "https://example.com/arrow_icon.png"
        },
        {
          "defaultIconName": "action_icon",
          "isRemoved": false,
          "removeIconName": "",
          "type": "action",
          "url": "https://example.com/action_icon.png"
        }
      ]
    }
  ],
  "scenes": [
    {
      "displayColor": "#4CAF50",
      "displayIcon": "https://example.com/scene_icon.png",
      "enabled": true,
      "id": "scene_456",
      "name": "回家模式"
    }
  ]
}
```
