import { createAction, openPreConditionPage } from '@ray-js/ray'; import { GetTTTSuccessData, GetTTTParams } from '../../types'; export interface ExtProperty { /** * 绑定的规则id集合,以逗号(,)分割,填充该值能在查询时返回绑定的相关规则详细信息 */ bindRuleIds: string; /** * 多控组id */ multiGroupId: number; /** * 绑定推送数据 */ bindPushData: Record; /** * 解绑推送数据 */ unbindPushData: Record; } export type BindExecutor = 'syncDataExecutor' | 'syncAndUnbindExecutor' | 'multiDataExecutor' | 'dynamicFenceGpsExecutor'; export type BizDomain = 'lightControl' | 'lightGroupControl' | 'pusherBindSensor' | 'schmiedRemoteControl' | 'schmiedControlScene' | 'doorLockAlarmBind' | 'lightBindMulti' | 'dynamicFenceGpsAlarmBind' | 'sunsetrise' | 'wirelessSwitchBindScene' | 'nbFurnaceBind' | 'thermostatDeviceBind' | 'suoyeDeviceGroupBind' | 'vealitePirPanelBind' | 'onOffDeviceBind' | 'hsyFurnaceBind'; export interface Condition { /** * 条件 id */ id: string; /** * 规则 id */ ruleId: string; /** * 条件类型 * 1. 表达式匹配 * 2. 简单匹配 */ condType: number; /** * @internal * 规则类型 * 1. 系统定义 * 2. 商家定义 * 3. 用户定义 * 4. 安防规则 * 5. 服务定义(如 dp 点转发) */ ruleType: number; /** * 用户 id */ uid: string; /** * @internal * 条件实体类型 * 1. 数据点上报。 示例:[["$dp1", "==", "alarm"]]。entityId: 产品id、设备id * 2. APP 动作。 * 3. 环境数据。示例:[["$temp", ">", -40]]。 entityId: 城市 id * 4. 统计结果 * 5. 手动触发 * 6. 定时触发。示例: [{"date":"20210302","timeZoneId":"Asia/Shanghai","loops":"1111111","time":"17:01"}]。 entityId: timer * 7. 定时延迟触发。示例:[["$dp92","==","2"]]。entityId: 设备id * 8. MQTT告警。 entityId: 产品id * 9. 人脸检测。示例:[["$bknow","==",false]]。 entityId: 产品id/设备id * 10. 地理围栏。示例:[["$action","==","enter"]]。entityId: 地理围栏id * 11. 门锁识别。 示例:[[["$devId","lockRecognition","$allData"],"inRange","31538721"]]。entityId: 设备id * 12. 安防状态。示例:[["$alarm","==","WATER_LEAK”]], [["$mode","==","2"]] * 13. 合成功能条件计算。示例:[[[["$dp1","==",true],"condCalculate","$calObj"],"==",true]]。entityId: 设备id * 14. 安防地理围栏。 示例:[["$mode","==","arrived"]] * 15. 外部通用事件。示例:[["$roomCheckStatus","==",2]]。entityId: saas的id,如: hotel_saas_26849652 * 16. 日出日落定时任务。示例:[{"sunset":20,"cityId":"793409530309513216","type":"sunset"}]。entityId: sunsetriseTimer * 17. woox app定制地理围栏 * 19. dp转发 * 20. 云端触发 * 21. 语音事件。示例:[["$trigger","==","1"]]。entityId:语音事件id,如 voice_event_20070030 * 22. 产品告警非dp点事件。示例:[["$device_online","==","online"]]]。entityId: 产品id */ entityType: number; /** * 数据 id */ entityId: string; /** * 抽象的子数据 id * 如是entityType=1的情况,即普通的dp点上报,则entity_id为设备id,entity_sub_ids为上报的dpId */ entitySubIds: string; /** * 条件持续信息 */ duration: number; /** * 条件的表达式 */ expr: string; /** * 顺序码,表示条件的排序 */ orderNum: number; /** * 额外信息 */ extraInfo: string; /** * 状态 * 0. 无效 * 1. 有效 */ status: number; /** * 是否启用 */ enabled: boolean; } export type IAction = GetTTTSuccessData; export type ICondition = Condition; export interface TriggerRuleVO { /** * 规则 code */ code: string; /** * 匹配类型 * 1. 任意条件,多个条件里只要有一个即触发(即 或关系)。 * 2. 全部满足,多个条件全部满足才触发。 * 3. 表态式匹配, 根据 rule 字段的 expr 确定是否满足,条件满足时触发。 */ matchType: number; /** * 家庭id */ ownerId: string; /** * 规则是否启用 */ enabled: boolean; /** * 用户 id */ uid: string; isLogicRule: boolean; /** * @internal * 规则类型 * 1. 系统定义 * 2. 商家定义 * 3. 用户定义 * 4. 安防规则 * 5. 服务定义(如 dp 点转发) */ ruleType: number; /** * 面板绑定 */ boundForPanel: boolean; /** * 属性 * 根据枚举值的2次幂进行位运算 */ attribute: number; /** * 执行规则 id */ id: string; /** * 运行环境 */ runtimeEnv: string; /** * 是否显示在首页顶部 */ stickyOnTop: boolean; newLocalScene: boolean; boundForWiFiPanel: boolean; /** * 图标 */ coverIcon: string; iotAutoAlarm: boolean; /** * 通用json字段,比如本地联动会存网关id,gwId */ commonField: string; /** * 是否本地联动 */ localLinkage: boolean; ruleSource: number; /** * 联动名称或备注 */ name: string; /** * 审核状态 * 0. 未审核 * 1. 审核通过 * 2. 审核不通过 */ auditStatus: number; /** * 背景颜色 */ displayColor: string; /** * 执行条件 */ conditions: ICondition[]; /** * 执行动作 */ actions: IAction[]; } export interface LinkageRule { /** * 执行规则 id */ triggerRuleId: string; triggerRuleVO: TriggerRuleVO; /** * 绑定规则信息列表,会根据 property 中 bindRuleIds 获取,没有则无 */ bindRuleList?: any[]; /** * 绑定执行器,通常情况下不传,具体由云端开发安排具体使用场景 */ bindExecutor?: string; /** * 业务域 */ bizDomain: string; /** * 当associativeEntityId不足以区分情况下使用,通常可关联设备、DP值、群组、规则等 */ associativeEntityValue?: string; /** * 条件规则 id */ conditionRuleId?: string; /** * 面板设备/设备的ID */ sourceEntityId: string; /** * 名称或备注 */ name?: string; /** * 图标 */ icon?: string; /** * 扩展字段,json格式 */ property?: ExtProperty; /** * 绑定 id */ bindId: number; /** *与面板/设备建立绑定关系,通常为设备ID、DP点、群组、规则,dpId#value等 */ associativeEntityId?: string; } export interface LinkageStyle { /** * 颜色 */ color: string; /** * 图标 */ icon: string; /** * 图片 */ image: string; } export interface BindTriggerRuleVo { preConditions?: Array; conditions?: Array; actions?: Array; } export interface LinkageBindParams { /** * 业务域标记,找对应开发确认 必传 */ bizDomain: BizDomain; /** * 设备id或群组id 被绑,如:面板设备id 必传 */ sourceEntityId: string; /** * 绑定设备ID、DP点、群组ID、规则ID等,非必传 */ associativeEntityId?: string; /** * 场景ID、门磁告警类别等,非必传 */ associativeEntityValue?: string; /** * 名称,非必传 */ name?: string; /** * 图标,非必传 */ icon?: string; /** * json格式,详细信息见 ExtProperty 扩展字段,非必传 */ property?: string; /** * 绑定所需的条件及动作参数 */ triggerRuleVO: BindTriggerRuleVo; } export type LinkageDetail = TriggerRuleVO; export interface GetRuleParams { /** * 业务域 */ bizDomain: BizDomain; /** * 设备 id */ sourceEntityId: string; /** * 保存时无该参数,则不传,若存在该参数,又需要查询多个的话,可不传 */ associativeEntityId?: string; } export interface GetBriefRuleParams { /** * 设备 id */ devId?: string; /** * 家庭id */ homeId?: string; } export interface CreateConditionParams { /** * 条件类型 */ type: string; /** * 已创建的条件字符串 */ condition?: string; /** * 所创建或修改的条件索引 */ index?: number; } export type EditConditionParams = CreateConditionParams; export type ActionType = 'device' | 'smart' | 'remind' | 'delay'; export type SmartType = 'scene' | 'auto'; export interface CreateActionParams { /** * 动作类型 */ createType: ActionType; /** * 智能类型 */ smartType: SmartType; /** * 动作列表 */ actionArray: IAction[]; } export type EditActionParams = CreateActionParams; export interface SelectStyleParams { /** * 智能类型 */ smartType?: SmartType; /** * 图标颜色 */ color?: string; /** * 已选择的图标 */ icon?: string; /** * 已选择的图片 */ image?: string; } export type SelectStyleResult = Omit; export interface BindTriggerRuleVO { /** * 前置条件集合,无前置条件,则无该对象 */ preConditions?: Array; /** * 条件集合,无条件,则不传 */ conditions?: Array; /** * 动作集合,无动作,则不传 */ actions?: Array; } export interface BindLinkageParams { /** * 业务域 */ bizDomain: BizDomain; /** * 设备 ID */ sourceEntityId: string; /** * 绑定设备ID、DP点、群组ID、规则ID等,非必传 */ associativeEntityId?: string; /** * 场景ID、门磁告警类别等,非必传 */ associativeEntityValue?: string; /** * 名称 */ name?: string; /** * 图标 */ icon?: string; /** * json格式,详细信息见 ExtProperty 扩展字段,非必传 */ property?: string; /** * 规则详情 */ triggerRuleVO: BindTriggerRuleVO; } export interface UnbindLinkageParams { /** * 绑定联动id */ bindId?: string; /** * 业务域 */ bizDomain: BizDomain; /** * 设备 ID */ sourceEntityId: string; /** * 绑定设备ID、DP点、群组ID、规则ID等,非必传 */ associativeEntityId?: string; /** * 场景ID、门磁告警类别等,非必传 */ associativeEntityValue?: string; } export interface ToggleLinkageParams { /** * 绑定 ID */ bindId: string; /** * 需要切换的状态 */ enable: boolean; } export type PreConditionParams = GetTTTParams; export type PreCondition = GetTTTSuccessData; export interface WifiBindParams { /** * 设备 id */ devId: string; /** * dp id */ dpId: number; /** * dp 对应值 */ dpValue: string; /** * 场景 ID */ ruleId: string; /** * 设备按钮 id */ btnId: number; /** * 场景类型;1: allDevice; 0: 非 allDevice; */ panelType?: number; } export interface WifiRemoveParams { /** * 设备 id */ devId: string; /** * 设备按钮 id */ btnId: number; } export interface ApplyMeshBindIdParams { /** * 设备 id */ devId: string; /** * 绑定类型 2: sigMesh */ bindType: number; } export interface CancelMeshBindParams { /** * 设备 id */ devId: string; /** * 绑定类型 2: sigMesh */ bindType: number; /** * 本地控制ID */ localControlId: number; } export interface MeshBindParams { /** * 设备 id */ devId: string; /** * 本地控制ID */ localControlId: number; /** * 规则 id */ ruleId: string; } export interface MeshRebindParams { /** * 场景详情列表主键ID */ id: number; /** * 按键ID */ btnId: number; }