SmartAlarmAbility.addCustomAlarm(options: AddCustomAlarmOptions)

Requires:
@ray-js/panel-sdk≥1.8.0

Description

Create or edit a custom alert rule

Parameters

ParameterTypeRequiredDescription
YesAlert rule configuration

Return Value

Type: Promise<AddCustomAlarmResult>
Tuple [the created/updated rule, the updated full rule list]

Referenced Types

typeAddCustomAlarmResult
[AddCustomAlarmBindResult, CustomAlarmList]
typeDpId
type DpId = number;
typeAddCustomAlarmBindResult
PropertyTypeDescription
associativeEntityValuestringAssociated entity value, used to distinguish alarm types
associativeEntityIdstringAssociated entity ID, typically the DP ID
bindIdnumberBinding ID
bizDomainstringBusiness domain, fixed as miniAppPanelSDKAlarm for alarms
enablebooleanWhether enabled
sourceEntityIdstringDevice ID
typeCustomAlarmList
export type CustomAlarmList = CustomAlarmRule[];
typeCustomAlarmRule
PropertyTypeDescription
triggerRuleIdstringID of the rule executed by the alarm
Details of the rule that triggers the alarm; see AlarmTriggerRuleVO
bizDomainstringBusiness domain identifier, fixed as miniAppPanelSDKAlarm in the alarm SDK
associativeEntityValuestringUsed when associativeEntityId is not sufficient to distinguish cases—for example, when the same DP is used but alarm types must be differentiated. You can use DpValue; generally not required.
sourceEntityIdstringDevice ID associated with the current alarm
namestringName or note
iconstringIcon
bindIdnumberBinding ID
associativeEntityIdstringDP ID associated with the current alarm
enablebooleanWhether enabled
typeAlarmTriggerRuleVO
PropertyTypeDescription
ownerIdstringHome ID
enabledbooleanWhether the alarm rule is enabled
idstringExecution rule ID
namestringAlarm name or note
Preconditions for executing actions; see AlarmPreCondition
Conditions for executing actions; see CustomAlarmCondition
Actions to execute; see CustomAlarmSceneAction
typeAlarmPreCondition
PropertyTypeDescription
Condition expression
condType"timeCheck"Condition type, fixed as timeCheck in the alarm SDK
idstringCondition ID
typeCustomAlarmCondition
PropertyTypeDescription
idstringCondition ID
ruleIdstringRule ID
entityIdstringData ID
entitySubIdsstringAbstract sub-data ID
exprstringCondition expression
typeCustomAlarmSceneAction
PropertyTypeDescription
idstringCondition ID
ruleIdstringScene ID
actionExecutorstringAction type, fixed as appPushTrigger in the alarm SDK
typeCustomAlarmPreConditionExpr
PropertyTypeDescription
timeZoneIdstringTime zone ID, e.g., Asia/Shanghai
startstringStart time in HH:mm, e.g., 00:00
timeIntervalstringTime interval, fixed as 'custom'
loopsstringRepeat days; '1111111' means all seven days are on, starting from Sunday
endstringEnd time in HH:mm, e.g., 23:59

Valid Values

AddCustomAlarmOptions.condition
ValueDescriptionSince
==--
<--
>--
<=--
>=--

Examples

Example

const [newRule, allRules] = await sdm.alarm.addCustomAlarm({
  name: 'High temperature alarm',
  condition: [['temp_current', '>', 40]],
  preCondition: {
    startTime: '08:00',
    endTime: '22:00',
    loops: '1111111',
  },
});
console.log('New rule:', newRule.bindId);