---
name: "removeRule"
mode: "api"
versionRequirements:
  - { name: "@ray-js/ray", version: "1.7.60" }
title: "removeRule - 移除场景规则"
---

## removeRule

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

### 描述

移除相关按键条件下的场景规则

### 参数

`Params`

| 参数 | 类型 | 必填 | 描述 |
| --- | --- | --- | --- |
| `params` | `IRemoveRule` | 是 | 移除规则参数 |

### 返回值

类型: `Promise<boolean>`

是否删除成功

### 引用对象

##### `interface` IRemoveRule

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `bizDomain` | `string` | 业务域 |
| `sourceEntityId` | `string` | 与面板/设备建立绑定关系标识 |
| `devId` | `string` | 设备 ID |
| `associativeEntityId` | `AssociativeEntityId` | 绑定关系标识 |
| `associativeEntityValue` | `AssociativeEntityValue` | 规则 ID |
| `gid` | `string` | 家庭 ID |

##### `type` AssociativeEntityId

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

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

##### `type` AssociativeEntityValue

当associativeEntityId不足以区分情况下使用，通常可关联设备、DP值、群组、规则等

```typescript
type AssociativeEntityValue = string;
```


### 示例代码

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

const removeSceneRule = async () => {
  try {
    const success = await removeRule({
      bizDomain: 'wirelessSwitch',
      devId: 'device_001',
      associativeEntityId: '1',
      associativeEntityValue: 'rule_001',
      gid: '12345678',
    });
    console.log('移除结果:', success);
  } catch (err) {
    console.error('移除失败:', err);
  }
};
```
