addCustomAlarm
描述
新增或修改自定义的告警规则。
类型
interface LinkageRule {
triggerRuleId: string;
triggerRuleVO: TriggerRuleVO;
bizDomain: string;
associativeEntityValue?: string;
sourceEntityId: string;
name?: string;
icon?: string;
bindId: number;
associativeEntityId?: string;
}
declare type DpValue = boolean | number | string;
declare type DpId = number;
declare type Operator = '==' | '<' | '>' | '<=' | '>=';
export declare type AddCustomAlarmOptions = {
devId?: string;
name?: string;
preCondition?: {
startTime: string;
endTime: string;
loops: string;
};
condition: [DpId, Operator, DpValue][];
duration?: number;
};
export declare class SmartAlarmAbility implements SmartDeviceAbility {
addCustomAlarm: (options: AddCustomAlarmOptions) => Promise<[LinkageRule, LinkageRule[]]>;
}
请求参数
参数 | 数据类型 | 说明 | 是否必填 |
---|---|---|---|
options.devId | string | 设备 ID,默认从设备环境中取 | 否 |
options.name | string | 告警的名称或备注 | 否 |
options.preCondition | PreCondition | 告警触发的前置条件 | 否 |
options.condition | [DpId, Operator, DpValue][] | 告警触发的功能点条件,如 [[1, '==', true]] | 是 |
options.duration | number | 告警触发的功能点条件持续时间,单位为秒 | 否 |
preCondition 对象包含以下属性:
属性 | 数据类型 | 说明 |
---|---|---|
startTime | string | 告警可触发的开始时间,默认全天,即 00:00 |
endTime | string | 告警可触发的结束时间,默认全天,即 23:59 |
loops | string | 告警可触发的日期,默认全周,即 '1111111',从周日开始 |
返回参数
参数 | 数据类型 | 说明 |
---|---|---|
result[0] | LinkageRule | 当前新增或修改的告警规则 |
result[1] | LinkageRule[] | 新增或修改的告警规则列表 |
LinkageRule
定义请查看 getCustomAlarmList#返回参数
请求示例
import { SmartAlarmAbility } from '@ray-js/panel-sdk';
const Alarm = new SmartAlarmAbility();
const result = await Alarm.addCustomAlarm.addCustomAlarm({
condition: [
[1, '<', 30],
[1, '>=', 85],
],
});
console.log('=== result: ', result);
👉 立即免费领取开发资源,体验涂鸦 MiniApp 小程序开发。
返回示例
️🚫 注意,返回示例仅供参考,其包含字段大于返回参数定义范围,请勿使用除本文返回参数定义以外的返回数据,否则可能会导致程序异常。
[
{
"triggerRuleId": "Ecrx5Bhx4sqvUp9B",
"triggerRuleVO": {
"matchType": 1,
"offGwSync": false,
"outOfWork": 0,
"ownerId": "152952332",
"matchStatus": 0,
"ruleGenre": 2,
"offGwSyncSuccess": false,
"id": "Ecrx5Bhx4sqvUp9B",
"runtimeEnv": "prod",
"newLocalScene": false,
"coverIcon": "",
"commonField": "{}",
"name": "门磁状态",
"containDeviceDelete": false,
"conditions": [
{
"icon": "",
"orderNum": 1,
"serverProperty": "",
"enabled": true,
"uid": "ay15234251194155zQ3F",
"entitySubIds": "1",
"ruleType": 3,
"extra": "",
"expr": [
[
"$dp1",
"==",
true
]
],
"attribute": 0,
"id": "eRJ9GihAaQDL75n9vpOE",
"ruleId": "Ecrx5Bhx4sqvUp9B",
"expression": "[[\"$dp1\",\"==\",true]]",
"entityType": 1,
"entityId": "vdevo169579725602982",
"devDelMark": false,
"handleStrategy": "",
"serviceProvider": "",
"condType": 1,
"status": true
}
],
"actions": [
{
"gmtModified": 1697466697571,
"offGwSync": false,
"actionExecutor": "appPushTrigger",
"orderNum": 1,
"enabled": true,
"uid": "ay15234251194155zQ3F",
"executorProperty": {
"deviceExecuteLog": 1
},
"attribute": 0,
"id": "BVvtnjVZbx5jTcrWSJMp",
"ruleId": "Ecrx5Bhx4sqvUp9B",
"actionStrategy": "repeat",
"devDelMark": false,
"status": true
}
],
"status": true,
"gmtModified": 1697467782751,
"code": "",
"preConditions": [
{
"expr": {
"timeZoneId": "Asia/Shanghai",
"start": "00:00",
"timeInterval": "custom",
"loops": "1111111",
"end": "23:59"
},
"condType": "timeCheck",
"id": "V0ElkQ3Aia3HEWGOEXB1"
}
],
"scenarioRule": false,
"linkageType": 0,
"orderWeight": 1,
"needCleanGidSid": false,
"enabled": false,
"uid": "ay15234251194155zQ3F",
"ruleType": 3,
"isLogicRule": false,
"attribute": 32,
"boundForPanel": false,
"isAlarmIssue": false,
"stickyOnTop": false,
"boundForWiFiPanel": false,
"needValidOutOfWork": false,
"gmtCreate": 1697466697551,
"iotAutoAlarm": false,
"localLinkage": false,
"ruleSource": 0,
"auditStatus": 0,
"displayColor": "",
"forceCloudTrigger": false
},
"icon": "",
"bindExecutor": "",
"bizDomain": "miniAppPanelSDKAlarm",
"associativeEntityValue": "",
"ownerId": "152952332",
"conditionRuleId": "",
"bindId": 2899540,
"uid": "ay15234251194155zQ3F",
"enable": false,
"sourceEntityId": "vdevo169579725602982",
"name": "",
"property": "",
"id": 2899540,
"associativeEntityId": "1",
"status": true
},
[
{
"triggerRuleId": "Ecrx5Bhx4sqvUp9B",
"triggerRuleVO": {
"matchType": 1,
"offGwSync": false,
"outOfWork": 0,
"ownerId": "152952332",
"matchStatus": 0,
"ruleGenre": 2,
"offGwSyncSuccess": false,
"id": "Ecrx5Bhx4sqvUp9B",
"runtimeEnv": "prod",
"newLocalScene": false,
"coverIcon": "",
"commonField": "{}",
"name": "门磁状态",
"containDeviceDelete": false,
"conditions": [
{
"icon": "",
"orderNum": 1,
"serverProperty": "",
"enabled": true,
"uid": "ay15234251194155zQ3F",
"entitySubIds": "1",
"ruleType": 3,
"extra": "",
"expr": [
[
"$dp1",
"==",
true
]
],
"attribute": 0,
"id": "eRJ9GihAaQDL75n9vpOE",
"ruleId": "Ecrx5Bhx4sqvUp9B",
"expression": "[[\"$dp1\",\"==\",true]]",
"entityType": 1,
"entityId": "vdevo169579725602982",
"devDelMark": false,
"handleStrategy": "",
"serviceProvider": "",
"condType": 1,
"status": true
}
],
"actions": [
{
"gmtModified": 1697466697571,
"offGwSync": false,
"actionExecutor": "appPushTrigger",
"orderNum": 1,
"enabled": true,
"uid": "ay15234251194155zQ3F",
"executorProperty": {
"deviceExecuteLog": 1
},
"attribute": 0,
"id": "BVvtnjVZbx5jTcrWSJMp",
"ruleId": "Ecrx5Bhx4sqvUp9B",
"actionStrategy": "repeat",
"devDelMark": false,
"status": true
}
],
"status": true,
"gmtModified": 1697467782751,
"code": "",
"preConditions": [
{
"expr": {
"timeZoneId": "Asia/Shanghai",
"start": "00:00",
"timeInterval": "custom",
"loops": "1111111",
"end": "23:59"
},
"condType": "timeCheck",
"id": "V0ElkQ3Aia3HEWGOEXB1"
}
],
"scenarioRule": false,
"linkageType": 0,
"orderWeight": 1,
"needCleanGidSid": false,
"enabled": false,
"uid": "ay15234251194155zQ3F",
"ruleType": 3,
"isLogicRule": false,
"attribute": 32,
"boundForPanel": false,
"isAlarmIssue": false,
"stickyOnTop": false,
"boundForWiFiPanel": false,
"needValidOutOfWork": false,
"gmtCreate": 1697466697551,
"iotAutoAlarm": false,
"localLinkage": false,
"ruleSource": 0,
"auditStatus": 0,
"displayColor": "",
"forceCloudTrigger": false
},
"icon": "",
"bindExecutor": "",
"bizDomain": "miniAppPanelSDKAlarm",
"associativeEntityValue": "",
"ownerId": "152952332",
"conditionRuleId": "",
"bindId": 2899540,
"uid": "ay15234251194155zQ3F",
"enable": false,
"sourceEntityId": "vdevo169579725602982",
"name": "",
"property": "",
"id": 2899540,
"associativeEntityId": "1",
"status": true
}
]
]
👉 立即免费领取开发资源,体验涂鸦 MiniApp 小程序开发。