---
name: "SmartAlarmAbility.getCustomAlarmList"
mode: "api"
versionRequirements:
  - { name: "@ray-js/panel-sdk", version: "1.8.0" }
title: "getCustomAlarmList - 查询自定义创建的告警规则列表。"
summary: "查询设备自定义创建的告警规则列表，支持按功能点 ID 过滤。"
---

## SmartAlarmAbility.getCustomAlarmList

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

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

### 描述

查询自定义创建的告警规则列表

### 参数

`Params`

| 参数 | 类型 | 必填 | 描述 |
| --- | --- | --- | --- |
| `options` | `GetCustomAlarmListParams` | 否 | 查询参数 |

### 返回值

类型: `Promise<CustomAlarmList>`

自定义告警规则列表，包含 triggerRuleId、triggerRuleVO、bizDomain、bindId 等信息

### 引用对象

##### `type` GetCustomAlarmListParams

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `dpId` | `string` | 要创建告警规则的功能点 ID，不填则拉取所有 |
| `devId` | `string` | 设备 ID，不填则默认自动读取当前环境下的设备 ID |

##### `type` CustomAlarmList

```typescript
export type CustomAlarmList = CustomAlarmRule[];
```

##### `type` CustomAlarmRule

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `triggerRuleId` | `string` | 告警执行的规则 id |
| `triggerRuleVO` | `AlarmTriggerRuleVO` | 触发告警规则的详细信息，详见 AlarmTriggerRuleVO 定义 |
| `bizDomain` | `string` | 业务域标识，在告警 SDK 下固定为 miniAppPanelSDKAlarm |
| `associativeEntityValue` | `string` | 当 associativeEntityId 不足以区分情况下使用，比如使用的是同一个功能点时又要区分告警类型的情况下，可以使用 DpValue，一般情况下用不到 |
| `sourceEntityId` | `string` | 和当前告警相关联的设备 ID |
| `name` | `string` | 名称或备注 |
| `icon` | `string` | 图标 |
| `bindId` | `number` | 绑定 ID |
| `associativeEntityId` | `string` | 和当前告警相关联的功能点 DP ID |
| `enable` | `boolean` | 是否启用 |

##### `type` AlarmTriggerRuleVO

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `ownerId` | `string` | 家庭 id |
| `enabled` | `boolean` | 告警规则是否启用 |
| `id` | `string` | 执行规则 id |
| `name` | `string` | 告警名称或备注 |
| `preConditions` | `AlarmPreCondition[] \| unknown[]` | 执行动作的前置条件，详见 AlarmPreCondition 定义 |
| `conditions` | `CustomAlarmCondition[] \| unknown[]` | 执行动作的条件，详见 CustomAlarmCondition 定义 |
| `actions` | `CustomAlarmSceneAction[] \| unknown[]` | 执行的动作，详见 CustomAlarmSceneAction 定义 |

##### `type` DpValue

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

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

##### `type` AlarmPreCondition

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `expr` | `CustomAlarmPreConditionExpr` | 条件表达式 |
| `condType` | `"timeCheck"` | 条件类型，告警 SDK 固定为 timeCheck |
| `id` | `string` | 条件 ID |

##### `type` CustomAlarmCondition

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `id` | `string` | 条件 ID |
| `ruleId` | `string` | 规则 ID |
| `entityId` | `string` | 数据 ID |
| `entitySubIds` | `string` | 抽象子数据 ID |
| `expr` | `string` | 条件的表达式 |

##### `type` CustomAlarmSceneAction

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `id` | `string` | 条件 id |
| `ruleId` | `string` | 场景 id |
| `actionExecutor` | `string` | 动作类型，在告警 SDK 下固定为 appPushTrigger |

##### `type` CustomAlarmPreConditionExpr

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `timeZoneId` | `string` | 时区 id，如 Asia/Shanghai |
| `start` | `string` | 开始时间，格式为 HH:mm，如 00:00 |
| `timeInterval` | `string` | 时间间隔，固定为 'custom' |
| `loops` | `string` | 循环日期，'1111111' 说明为一周七天均开启，其中起始时间为周日 |
| `end` | `string` | 结束时间，格式为 HH:mm，如 23:59 |


### 示例代码

#### 示例

```typescript
// 获取所有自定义告警
const rules = await sdm.alarm.getCustomAlarmList();
console.log('自定义告警数量:', rules.length);

// 按功能点筛选
const dpRules = await sdm.alarm.getCustomAlarmList({ dpId: '1' });
```
