---
name: "SmartTapToRunAbility.bind"
mode: "api"
versionRequirements:
  - { name: "@ray-js/panel-sdk", version: "1.11.0" }
title: "bind - 给一键执行绑定自动化条件"
summary: "给一键执行绑定自动化条件，将场景规则与设备功能点关联。"
---

## SmartTapToRunAbility.bind

> [VERSION] @ray-js/panel-sdk >= 1.11.0

> 💡 仅支持单设备，不支持群组环境。
> 注意，返回示例仅供参考，其包含字段大于返回参数定义范围，请勿使用除本文返回参数定义以外的返回数据，否则可能会导致程序异常。

### 描述

给一键执行绑定自动化触发条件

### 参数

`Params`

| 参数 | 类型 | 必填 | 描述 |
| --- | --- | --- | --- |
| `params` | `BindParams` | 是 | 绑定参数 |

### 返回值

类型: `Promise<BindTapToRunResult>`

绑定结果

### 引用对象

##### `type` BindParams

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `devId` | `string` | 设备 ID，默认从默认设备环境中取 |
| `dpId` | `string` | 功能点 ID，需搭配 dpValue 一同使用， 其含义为当设备上报后满足 dpId == dpValue 时，则会自动触发执行对应绑定的一键执行 |
| `dpValue` | `boolean \| number \| string` | 功能点值，需搭配 dpId 一同使用， 其含义为当设备上报后满足 dpId == dpValue 时，则会自动触发执行对应绑定的一键执行 |
| `ruleId` | `string` | 需要绑定的场景 id 列表，在 dpId == dpValue 时，则会触发执行当前规则 id 对应绑定的联动 |
| `name` | `string` | 名称 |
| `icon` | `string` | 图标 |
| `gid` | `string` | 家庭 id，不填默认使用当前 App 家庭 id |

##### `type` BindTapToRunResult

一键执行绑定结果

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `associativeEntityId` | `string` | 关联实体 ID，格式为 dpId#dpValue |
| `associativeEntityValue` | `string` | 关联的规则 ID |
| `bindId` | `number` | 绑定 ID，一般用来解绑 |
| `bizDomain` | `string` | 业务域，一键执行固定为 wirelessSwitchBindScene |
| `id` | `number` | 数据 ID |
| `ownerId` | `string` | 家庭 ID |
| `sourceEntityId` | `string` | 设备 ID |
| `triggerRuleId` | `string` | 触发规则 ID |

##### `type` DpValue

功能点值类型，可能为 boolean、number、string

```typescript
export type DpValue = boolean | number | string;
```


### 示例代码

#### 示例

```typescript
const result = await sdm.tapToRun.bind({
  dpId: '1',
  dpValue: 'single_click',
  ruleId: 'scene_abc123',
});
console.log('绑定结果:', result);
```
