Skip to content

queryScenes

调用该接口查询场景联动规则。

使用说明

无。

接口地址

/gateway/openapi

请求方式

POST

请求参数

请求头

名称类型描述
tokenauthorizationString平台颁发的token
apiCodeString固定值:queryScenes

QueryScenesRequest

名称类型是否必选描述
scenesIdString场景id

返回数据

名称类型描述
codeString调用成功,返回0,调用失败,查看错误信息。
msgString调用成功,提示"操作成功",调用失败,查看错误信息。
dataObject返回结果。结果内容如下详情,查看下方示例。

QueryScenesResponse

名称类型是否必选描述
scenesIdString场景唯一标识
nameString场景名称
descriptionString场景描述
conditionLogicString场景逻辑,可选值如下:
or:满足任意条件;
and:满足所有条件
onekey:一键执行
conditionRuleListList<ConditionRule>场景条件,如果conditionLogic=onekey,则场景条件为空
actionRuleListList<ActionRule>场景执行动作
statusInteger启用状态,0:未启用,1:已启用

ConditionRule

名称类型是否必选描述
idString场景条件id
typeString场景触发类型,可选值如下:
property 设备属性触发
event 设备事件触发
timing 定时触发
productKeyString产品key
productIdString产品id
deviceNameString设备名称
deviceDescString设备备注名
timingDataString定时数据,当type=timing时,才有值。
格式:星期+时间,周一至周日分别对应数字1-7,时间HH:mm
举例:周一周二周日10点触发,1,2,7,10:00
dataList<ConditionDataRule>具体属性条件

ConditionDataRule

名称类型是否必选描述
pidString设备属性pid,对应物模型里的pid
nameString设备属性名字,对应物模型里的pid的功能名称
compareString设备属性条件表达式,可选值如下:
>=
=
between
<=
<
!=
>
compareValueObject条件值,如果compare取值为between,则compareValue格式:30,50,表示温度在30-50之间,包含30和50

ActionRule

名称类型是否必选描述
productKeyString产品key
productIdString产品id
deviceNameString设备名称
deviceDescString设备备注名
pidString下发命令的pid,对应物模型里定义的命令pid
nameString下发命令的pid的名称,对应物模型里定义的命令pid的功能名称
commandIdString命令id
typeString动作类型,固定为command
orderNoInteger命令下发排序号
delayTimeInteger延时执行时间,单位:秒,范围:0-86400
dataObject命令下发数据,格式:{pid:value}
举例:给风机下发指令1,{"status":1}

示例

请求示例

json
{
    "scenesId":"cacfc113e07563fe8cd1864cdcd2f9b9"
}

返回示例

json
{
	"code": "0",
	"msg": "操作成功",
	"data": {
		"scenesId": "9b63f96d059f56934f4584859c7b4cf5",
		"name": "延迟",
		"description": "延迟执行",
		"conditionLogic": "or",
		"conditionRuleList": [
			{
				"id": "493bc3c1b27542e09386defb7889ffa3",
				"type": "property",
				"productKey": "F4wg3MgrM",
				"productId": "ead030a5252442f68f9a65137508f862",
				"deviceName": "*",
				"data": [
					{
						"pid": "status",
						"name": "status",
						"compare": "=",
						"compareValue": 1
					}
				],
				"productDevice": {
					"productKey": "F4wg3MgrM",
					"deviceName": "*",
					"deviceId": null,
					"productDeviceStr": "F4wg3MgrM&*",
					"productDeviceSlashStr": "F4wg3MgrM/*"
				}
			}
		],
		"actionRuleList": [
			{
				"productKey": "44yw3jwqj",
				"productId": "808a38503f93434fb43dddfd03c8a8ec",
				"deviceName": "B4JmbNmyN",
				"pid": "open",
				"commandId": "f089a0b394ae421a97c78e11b271ab9c",
				"type": "command",
				"data": {
					"status": 1
				},
				"delayTime": 10
			},
			{
				"productKey": "44yw3jwqj",
				"productId": "808a38503f93434fb43dddfd03c8a8ec",
				"deviceName": "B4JmbNmyN",
				"pid": "abcd",
				"commandId": "b5f851be7f8f4d60a53264361c749894",
				"type": "command",
				"data": {
					"eee": 10
				},
				"delayTime": 20
			}
		],
		"status": 1
	}
}

错误码

错误码错误码取值解决方案
iot.scenes.paramCheckFail字段 scenesId场景id不能为空。请传入场景id。
iot.scenes.notExist场景不存在。请传入正确的场景id。