---
name: "bindRule"
mode: "api"
versionRequirements:
  - { name: "Base Library", version: "2.14.0" }
title: "device.bindRule - 绑定联动规则"
---

## bindRule

> [VERSION] Base Library >= 2.14.0

### Description

Bind automation rule

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `params` | `IBindRule` | Yes | Binding parameters |

### Return Value

Type: `Promise<IBindRuleResponse>`

Binding result

##### IBindRuleResponse

| Property | Type | Description |
| --- | --- | --- |
| `associativeEntityId` | `string` | Establish a binding relationship with a panel/device, typically device ID, DP, group, rule, dpId#value, etc. |
| `associativeEntityValue` | `string` | Used when associativeEntityId is insufficient to distinguish; typically can associate devices, DP values, groups, rules, etc. |
| `bizDomain` | `string` | Business domain |
| `id` | `number` | Data ID |
| `ownerId` | `string` | Home ID |
| `sourceEntityId` | `string` | Device ID |
| `triggerRuleId` | `string` | Rule ID |
| `triggerRuleVO` | `any` | Device info for action execution |

### Referenced Types

##### `interface` IBindRule

| Property | Type | Description |
| --- | --- | --- |
| `devId` | `string` | Device ID |
| `sourceEntityId` | `string` | Establish a binding with the panel/device; typically device ID, DP point, group, rule, dpId#value, etc. |
| `associativeEntityId` | `string` | Used when associativeEntityId is insufficient to distinguish; can typically associate devices, DP values, groups, rules, etc. |
| `ruleId` | `string` | Associated scene ID |
| `entitySubIds` | `string` | Associated DP point |
| `expr` | `[string[]]` | Associated DP point/action combination expression |
| `bizDomain` | `string` | Business domain |
| `gid` | `string` | Home ID |
| `property` | `Record<string, any>` | Extension field, optional |


### Examples

#### Bind automation rule

```ts
ty.bindRule({
  devId: 'abc123',
  associativeEntityId: 'dp_1#true',
  ruleId: 'rule_001',
  entitySubIds: '1',
  expr: [['$dp1', '==', 'true']],
  bizDomain: 'switch',
  gid: '456789',
}).then((res) => {
  console.log('Binding successful', res);
});
```
