场景联动规则是设备与设备间联动关系的可视化编程方式,通过调用API方式,可获取场景联动规则列表。

请求Topic

获取网关IFTTT规则列表Topic:{srcApp}/request/linkedge/$Your_gateway_ProductKey/$Your_gateway_DeviceName/getSceneList

其中,$Your_gateway_ProductKey表示网关设备所属产品的ProductKey,$Your_gateway_DeviceName表示网关设备的名称。

请求Payload

{
  "requestId": "0bc458b5-47f6-472f-bd88-3624696e****",
  "timestamp": 1571219858000, # ms [Optional]
  "timeout":3,                # 最少1s,最多120s [Optional: default 4s]
  "version": "1.0"            # [Optional]
}

参数说明请参见Payload通用参数说明

响应Topic

获取场景联动规则响应Topic:linkedge/response/{srcApp}/$Your_gateway_ProductKey/$Your_gateway_DeviceName/getSceneList

其中,{srcApp}是发布消息的App名称,$Your_gateway_ProductKey表示网关设备所属产品的ProductKey,$Your_gateway_DeviceName表示网关设备的名称。

响应Payload

{
    "params":[
        {
            "times":0,
            "failureTimes":0,
            "lastState":null,
            "id":"a08d6c08bc1a440693ba9c9c8166****",
            "name":"ifttt",
            "running":true,
            "time":"2019-10-28T17:35:35+08:00",
            "uptime":5967,
            "actions":{
                "times":0,
                "failureTimes":0,
                "lastState":null
            },
            "conditions":{
                "times":0,
                "failureTimes":0,
                "lastState":null
            }
        }
    ],
    "requestId":"0bc458b5-47f6-472f-bd88-3624696e****",
    "version":"1.0",
    "timestamp":1572255341310,
    "code":0,
    "message":"success"
}

完整示例

./mosquitto_sub -u <your_username> -P <your_password> -p 8883 -t linkedge/response/testApp/a1PQ982****/gw_dev1/getSceneList -v &
./mosquitto_pub -u <your_username> -P <your_password> -p 8883 -t testApp/request/linkedge/a1PQ982****/gw_dev1/getSceneList -m "{\"requestId\": \"0bc458b5-47f6-472f-bd88-3624696e****\"}"
linkedge/response/testApp/a1PQ982****/gw_dev1/getSceneList {"params":{"code":0,"message":"success","data":[{"times":0,"failureTimes":0,"lastState":null,"id":"a08d6c08bc1a440693ba9c9c8166****","name":"ifttt","running":false,"time":"","uptime":0,"actions":{"times":0,"failureTimes":0,"lastState":null},"conditions":{"times":0,"failureTimes":0,"lastState":null}}]},"requestId":"0bc458b5-47f6-472f-bd88-3624696e****","version":"1.0","timestamp":1572229964988,"code":0,"message":"success"}
说明 其中:
  • mosquitto_submosquitto_pub是用来订阅和发送MQTT消息的命令行工具,详细信息请参见官方文档
  • <your_username>:替换为云端开启MQTT API中设置的访问边缘Open API的用户名。
  • <your_password>:替换为云端开启MQTT API中设置的访问边缘Open API的密码。