bindRule

版本要求:
@ray-js/ray≥1.7.60

方法签名
bindRule(params: )

描述

将按键条件与场景规则关联,建立设备按键与联动规则的绑定关系

参数

参数类型必填说明
是绑定规则参数

返回值

类型:Promise<IBindRuleResponse>
绑定结果信息

引用对象

interfaceIBindRuleResponse
属性类型描述
associativeEntityIdAssociativeEntityId与面板/设备建立绑定关系,通常为设备ID、DP点、群组、规则,dpId#value等
associativeEntityValueAssociativeEntityValue当associativeEntityId不足以区分情况下使用,通常可关联设备、DP值、群组、规则等
bizDomainstring业务域
idnumber数据 ID
ownerIdstring家庭 ID
sourceEntityIdstring设备 ID
triggerRuleIdstring规则 ID
triggerRuleVOany执行动作设备信息
typeAssociativeEntityId
type AssociativeEntityId = string;
typeAssociativeEntityValue
type AssociativeEntityValue = string;

示例代码

import { bindRule } from '@ray-js/ray';

const bindSceneRule = async () => {
  try {
    const result = await bindRule({
      devId: 'device_001',
      associativeEntityId: '1',
      ruleId: 'rule_001',
      entitySubIds: '1',
      expr: [['$dp1', '==', 'true']],
      bizDomain: 'wirelessSwitch',
      gid: '12345678',
    });
    console.log('绑定成功, ID:', result.id);
  } catch (err) {
    console.error('绑定失败:', err);
  }
};