目录

创建规则

适用平台

Android、iOS

接口描述

hilink.createRule(String jsonString, String resultCallback)

创建任务执行的规则。例如,在某个时刻定时推送消息;或者当满足一定条件时,触发某个事件的执行。

请求参数

参数

类型

描述

jsonString

String

符合特定格式的json字符串,参见下面示例。

resultCallback

String

回调函数的方法名

jsonString数据参考格式:

{
    "name": "Rule01",
    "description": "string""conditions": [
        {
            "type": "DEVICE_DATA",
            "deviceInfo": {
                "devId": "2323-1221-...",
                "devType": "005",
                "path": "switch/on"
            },
            "operator": "=",
            "value": "1"
        }
    ]
    "author": "12222",
    "actions": [
        {
            "type": "DEVICE_CMD",
            "devId": "2323-1221-...",
            "devType": "01B",
            "cmd": {
                "sid": "switch",
                "messageType": "POST",
                "messageBody": {
                    "on": 1
                }
            }
        }
    ]
}

返回参数

{
    "ruleId": "*******",
    "name": "Rule01",
    "conditions": [
        {
            "id": "****",
            "type": "DEVICE_DATA",
            "deviceInfo": {
                "devId": "2323-1221-...",
                "devType": "005",
                "path": "switch/on"
            },
            "operator": "=",
            "value": "1"
        }
    ],
    "author": "12222",
    "actions": [
        {
            "type": "DEVICE_CMD",
            "id": "****",
            "devId": "2323-1221-...",
            "devType": "01B",
            "cmd": {
                "sid": "switch",
                "messageType": "POST",
                "messageBody": {
                    "on": 1
                }
            }
        }
    ]
}