智能小程序 Ray 开发面板 SDK —— 智能设备模型通用能力告警推送 SDK 汇总(四)

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.devIdstring设备 ID,默认从设备环境中取
options.namestring告警的名称或备注
options.preConditionPreCondition告警触发的前置条件
options.condition[DpId, Operator, DpValue][]告警触发的功能点条件,如 [[1, '==', true]]
options.durationnumber告警触发的功能点条件持续时间,单位为秒

preCondition 对象包含以下属性:

属性数据类型说明
startTimestring告警可触发的开始时间,默认全天,即 00:00
endTimestring告警可触发的结束时间,默认全天,即 23:59
loopsstring告警可触发的日期,默认全周,即 '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 小程序开发。 

  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IoT砖家涂拉拉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值