---
name: "getBindRuleList"
mode: "api"
versionRequirements:
  - { name: "@ray-js/ray", version: "1.4.61" }
title: "getBindRuleList - 查询设备条件已绑定的场景"
---

## getBindRuleList

> [VERSION] @ray-js/ray >= 1.4.61

### 描述

查询设备条件已绑定的场景

### 参数

`Params`

| 参数 | 类型 | 必填 | 描述 |
| --- | --- | --- | --- |
| `params` | `IGetBindRuleList` | 是 | 查询参数 |

### 返回值

类型: `Promise<IBindRuleListItem[]>`

已绑定的规则列表

##### IBindRuleListItem

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `associativeEntityId` | `AssociativeEntityId` | 与面板/设备建立绑定关系,通常为设备ID、DP点、群组、规则，dpId#value等 |
| `associativeEntityValueList` | `IBindRuleSceneItem[]` | 关联实体的值列表 |
| `bindId` | `number` | 绑定 id，一般用来解绑 |
| `bizDomain` | `string` | 业务域 |
| `enable` | `boolean` | 是否启用 |
| `sourceEntityId` | `string` | 设备 ID |

### 引用对象

##### `interface` IGetBindRuleList

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `bizDomain` | `string` | 业务域 |
| `devId` | `string` | 设备 ID |
| `sourceEntityId` | `string` | 与面板/设备建立绑定关系标识 |
| `entityType` | `"EntityType.DEVICE" \\| "EntityType.RULE"` | 实体类型，1 为设备，2 为联动规则 |
| `gid` | `string` | 家庭 ID |

##### `type` AssociativeEntityId

与面板/设备建立绑定关系,通常为设备ID、DP点、群组、规则，dpId#value等

```typescript
type AssociativeEntityId = string;
```

##### `interface` IBindRuleSceneItem

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `triggerRuleEnable` | `boolean` | 无线开关规则是否启用 |
| `triggerRuleId` | `string` | 无线开关执行规则 id |
| `actions` | `ISceneAction[]` | 执行动作 |
| `alarmIssue` | `boolean` | 是否为告警问题 |
| `attribute` | `number` | 属性 根据枚举值的2次幂进行位运算 |
| `auditStatus` | `number` | 审核状态 0. 未审核 1. 审核通过 2. 审核不通过 |
| `background` | `string` | 背景图地址 |
| `boundForPanel` | `boolean` | 面板绑定 |
| `boundForWiFiPanel` | `boolean` | WiFi 面板绑定 |
| `code` | `string` | 规则 code |
| `commonField` | `string` | 通用json字段，比如本地联动会存网关id，gwId |
| `containDeviceDelete` | `boolean` | 是否包含已删除的设备 |
| `coverIcon` | `string` | 图标 |
| `description` | `string` | 规则描述 |
| `disableTime` | `number` | 禁用时间戳 |
| `displayColor` | `string` | 背景颜色 |
| `enabled` | `boolean` | 规则是否启用 |
| `forceCloudTrigger` | `boolean` | 是否强制云端触发 |
| `id` | `string` | 执行规则 id |
| `iotAutoAlarm` | `boolean` | 是否为 IoT 自动告警 |
| `isAlarmIssue` | `boolean` | 是否为告警问题 |
| `isLogicRule` | `boolean` | 是否为逻辑规则 |
| `linkageType` | `number` | 联动类型 |
| `localLinkage` | `boolean` | 是否本地联动 |
| `logicRule` | `boolean` | 是否逻辑规则 |
| `matchType` | `number` | 匹配类型 1. 任意条件，多个条件里只要有一个即触发（即 或关系）。 2. 全部满足，多个条件全部满足才触发。 3. 表态式匹配， 根据 rule 字段的 expr 确定是否满足，条件满足时触发。 |
| `name` | `string` | 联动名称或备注 |
| `needCleanGidSid` | `boolean` | 是否需要清理 gidSid |
| `needValidOutOfWork` | `boolean` | 是否需要校验不在工作时间段 |
| `newLocalScene` | `boolean` | 是否为新本地场景 |
| `offGwSync` | `boolean` | 是否离网关同步 |
| `offGwSyncSuccess` | `boolean` | 离网关同步是否成功 |
| `orderWeight` | `number` | 排序权重 |
| `outOfWork` | `number` | 不在工作时间段标记 |
| `ownerId` | `string` | 家庭 id |
| `panelType` | `number` | 面板类型 |
| `permissionCode` | `string` | 权限 code |
| `ruleGenre` | `number` | 规则体裁 |
| `ruleSource` | `number` | 规则来源 |
| `ruleType` | `number` | 规则类型 1. 系统定义 2. 商家定义 3. 用户定义 4. 安防规则 5. 服务定义（如 dp 点转发） |
| `runtimeEnv` | `string` | 运行环境 |
| `scenarioRule` | `boolean` | 是否为场景规则 |
| `status` | `boolean` | 规则状态 |
| `statusConditions` | `any[]` | 状态条件列表 |
| `stickyOnTop` | `boolean` | 是否显示在首页顶部 |
| `subMatchType` | `number` | 子匹配类型 |
| `uid` | `string` | 用户 id |

##### `enum` EntityType

| 枚举值 | 实际值 | 描述 |
| --- | --- | --- |
| `EntityType.DEVICE` | `1` | 关联实体为设备 |
| `EntityType.RULE` | `2` | 关联实体为联动规则 |


### 示例代码

```typescript
import { getBindRuleList } from '@ray-js/ray';

const fetchBindRules = async () => {
  try {
    const rules = await getBindRuleList({
      bizDomain: 'wirelessSwitch',
      devId: 'device_001',
      entityType: 1,
      gid: '12345678',
    });
    rules.forEach(rule => {
      console.log(`绑定ID: ${rule.bindId}, 启用: ${rule.enable}`);
    });
  } catch (err) {
    console.error('查询失败:', err);
  }
};
```
