提供一组客户端用户创建和配置自动化场景的接口,可以实现触发某些条件时,执行某些任务的功能,如当到达某个时间时设备自动开启等功能。
说明
场景服务2.0已升级,新增了家、空间、群组控制等功能。若您无需使用这些功能,请查看
历史版本场景服务2.0。
场景规则说明
场景的创建、编辑、删除、查询
触发条件和执行任务
场景自动化的执行
定时场景
App小组件
场景规则说明
场景规则用于描述动作由谁触发(Trigger),需要满足哪些条件(Condition),触发后要执行的动作(Action)。目前支持两种规则形式:IFTTT(If
This Than That)和CA(Condition&Action)。其中IFTTT支持Trigger、Condition、Action节点;CA是对IFTTT的简化,将Trigger与Condition合并在一起作为“条件”。
IFTTT规则
以下是一个典型的场景规则示例,表示当设备sensor_01的someone_exist属性值等于1时场景将被触发(Trigger),此时会检查当前时间是否处于6:00至22:00之间(Condition),如果是,则把设备light 的开关属性设置为on(Action)。
{
"type":"IFTTT",
"trigger":{
"uri":"trigger/device/property",
"params":{
"iotId":"sensor_01_iotId",
"propertyName":"someone_exist",
"compareType":"==",
"compareValue":1
}
},
"condition":{
"uri":"logical/and",
"items":[
{
"params":{
"cron":"0-0 6-22 * * 1,2,3",
"cronType":"linux",
"timezoneID":"Shanghai"
},
"uri":"condition/timeRange"
}
]
},
"action":[
{
"uri":"action/device/setProperty",
"params":{
"iotId":"light_iotId",
"propertyName":"onOff",
"propertyValue":"on"
}
}
]
}
以上例子展示了 IFTTT 类型的场景规则,可以看到规则中包含了四个节点, 分别是:
名称 |
描述 |
type |
表示场景规则的类型,可取值为 IFTTT、CA。 |
trigger |
表示场景的触发器,例如时间点、设备属性。一个场景中可以有多个触发器,彼此之间是“或”的关系。场景中也可以没有触发器,这时可以通过接口调用来手动触发场景。 |
condition |
表示场景被触发后的过滤条件,例如时间段限制、设备属性限制。一个场景中可以有多个过滤条件,彼此之间是“与”的关系。场景中也可以没有过滤条件,这时场景触发后会不经过滤直接执行相应的动作。 |
action |
表示场景被触发,且满足过滤条件时,所需执行的动作,例如设置设备属性、执行另一个场景。一个场景中可以有多个动作。场景中必须至少有一个动作。 |
以下例子展示了多个trigger多个condition的场景规则。 此时会使用logical/or节点封装多个trigger,使用logical/and节点封装多个condition。
{
"type":"IFTTT",
"trigger":{
"uri":"logical/or",
"items":[
{
"uri":"trigger/device/property",
"params":{
"productKey":"pk_sensor",
"deviceName":"sensor_01",
"propertyName":"someone_exist",
"compareType":"==",
"compareValue":1
}
},
{
"uri":"trigger/timer",
"params":{
"cron":"0 0 10 * *",
"cronType":"linux"
}
}
]
},
"condition":{
"uri":"logical/and",
"items":[
{
"uri":"condition/device/property",
"params":{
"productKey":"pkxxxxon",
"deviceName":"txxxxce",
"propertyName":"soxxxxrty",
"compareType":"<",
"compareValue":10
}
},
{
"params":{
"cron":"0-0 9-12 * * 1,2,3",
"cronType":"linux",
"timezoneID":"Asia/Shanghai"
},
"uri":"condition/timeRange"
}
]
},
"action":[
{
"uri":"action/device/setProperty",
"params":{
"productKey":"pk_action",
"deviceName":"test_device",
"propertyName":"onOff",
"propertyValue": "on"
}
},
{
"uri":"action/scene/trigger",
"params":{
"automationRuleId":"some_scene_id"
}
}
]
}
以上规则表示:每天十点或设备sensor_01的someone_exist属性值等于1时场景触发,如果设备test_device的some_property属性小于10
并且当前处于九点和十二点之间,则执行动作,将test_device的onOff属性设置为on,并触发另一个场景执行。
CA规则
除了IFTTT类型外,还支持CA类型的规则。CA规则是IFTTT规则的简化,规则中包含 type,mode,condition和 action节点。其中:
名称 |
描述 |
type |
表示场景规则的类型,可取值为 IFTTT, CA |
mode |
CA规则的模式,可取值为 any 表示任何一个条件满足就执行动作,或 all 表示所有条件满足时才执行动作。 |
condition |
场景的触发条件,例如时间点、设备属性、时间段等。一个场景可以有多个触发条件。 |
action |
表示场景被触发时所需执行的动作,例如设置设备属性、执行另一个场景。一个场景中可以有多个动作。场景中必须至少有一个动作。 |
以下是CA类型场景规则的一个示例。
{
"type":"CA",
"mode":"all",
"condition":[
{
"uri":"condition/device/property",
"params":{
"productKey":"pk_condition",
"deviceName":"sensor_01",
"propertyName":"some_property",
"compareType":">",
"compareValue":"300"
}
},
{
"uri":"condition/device/property",
"params":{
"productKey":"pk_condition",
"deviceName":"sensor_02",
"propertyName":"BarrierState",
"compareType":"in",
"compareValue":[
0,
1,
2
]
}
},
{
"uri":"condition/timer",
"params":{
"cron":"0 05 10 * *",
"cronType":"linux"
}
}
],
"action":[
{
"uri":"action/device/setProperty",
"params":{
"productKey":"pk_action",
"deviceName":"test_device",
"propertyName":"LightStatus",
"propertyValue": 1
}
}
]
}
以上规则表示: 当设备 sensor_01 的 some_property 属性大于 300、设备 sensor_02 的 BarrierState 属性取值在 0,1,2
之间、时间点在 10:05 这几个条件全部满足时,将设备 test_device 的 LightStatus 属性设置为 1。
Trigger组件
目前支持的Trigger组件包括:
url |
描述 |
|
trigger/timer |
定时触发 |
|
trigger/device/property |
设备属性触发 |
|
trigger/device/event |
设备事件触发 |
|
trigger/timer 参数描述
参数 |
类型 |
描述 |
参考 |
cron |
String |
定时表达式 |
cron表达式格式:http://crontab.org/ |
cronType |
String |
表达式类型,可取值为 linux, quartz_cron
linux:表示crontab类型,5位,不能设置年
quartz_cron:quartz类型cron,7位,支持年。当前只能最小设置分钟级别,第一位秒级必须是0
|
cron表达式格式:http://crontab.org/ |
timezoneID |
String |
时区ID,可空,表示将按照哪个时区来执行定时表达式。如果不设置,默认为智能生活平台云端服务所在区域,建议传入该参数,明确指定时区 |
示例:Asia/Shanghai |
Corn表达式类型与范例
表达式类型 |
表达式结构 |
表达式字段 |
表达式示范 |
linux |
${minute} ${hour} ${day of month} ${month} ${day of week} |
- minute 0-59
- hour 0-23
- day of month 0-31
- month 0-12
- day of week 0-7
|
1 3 * * *
|
quartz_cron |
${second} ${minute} ${hour} ${day of month} ${month} ${day of week} ${year}
|
- second 必须为 0
- minute 0-59
- hour 0-23
- day of month 0-31
- month 0-12
- day of week 0-7
- year(可省略,省略则表示每年会触发)
|
0 * 14 * * ? 2019
说明
在2019年每天下午2点到下午2:59期间的每1分钟触发
|
trigger/timer 示例
{
"uri":"trigger/timer",
"params":{
"cron":"* * * * *",
"cronType":"linux",
"timezoneID":"Asia/Shanghai"
}
}
trigger/device/property 参数描述
参数 |
类型 |
描述 |
productKey |
String |
设备产品键 |
deviceName |
String |
设备名称 |
propertyName |
String |
待比较的设备属性名 |
compareType |
String |
比较类型,如>、<、>=、==、<=、!=、in、like等 |
compareValue |
Object |
比较的值 |
trigger/device/property示例
{
"uri":"trigger/device/property",
"params":{
"productKey":"test_pk",
"deviceName":"test_dn",
"propertyName":"temp",
"compareType":">",
"compareValue":30
}
}
trigger/device/event参数描述
参数 |
类型 |
描述 |
|
productKey |
String |
设备产品键 |
|
deviceName |
String |
设备名称 |
|
eventCode |
String |
设备事件Code,可为空 |
|
propertyName |
String |
设备属性名称 |
|
compareType |
String |
比较类型,如>、<、>=、==、<=、!=、in、like等 |
|
compareValue |
Object |
比较的值 |
|
trigger/device/event示例
{
"uri":"trigger/device/event",
"params":{
"productKey":"test_pk",
"deviceName":"test_dn",
"eventCode":"temp_warning",
"propertyName":"temp",
"compareType":">",
"compareValue":30
}
}
Condition组件
目前支持的condition组件包括:
url |
描述逻辑 |
condition/timeRange |
比较当前时间是否在一个区间内 |
condition/device/property |
设备属性过滤 |
condition/timeRange 参数描述
参数 |
类型 |
描述 |
cron |
String |
20-25 11-23 * * 1,2,3 表示每周一、二、三的11:20到23:25之间允许执行 |
cronType |
String |
cron表达式类型,取值是linux |
timezoneID |
String |
示例:Asia/Shanghai |
condition/timeRange示例
{
"params":{
"cron":"0-0 9-12 * * 1,2,3",
"cronType":"linux",
"timezoneID":"Asia/Shanghai"
},
"uri":"condition/timeRange"
}
condition/device/property参数描述
参数 |
类型 |
描述 |
productKey |
String |
设备产品键 |
deviceName |
String |
设备名称 |
propertyName |
String |
设备属性 |
compareType |
String |
比较类型,如>、<、>=、==、<=、!=、in、like等 |
compareValue |
Object |
比较值 |
condition/device/property 示例
{
"uri":"condition/device/property",
"params":{
"productKey":"test_product",
"deviceName":"test_device",
"propertyName":"temp",
"compareType":">",
"compareValue":30
}
}
Action组件
目前支持的action组件包括:
url |
描述逻辑 |
action/device/setProperty |
设置设备属性 |
action/device/invokeService |
调用设备服务 |
action/scene/trigger |
触发另一个场景,如果被触发的场景包含condition,并且 condition没有被满足,那么被触发场景的action不会被执行。 |
action/automation/setSwitch |
启用或停用另一个场景设置 |
action/scene/trigger 参数描述
参数 |
类型 |
描述 |
示例 |
|
sceneId |
String |
场景id |
无 |
|
action/scene/trigger 示例
{
"uri":"action/scene/trigger",
"params":{
"sceneId":"xxx"
}
}
action/device/invokeService 参数描述
参数 |
类型 |
描述 |
示例 |
|
iotId |
String |
设备Id |
无 |
|
serviceName |
String |
服务名称 |
无 |
|
serviceArgs |
JSON |
服务参数 |
{"warningStatus":"off","level":"init"} |
|
action/device/invokeService 示例
{
"uri":"action/device/invokeService",
"params":{
"iotId":"xxxx",
"serviceName":"clearWarningStatus",
"serviceArgs":{
"warningStatus":"off",
"level":"init"
}
}
}
action/device/setProperty 参数描述
参数 |
类型 |
描述 |
示例 |
iotId |
String |
设备id |
无 |
propertyName |
String |
要设置的属性的名称 |
PowerSwitch |
propertyValue |
Object |
要设置的属性的值 |
1 |
delayedExecutionSeconds |
Integer |
延时执行时间,默认为空,即立即执行,设置了该值后才执行延时操作。单位为秒,最小1s,最大86400s(24小时) |
10 |
action/device/setProperty 示例
{
"uri":"action/device/setProperty",
"params":{
"iotId":"xxxx",
"propertyName":"PowerSwitch",
"propertyValue":1,
"delayedExecutionSeconds":10
}
}
action/automation/setSwitch 参数描述
参数 |
类型 |
描述 |
示例 |
automationRuleId |
String |
要启用或停用的场景id |
无 |
switchStatus |
Integer |
0 表示停用,1 表示启用 |
1 |
action/automation/setSwitch 示例
{
"uri":"action/automation/setSwitch",
"params":{
"automationRuleId":"xxxx",
"switchStatus":0
}
}
CaCondition组件
目前支持的caCondition组件包括:
url |
描述逻辑 |
condition/timer |
定时器,作用和参数与IFTTT类型下的trigger/timer组件相同 |
condition/timeRange |
时间段,作用与IFTTT类型下的condition/timeRange相同
只能用于all模式;any模式下将被忽略
说明
CA 类型下的condition/timeRange节点与IFTTT类型下的 condition/timeRange 节点参数形式不同。
|
condition/device/property |
设备属性,作用和参数与IFTTT类型下的trigger/device/property 相同 |
condition/timeRange 参数描述
参数 |
类型 |
描述 |
format |
String |
时间的格式,如HH:mm |
timezoneID |
String |
时区ID,可空,表示将按照哪个时区来进行时间段判断。如果不设置,默认为智能生活平台云端服务所在区域,建议传入该参数,明确指定时区。 |
beginDate |
String |
开始时间,需要符合format指定的格式,例如format为HH:mm那么 beginDate可以传入12:30 |
endDate |
String |
结束时间,需要符合format指定的格式(例如format为HH:mm),那么endDate可以传入13:30。
说明
如果 beginDate大于endDate,那么将视为跨点,例如beginDate为22:00,endDate为6:00,则视为晚上22:00到第二天6:00。
|
repeat |
String |
星期重复,是逗号分隔的1~7数字构成的字符串。可空,不传表示不重复。如1,2,3 表示在星期一、星期二、星期三重复 |
condition/timeRange format 取值描述
取值 |
说明 |
mm:ss |
分秒 |
HH:mm |
时分 |
HH:mm:ss |
时分秒 |
dd HH |
日时 |
dd HH:mm |
日时分 |
dd HH:mm:ss |
日时分秒 |
MM |
月 |
MM-dd |
月日 |
MM-dd HH |
月日时 |
MM-dd HH:mm |
月日时分 |
MM-dd HH:mm:ss |
月日时分秒 |
yyyy-MM-dd |
年月日 |
yyyy-MM-dd HH:mm:ss |
年月日时分秒 |
condition/timeRange 示例
{
"uri":"condition/timeRange",
"params":{
"format":"HH:mm",
"beginDate":"8:30",
"endDate":"23:00",
"repeat":"1,2,3,4,5"
}
}
规则限制
场景规则有如下限制:
- Trigger组件可以没有,此时场景不会自动触发,可以调用 执行场景 接口来手动触发场景。例如,只设置了 condition/timeRange,但没有设置trigger,那么场景不会自动触发。
- Condition组件可以没有,此时Trigger触发会直接执行Action。
- 不能没有Action组件。
- 一个用户可以创建200个场景。
- 一个规则内最多可以有10个Trigger。
- 一个规则内最多可以有5个Condition。
- 一个规则内最多可以有30个Action。
- 一个设备最多可以作为20个场景的Action。
- 一个规则内最多只能有一个trigger/timer组件。
- 一个规则内最多只能有一个condition/timeRange组件。
- CA类型规则中,只有all模式支持condition/timeRange组件,any模式下将忽略该组件。
创建场景
定义描述
path |
版本 |
描述 |
是否需要登录 |
/scene/create |
1.0.5 |
创建场景 |
是 |
请求参数
参数 |
类型 |
必填 |
描述 |
groupId |
String |
是 |
用于对场景进行分类
- 0表示手动场景,只包含action场景
- 1表示自动场景,包含Trigger和Condition的场景
|
enable |
Boolean |
是 |
是否在创建时启用场景,true表示启用,false表示停用 |
name |
String |
是 |
用户给场景起的名称 |
icon |
String |
是 |
场景图标的下载链接 |
iconColor |
String |
是 |
场景图标色,例如#FFFFFF |
description |
String |
否 |
对场景的描述 |
triggers |
Object |
否 |
IFTTT 规则的trigger对象 |
conditions |
Object |
否 |
IFTTT规则的condition对象 |
caConditions |
JSON Array |
否 |
CA规则的condition对象 |
actions |
JSON Array |
是 |
action对象 |
sceneType |
String |
否 |
场景规则类型:可取值为:IFTTT和CA;缺省值为IFTTT |
mode |
String |
否 |
CA规则的模式
|
返回参数
参数 |
类型 |
描述 |
sceneId |
String |
创建的场景Id |
示例
- 创建CA规则场景的请求示例
{
"groupId":"1",
"enable":true,
"name":"ilopTestScene",
"icon":"http://www.aliyundoc.com/***.png",
"iconColor":"#FFFFFF",
"caConditions":[
{
"params":{
"cron":"42 00 * * *",
"cronType":"linux",
"timezoneId":"Asia/Shanghai"
},
"uri":"condition/timer"
},
{
"params":{
"compareValue":0,
"compareType":"==",
"propertyName":"PowerSwitch",
"productKey":"xxxx",
"deviceName":"xxxx"
},
"uri":"condition/device/property"
}
],
"actions":[
{
"params":{
"iotId":"xxxx",
"propertyName":"PowerSwitch",
"propertyValue":1
},
"uri":"action/device/setProperty"
}
],
"sceneType":"CA",
"mode":"all"
}
- 创建IFTTT规则场景的请求示例(单Trigger,单Condition)
{
"sceneType":"IFTTT",
"enable":true,
"groupId":"1",
"name":"TestScene",
"icon":"http://www.aliyundoc.com/***.png",
"iconColor":"#FFFFFF",
"triggers":{
"params":{
"cron":"42 00 * * *",
"cronType":"linux",
"timezoneId":"Asia/Shanghai"
},
"uri":"trigger/timer"
},
"conditions":{
"uri":"logical/and",
"items":[
{
"params":{
"cron":"20-25 11-23 * * 1,2,3",
"cronType":"linux",
"timezoneID":"Asia/Shanghai"
},
"uri":"condition/timeRange"
}
]
},
"actions":[
{
"params":{
"iotId":"xxxx",
"propertyName":"PowerSwitch",
"propertyValue":1
},
"uri":"action/device/setProperty"
}
]
}
- 创建IFTTT规则场景的请求示例(多Trigger,多Condition)
{
"sceneType":"IFTTT",
"enable":true,
"groupId":"1",
"name":"testScene",
"icon":"http://www.aliyundoc.com/***.png",
"iconColor":"#FFFFFF",
"triggers":{
"uri":"logical/or",
"items":[
{
"params":{
"cron":"42 00 * * *",
"cronType":"linux",
"timezoneId":"Asia/Shanghai"
},
"uri":"trigger/timer"
},
{
"params":{
"iotId":"testIotId",
"propertyName":"PowerSwitch",
"compareType":"==",
"compareValue":0
},
"uri":"trigger/device/property"
}
]
},
"conditions":{
"uri":"logical/and",
"items":[
{
"params":{
"cron":"20-25 11-23 * * 1,2,3",
"cronType":"linux",
"timezoneID":"Asia/Shanghai"
},
"uri":"condition/timeRange"
},
{
"params":{
"iotId":"testIotId",
"propertyName":"PowerSwitch",
"compareType":"==",
"compareValue":0
},
"uri":"condition/device/property"
}
]
},
"actions":[
{
"params":{
"iotId":"testIotId",
"propertyName":"PowerSwitch",
"propertyValue":1
},
"uri":"action/device/setProperty"
}
]
}
- 正常返回示例
{
"code": 200,
"data": "sceneId",
"message": "success"
}
更新场景
定义描述
path |
版本 |
描述 |
是否需要登录 |
/scene/update |
1.0.5 |
更新场景 |
是 |
请求参数
参数 |
类型 |
必填 |
描述 |
groupId |
String |
是 |
用于对场景进行分类
- 0表示手动场景,只包含action场景
- 1表示自动场景,包含Trigger和Condition的场景
说明
在创建场景时指定groupId,场景创建后groupId不可以修改,即不能通过修改groupId的方式,将手动场景变更为自动场景。
|
sceneId |
String |
是 |
场景Id |
enable |
Boolean |
是 |
true表示启用场景;false表示停用场景 |
name |
String |
是 |
场景的名称 |
icon |
String |
是 |
场景图标URL |
iconColor |
String |
是 |
场景图标色 |
description |
String |
否 |
对场景的描述 |
triggers |
Object |
否 |
IFTTT规则的trigger对象 |
conditions |
Object |
否 |
IFTTT规则的condition对象 |
caConditions |
Array |
否 |
CA 规则的condition对象 |
actions |
Array |
是 |
action对象 |
sceneType |
String |
否 |
场景规则类型,可取值为IFTTT和CA,缺省值为IFTTT |
mode |
String |
否 |
CA规则的模式,可取值为all和any |
返回参数
参数 |
类型 |
描述 |
sceneId |
String |
更新的场景Id |
示例
- 请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.1",
"iotToken": "token"
},
"params": {
"enable" : true,
"iconColor" : "#DE4545",
"reBind" : true,
"mode" : "any",
"caConditions" : [
{
"uri" : "condition\/timer",
"params" : {
"cron" : "33 10 * * 1,2,3,4",
"cronType" : "linux"
}
}
],
"sceneType" : "CA",
"icon" : "http:\\www.aliyundoc.com/***.png",
"sceneId" : "2420d2xxxxf93c54fc4e",
"groupId" : "1",
"name" : "10:27 周一 周二 - 电源开关 开启",
"actions" : [
{
"uri" : "action\/device\/setProperty",
"params" : {
"iotId" : "uumR5xxxx00101",
"propertyName" : "PowerSwitch",
"propertyValue" : 1
}
}
]
}
}
- 正常返回示例
{
"code": 200,
"data": "bdc60bexxxxd617697",
"message": "success"
}
删除场景
定义描述
path |
版本 |
描述 |
是否需要登录 |
/scene/delete |
1.0.2 |
删除场景 |
是 |
请求参数
参数 |
类型 |
必填 |
描述 |
sceneId |
String |
是 |
场景Id |
返回参数
参数 |
类型 |
描述 |
sceneId |
String |
删除的场景Id |
示例
- 请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.1",
"iotToken": "token"
},
"params": {
"sceneId": "0c965xxxx5306a6657",
"groupId": null
}
}
- 正常返回示例
{
"code": 200,
"data": "0c9653xxxx06a6657",
"message": "success"
}
查询场景或自动化列表
定义描述
path |
版本 |
描述 |
是否需要登录 |
/scene/list/get |
1.0.5 |
查询场景列表 |
是 |
请求参数
参数 |
类型 |
必填 |
描述 |
groupId |
String |
是 |
0=场景 1=自动化 |
pageNo |
Integer |
是 |
页序号,不小于1 |
pageSize |
Integer |
是 |
每页数量,不小于1,不大于50 |
返回参数
参数 |
子参数 |
类型 |
描述 |
total |
|
Integer |
总条目数 |
pageNo |
|
Integer |
从1开始的页序号 |
pageSize |
|
Integer |
每页数量 |
scenes |
|
Array |
返回当前页条目 |
|
scenes.id |
String |
场景id |
|
scene.status |
Integer |
场景运行时状态:1-场景上线;2-场景下线 |
|
scene.enable |
Boolean |
场景开关(App上的开关):true-场景置为打开;false-场景置为关闭 |
|
scene.icon |
String |
场景图标连接 |
|
scene.iconColor |
String |
场景图标颜色 |
|
scene.name |
String |
场景名称 |
|
scene.description |
String |
场景描述 |
|
scene.valid |
Boolean |
是否有效 |
|
scene.groupId |
String |
类型:null-老版场景;0-场景;1-自动化 |
示例
- 请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.1",
"iotToken": "token"
},
"params": {
"groupId": "1",
"pageSize": 20,
"pageNo": 1,
}
}
- 正常返回示例
{
"code": 200,
"data": {
"pageNo": 1,
"pageSize": 20,
"scenes": [{
"description": "电热毯-hy-信噪比--127 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "260de82dxxxx691be22",
"name": "电热毯",
"status": 2,
"iconColor":"#19BBFF",
"valid":false,
"groupId":"1"
}, {
"description": "light-hy-LightSwitch-1, shuijin-hy-WiFI_SNR--127 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "45dc6fcxxxx6974e5f7",
"name": "凉宫",
"status": 1,
"iconColor":"#19BBFF",
"valid":true,
"groupId":"1"
}, {
"description": "fengsan-hy-PowerSwitch-关闭, light-hy-LightSwitch-1 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "3ce636xxxx1367f2dc88",
"name": "风扇灯0522",
"status": 1,
"iconColor":"#19BBFF",
"valid":false,
"groupId":"1"
}, {
"description": "light-hy-LightSwitch-1 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "5b4bdexxxx2612f81",
"name": "灯0522",
"status": 2,
"iconColor":"#19BBFF",
"valid":false,
"groupId":"1"
}],
"total": 4
},
"message": "success"
}
同时查询场景和自动化列表
定义描述
path |
版本 |
描述 |
是否需要登录 |
/scene/list/all |
1.0.0 |
查询我的智能页面中的所有场景信息,包括场景和自动化 |
是,客户端SDK需启用身份的鉴权,进行身份认证 |
请求参数
参数 |
类型 |
必填 |
描述 |
pageNo |
Integer |
否 |
当前页号,缺省默认值1 |
pageSize |
Integer |
是 |
页大小,大于等于1,最大为30 |
返回参数
参数 |
二级子参数 |
三级子参数 |
四级子参数 |
类型 |
描述 |
data |
|
|
|
String |
场景及自动化列表 |
|
scene0 |
|
|
String |
场景列表信息 |
|
|
total |
|
Integer |
场景总数 |
|
|
pageNo |
|
Integer |
返回当前的页号 |
|
|
pageSize |
|
Integer |
返回的页大小 |
|
|
scenes |
|
String |
场景列表 |
|
|
|
id |
String |
场景id |
|
|
|
name |
String |
场景名称 |
|
|
|
description |
String |
场景描述 |
|
|
|
enable |
Boolean |
场景开关(App上的开关):true-场景置为打开;false-场景置为关闭 |
|
|
|
icon |
String |
场景图标链接 |
|
|
|
iconColor |
String |
场景图标颜色 |
|
|
|
groupId |
String |
分类,0-表示场景;1-表示自动化 |
|
|
|
valid |
Boolean |
场景是否有效,当场景中的设备被解绑时,自动化会变为无效状态,此时该字段为true |
|
scene1 |
|
|
String |
自动化列表信息 |
|
|
total |
|
Integer |
自动化总数 |
|
|
pageNo |
|
Integer |
返回的当前页号 |
|
|
pageSize |
|
Integer |
返回的页大小 |
|
|
scenes |
|
String |
自动化列表 |
|
|
|
id |
String |
自动化id |
|
|
|
name |
String |
自动化名称 |
|
|
|
description |
String |
自动化描述 |
|
|
|
enable |
Boolean |
自动化开关(App上的开关):true-场景置为打开;false-场景置为关闭 |
|
|
|
icon |
String |
自动化图标 |
|
|
|
iconColor |
String |
自动化图标颜色 |
|
|
|
groupId |
String |
分类,0-表示场景;1-表示自动化 |
|
|
|
valid |
Boolean |
自动化是否有效,当自动化中的设备被解绑时,自动化会变为无效状态,此时该字段为true |
示例
- 请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.0",
"iotToken": "token"
},
"params": {
"pageNum": 1,
"pageSize": 10
}
}
- 正常返回示例
{
"code": 200,
"data": {
"scene0": {
"total": 1,
"scenes": [
{
"id": "",
"name": "",
"description": "",
"enable": true,
"icon": "",
"iconColor": "",
"groupId": "0",
"valid": true
}
],
"pageNo": 1,
"pageSize": 10
},
"scene1": {
"total": 0,
"scenes": [],
"pageNo": 1,
"pageSize": 10
}
},
"message": "success"
}
改变场景列表中表项的排序
定义描述
path |
版本 |
描述 |
是否需要登录 |
/scene/list/reorder |
1.0.5 |
改变场景列表中表项的排序 |
是 |
请求参数
参数 |
子参数 |
类型 |
必填 |
描述 |
groupId |
|
String |
是 |
0-场景;1-自动化 |
newOrders |
|
Array |
是 |
序号变化的场景数组 |
|
sceneId |
String |
是 |
场景id |
|
fromOrder |
Integer |
是 |
顺序变化前的序号 |
|
toOrder |
Integer |
是 |
新的序号 |
返回参数
参数 |
类型 |
描述 |
code |
Integer |
操作成功状态 |
示例
- 请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.1",
"iotToken": "token"
},
"params": {
"groupId": null,
"newOrders": [{
"fromOrder": 1,
"sceneId": "a596dexxxx9685d25",
"toOrder": 2
}, {
"fromOrder": 2,
"sceneId": "c1a8de4xxxxb473c3",
"toOrder": 1
}]
}
}
- 正常返回示例
{
"code": 200,
"message": "success"
}
执行场景
定义描述
path |
版本 |
描述 |
是否需要登录 |
/scene/fire |
1.0.2 |
执行场景 |
是 |
请求参数
参数 |
类型 |
必填 |
描述 |
sceneId |
String |
是 |
待触发的场景id |
返回参数
参数 |
类型 |
描述 |
sceneId |
String |
触发的场景id |
示例
- 请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.1",
"iotToken": "token"
},
"params": {
"groupId": null,
"sceneId": "debf2dxxxx51496c2"
}
}
- 正常返回示例
{
"code": 200,
"data": "debf2dxxxx51496c2",
"message": "success"
}
获取场景日志列表
定义描述
path |
版本 |
描述 |
是否需要登录 |
/scene/log/list/get |
1.0.2 |
获取场景日志列表 |
是 |
请求参数
参数 |
类型 |
必填 |
描述 |
pageNo |
Integer |
是 |
请求的页数,不小于1 |
pageSize |
Integer |
是 |
一次拉取的条目数 |
nowTime |
Long |
是 |
查询日志的起始时间(单位毫秒),参照场景日志查询的方式 |
如果页面要查看T1之后的某个时间点开始的Log,需要重新指定此时的时间点T2,并且把已查询到的结果全部删除掉,令pageNo=1,重新开始查询。[T1-15*3600*24,
T1] 这个时间段之间的日志场景日志查询的方式
返回参数
参数 |
类型 |
描述 |
pageNo |
Integer |
请求的页数,不小于1 |
pageSize |
Integer |
一次拉取的条目数 |
total |
Integer |
总数 |
logs |
Array |
日志列表,按时间从大到小返回 |
logs.time |
Long |
日志时间,时间戳,单位毫秒 |
logs.icon |
String |
场景图标 |
logs.sceneId |
String |
场景id |
logs.id |
String |
日志id |
logs.sceneName |
String |
场景名称 |
logs.result |
Integer |
执行结果:0-失败;1-成功 |
示例
- 请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.1",
"iotToken": "token"
},
"params": {
"pageNo": 1,
"pageSize": 5,
"groupId": null,
"nowTime": 1527129084824
}
}
- 正常返回示例
{
"code": 200,
"data": {
"logs": [{
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5d15xxxx56576d52bf",
"result": 0,
"sceneId": "d5edf3a8xxxx91b15e2028",
"sceneName": "t时间设备",
"time": 1527091200000
}, {
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5xxxx056577d52bf",
"result": 0,
"sceneId": "81eb22a2991xxxx2d0993ce",
"sceneName": "t时间",
"time": 1527091200000
}, {
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5d15xxxx75d52bf",
"result": 0,
"sceneId": "3f522ebxxxx12336709",
"sceneName": "测",
"time": 1527091200000
}, {
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19fxxxx578d52bf",
"result": 0,
"sceneId": "32020xxxx757ee3",
"sceneName": "t时间设备",
"time": 1527091200000
}, {
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5xxxx14d52bf",
"result": 1,
"sceneId": "70d90fexxxx997188911",
"sceneName": "灯",
"time": 1527054987000
}],
"pageNo": 1,
"pageSize": 5,
"total": 62
},
"message": "success"
}
获取失败日志详情
定义描述
path |
版本 |
描述 |
是否需要登录 |
/scene/failedlog/get |
1.0.4 |
获取失败日志详情 |
是 |
请求参数
参数 |
类型 |
必填 |
描述 |
logId |
String |
是 |
待查询的日志id |
sceneId |
String |
是 |
场景id |
time |
Long |
是 |
/scene/log/list/get返回的logs.time,单位毫秒 |
pageNo |
Integer |
是 |
请求的页数,第一次为1 |
pageSize |
Integer |
是 |
一次拉取的条目数 |
返回参数
参数 |
类型 |
描述 |
total |
Integer |
总数 |
pageSize |
Integer |
一次拉取的条目数 |
pageNo |
Integer |
请求的页数,不小于1 |
details |
Array |
无 |
details.productKey |
String |
失败设备的详情列表 |
details.localizedProductName |
String |
本地化的产品信息 |
details.deviceName |
String |
设备的deviceName |
details.aliasName |
String |
用户给设备起的名称 |
details.failedReason |
String |
错误信息,格式如果action是设置属性,则文案拼接规则是:{产品名称}-{属性名}-{属性值} 执行失败如果action是调用服务,则文案拼接规则是:{产品名称}-{服务名称}
执行失败
|
details.detail |
String |
下标注释的原因 |
details.icon |
String |
图标 |
示例
- 请求示例
{
"id": "150xxxx4180",
"version": "1.0",
"request": {
"apiVer": "1.0.1",
"iotToken": "token"
},
"params": {
"pageNo": 1,
"pageSize": 1000,
"logId": "0bc19xxxx00056576d52bf",
"sceneId": "d5edf3xxxx91b15e2028",
"time": 1527091200000
}
}
- 正常返回示例
{
"code": 200,
"data": {
"details": [{
"detail": "light-hy - NightLightSwitch - 关闭1 设置设备参数",
"deviceName": "hyxxxxhy",
"failedReason": "device in scene's action is unbind",
"productKey": "b1xxxxrm"
}],
"pageNo": 1,
"pageSize": 1000
},
"message": "success"
}
获取场景详情
定义描述
path |
版本 |
描述 |
是否需要登录 |
/scene/info/get |
1.0.5 |
获取场景详情 |
是 |
请求参数
参数 |
类型 |
必填 |
描述 |
sceneId |
String |
是 |
待查询的场景ID |
groupId |
String |
否 |
场景类型:
|
返回参数
参数 |
类型 |
描述 |
sceneId |
String |
场景id |
enable |
Boolean |
场景开关状态,取值如下:
- true,打开状态,场景可以正常被触发执行
- false,关闭状态,即便达到触发条件,场景也不会执行
|
name |
String |
用户给场景起的名称 |
icon |
String |
场景图标 |
iconColor |
String |
场景图标色 |
description |
String |
对场景的描述 |
triggersJson |
Object |
IFTTT规则-Trigger内复杂对象的JSON序列化,用于前端展示 |
conditions |
Object |
IFTTT规则的condition对象 |
caConditionsJson |
Array |
Since场景2.0,CA规则 - Condition内复杂对象的JSON序列化,用于前端展示 |
actionsJson |
String |
Action内复杂对象的JSON序列化,用于前端展示 |
sceneType |
String |
Since场景2.0,场景规则:IFTTT和CA(缺省值为IFTTT) |
mode |
String |
Since 场景2.0,CA规则的模式:all和any |
valid |
Boolean |
场景是否有效 |
场景生效与失效
定义描述
path |
版本 |
描述 |
是否需要登录 |
/living/scene/switch |
1.0.0 |
场景自动化开启/关闭 |
是 |
请求参数
参数 |
类型 |
必填 |
描述 |
sceneId |
String |
是 |
场景ID |
enable |
Boolean |
是 |
场景开关状态,取值如下:
- true,打开状态,场景可以正常被触发执行
- false,关闭状态,即便达到触发条件,场景也不会执行
|
返回参数
无
示例
- 请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.0",
"iotToken": "token"
},
"params": {
"sceneId": "0c96536xxxxc5306a6657",
"enable": true
}
}
- 正常返回示例
{
"code": 200,
"message": "success"
}
获取当前用户下支持trigger/condition/action配置的设备列表
定义描述
path |
版本 |
描述 |
是否需要登录 |
说明 |
/scene/thing/list |
1.0.2 |
查询获取支持T/C/A的设备列表 |
是,客户端SDK需启用身份的鉴权,进行身份认证 |
包含了被分享的设备 |
请求参数
参数 |
类型 |
必填 |
描述 |
flowType |
Integer |
是 |
流程类型 0-trigger;1-condition;2-action |
pageNum |
Integer |
是 |
分页页数,从1开始 |
pageSize |
Integer |
是 |
分页页面大小 |
返回参数
参数 |
类型 |
描述 |
pageNo |
Integer |
从1开始的页序号 |
pageSize |
Integer |
单页的item数量上限 |
total |
Long |
总记录数 |
data |
List |
设备列表 |
data 列表结构
参数 |
类型 |
描述 |
iotId |
String |
设备ID |
deviceName |
String |
设备deviceName |
productKey |
String |
产品productKey |
nickName |
String |
设备昵称 |
image |
String |
品类图标URL |
示例
- 请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.1",
"iotToken": "token"
},
"params": {
"flowType": 0,
"pageNum": 1,
"pageSize": 20
}
}
- 正常返回示例
{
"code": 200,
"data": {
"pageNo": 1,
"pageSize": 20,
"total":1,
"data": [{
"iotId": "45dc6xxxxf6974e5f7",
"deviceName": "xxxx",
"productKey": "xxxx",
"nickName": "测试设备",
"image": "https://g.aliplus.com/scene_icons/default.png"
}]
},
"message": "success"
}
获取设备上支持trigger/condition/action配置的功能属性列表
定义描述
path |
版本 |
描述 |
是否需要登录 |
/iotid/scene/ability/list |
1.0.2 |
查询设备支持T/C/A的功能列表信息 |
是,客户端SDK需启用身份的鉴权,进行身份认证 |
请求参数
参数 |
类型 |
必填 |
描述 |
iotId |
String |
是 |
设备ID |
flowType |
Integer |
是 |
流程类型 0-trigger;1-condition;2-action |
返回参数
参数 |
类型 |
描述 |
name |
String |
功能名称 |
identifier |
String |
功能标识符 |
categoryType |
String |
品类名称 |
type |
Integer |
功能类型 1:-属性;2-服务;3-事件 |
示例
- 请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.1",
"iotToken": "token"
},
"params": {
"iotId": "45dc6fxxxx29f6974e5f7",
"flowType": 0
}
}
- 正常返回示例
{
"code": 200,
"data": [{
"name": "开关",
"identifier": "switch",
"categoryType": "xxxx",
"type": 1
}],
"message": "success"
}
获取设备的trigger或condition或action功能列表与TSL定义
定义描述
path |
版本 |
描述 |
是否需要登录 |
/iotid/scene/ability/tsl/list |
1.0.2 |
查询设备支持T/C/A的功能列表信息以及对应设备的TSL信息 |
是,客户端SDK需启用身份的鉴权,进行身份认证 |
请求参数
参数 |
类型 |
必填 |
描述 |
iotId |
String |
是 |
设备ID |
flowType |
Integer |
是 |
流程类型:0-trigger;1-condition;2-action |
返回参数
参数 |
类型 |
描述 |
simplifyAbilityDTOs |
List |
功能定义列表 |
abilityDsl |
JSONObject |
产品功能TSL(参考) |
simplifyAbilityDTOs结构
参数 |
类型 |
描述 |
name |
String |
功能名称 |
identifier |
String |
功能标识符 |
categoryType |
String |
品类名称 |
type |
Integer |
功能类型:1-属性;2-服务;3-事件 |
示例
- 请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.1",
"iotToken": "token"
},
"params": {
"iotId": "45dc6fxxxx6974e5f7",
"flowType": 0
}
}
- 正常返回示例
{
"code": 200,
"data": {
"simplifyAbilityDTOs":[{
"name": "开关",
"identifier": "switch",
"categoryType": "xxxx",
"type": 1
}],
"abilityDsl": {}
},
"message": "success"
}
创建设备预约定时场景
定义描述
path |
版本 |
描述 |
是否需要用户身份的鉴权 |
/scene/timing/create |
1.0.2 |
创建设备的预约定时场景 |
是,客户端SDK需启用身份的鉴权,进行身份认证 |
说明
预约定时场景与设备相关联,因此不能使用/scene/update和/living/scene/switch等接口来更新、启停。如有这方面需要,请使用/scene/timing/update接口。同时不支持手机消息推送action。
请求参数
参数 |
类型 |
必填 |
描述 |
iotId |
String |
是 |
设备ID |
enable |
Boolean |
是 |
true打开 false关闭 |
name |
String |
是 |
用户给场景起的名称 |
icon |
String |
是 |
场景图标 |
description |
String |
否 |
对场景的描述 |
triggers |
Object |
否 |
trigger对象 |
conditions |
Object |
否 |
condition对象 |
actions |
Array |
是 |
action对象 |
说明
action不能为空,trigger可以空,condition可以空。
返回参数
参数 |
类型 |
描述 |
sceneId |
String |
新建的场景Id |
示例
- 请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.2",
"iotToken": "token"
},
"params": {
"actions": [{
"params": {
"compareValue": 1,
"iotId": "zjoOvFxxxxc4dc00",
"compareType": ">",
"propertyName": "Qxxxxat",
"propertyValue": 1
},
"uri": "action/device/setProperty"
}],
"iotId":"zjoOvFZxxxx4dc00",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"name": "一样",
"triggers": {
"params": {},
"items": [{
"params": {
"cron": "1 1 * * *",
"cronType": "linux",
"timezoneID": "Asia/Shanghai"
},
"uri": "trigger/timer"
}],
"uri": "logical/or"
}
}
}
- 正常返回示例
{
"code": 200,
"data": "0c9653xxxx645c5306a6657",
"message": "success"
}
更新设备预约定时场景
定义描述
path |
版本 |
描述 |
是否需要用户身份的鉴权 |
/scene/timing/update |
1.0.2 |
更新设备的预约定时场景 |
是,客户端SDK需启用身份的鉴权,进行身份认证 |
请求参数
参数 |
类型 |
必填 |
描述 |
iotId |
String |
是 |
设备ID |
sceneId |
String |
是 |
场景ID |
enable |
Boolean |
是 |
true打开 false关闭 |
name |
String |
是 |
用户给场景起的名称 |
icon |
String |
是 |
场景图标 |
description |
String |
否 |
对场景的描述 |
triggers |
Object |
否 |
trigger对象 |
conditions |
Object |
否 |
condition对象 |
actions |
Array |
是 |
action对象 |
说明
action不能为空,trigger可以空,condition可以空。
返回参数
参数 |
类型 |
描述 |
sceneId |
String |
场景Id |
示例
- 请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.2",
"iotToken": "token"
},
"params": {
"actions": [{
"params": {
"compareValue": 0,
"iotId": "gaI0CRxxxx09b3700",
"compareType": {
"i18nKey": "scene.common.compareType.equal",
"type": "=="
},
"propertyName": "Nigxxxxwitch",
"propertyValue": 0
},
"uri": "action/device/setProperty",
"status": 1
}],
"conditions": {
"params": {},
"items": [{
"params": {
"compareValue": 0,
"iotId": "gaI0Cxxxx09b3700",
"compareType": "==",
"propertyName": "LightSwitch",
"propertyValue": 0
},
"uri": "condition/device/property",
"status": 1
}],
"uri": "logical/and"
},
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"name": "",
"sceneId": "bdc60xxxx7d617697",
"iotId": "gaI0CRKxxxx09b3700",
"triggers": {
"params": {},
"items": [{
"params": {
"cron": "0 0 * * *",
"cronType": "linux",
"timezoneID": "Asia/Shanghai"
},
"uri": "trigger/timer",
"status": 1
}],
"uri": "logical/or"
}
}
}
- 正常返回示例
{
"code": 200,
"data": "0c9653xxxx06a6657",
"message": "success"
}
删除设备预约定时场景
定义描述
path |
版本 |
描述 |
是否需要用户身份的鉴权 |
/scene/timing/delete |
1.0.2 |
删除定时场景 |
是,客户端SDK需启用身份的鉴权,进行身份认证 |
请求参数
参数 |
类型 |
必填 |
描述 |
iotId |
String |
是 |
设备Id |
sceneId |
String |
是 |
场景Id |
返回参数
参数 |
类型 |
描述 |
sceneId |
String |
删除的场景Id |
示例
- 请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.2",
"iotToken": "token"
},
"params": {
"sceneId": "0c96xxxx306a6657",
"iotId": "gaI0Cxxxx109b3700"
}
}
- 正常返回示例
{
"code": 200,
"data": "0c9653xxxx06a6657",
"message": "success"
}
获取设备预约定时场景详情
定义描述
path |
版本 |
描述 |
是否需要用户身份的鉴权 |
/scene/timing/info/get |
1.0.2 |
获取定时场景的详情 |
是,客户端SDK需启用身份的鉴权,进行身份认证 |
请求参数
参数 |
类型 |
必填 |
描述 |
iotId |
String |
是 |
设备Id |
sceneId |
String |
是 |
待查询的场景Id |
返回参数
参数 |
类型 |
描述 |
sceneId |
String |
场景id |
enable |
Boolean |
场景开关:true-打开;false-关闭 |
status |
Integer |
场景运行时状态:1-运行;2-失效 |
name |
String |
用户给场景起的名称 |
icon |
String |
场景图标 |
triggers |
Object |
triggers对象的String。trigger对象定义在下面 |
conditions |
Object |
conditions对象的String |
actions |
Array |
actions对象的String |
示例
- 请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.2",
"iotToken": "token"
},
"params": {
"sceneId": "260de8xxxx4691be22",
"iotId": "gaI0Cxxxx9b3700"
}
}
- 正常返回示例
{
"code": 200,
"data": {
"actions": [{
"params": {
"compareValue": -127,
"localizedProductName": "电热毯-hy",
"iotId": "SY7a6Ixxxx0c00",
"compareType": "==",
"propertyName": "WiFI_SNR",
"localizedPropertyName": "信噪比",
"deviceNickName": "电热毯-hy",
"propertyValue": -127,
"localizedCompareValueName": "-127",
"productKey": "b1xxxxql",
"propertyItems": {
"WiFI_SNR": -127
},
"deviceName": "hyhyhy4"
},
"uri": "action/device/setProperty",
"status": 0
}],
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"name": "电热毯",
"sceneId": "260de82dxxxx4691be22",
"status": 2
},
"message": "success"
}
查询预约定时场景列表
查询设备预约定时场景列表
定义描述
path |
版本 |
描述 |
是否需要用户身份的鉴权 |
/scene/timing/list/get |
1.0.2 |
查询定时场景列表 |
是,客户端SDK需启用身份的鉴权,进行身份认证 |
请求参数
参数 |
类型 |
必填 |
描述 |
iotId |
String |
是 |
设备ID |
pageNo |
Integer |
是 |
页序号,不小于1 |
pageSize |
Integer |
是 |
每页数量,不小于1,不大于50 |
返回参数
参数 |
子参数 |
类型 |
描述 |
total |
|
Integer |
总条目数 |
pageNo |
|
Integer |
从1开始的页序号 |
pageSize |
|
Integer |
每页数量 |
scenes |
|
Array |
返回当前页条目 |
|
scenes.id |
String |
场景id |
|
scene.status |
Integer |
场景运行时状态:1-场景上线;2-场景下线 |
|
scene.enable |
Boolean |
场景开关(App上的开关):true-场景置为打开;false-场景置为关闭 |
|
scene.icon |
String |
场景图标连接 |
|
scene.name |
String |
场景名称 |
|
scene.description |
String |
场景描述 |
示例
- 请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.2",
"iotToken": "token"
},
"params": {
"pageSize": 20,
"pageNo": 1,
"iotId": "zjoOvFZxxxx0c4dc00"
}
}
- 正常返回示例
{
"code": 200,
"data": {
"pageNo": 1,
"pageSize": 20,
"scenes": [{
"description": "电热毯-hy-信噪比--127 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "260de82xxxx691be22",
"name": "电热毯",
"status": 2
}, {
"description": "light-hy-LightSwitch-1, shuijin-hy-WiFI_SNR--127 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "45dc6fcxxxx6974e5f7",
"name": "凉宫",
"status": 1
}],
"total": 2
},
"message": "success"
}
批量获取场景详情
定义描述
path |
版本 |
描述 |
是否需要用户身份的鉴权 |
/living/scene/batchget |
1.0.0 |
批量请求场景信息 |
是,客户端SDK需启用身份的鉴权,进行身份认证 |
请求参数
参数 |
类型 |
必填 |
描述 |
sceneIdList |
list |
是 |
待查询的场景ID列表 |
返回参数
参数 |
类型 |
描述 |
sceneId |
String |
场景id |
enable |
Boolean |
场景开关:true-打开;false-关闭 |
name |
String |
用户给场景起的名称 |
icon |
String |
场景图标 |
triggers |
String |
triggers对象的String |
conditions |
String |
conditions对象的String |
actions |
String |
actions对象的String |
示例
- 请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.0",
"iotToken": "token"
},
"params":
{"sceneIdList":["b8fe2xxxx26b76c31"]}
}
- 正常返回示例
{
"code":200,
"data":
[
{"sceneType":"IFTTT",
"name":"主灯开关 开启 - 灯模式 mono - 开启",
"icon":"https://img.alicdn.com/tfs/TB10G8xxxxUVXa-144-144.png",
"sceneId":"b8fexxxx26b76c31",
"sceneSwitch":1,
"triggers":"{\"params\":{},\"items\":[{\"params\":{\"eventCode\":\"\",\"compareValue\":1,\"iotId\":\"z8nxxxx00101\",\"compareType\":\"==\",\"propertyName\":\"LightSwitch\",\"propertyValue\":1,\"productKey\":\"a1B0kMs35NW\",\"deviceName\":\"z8nxxxx6SFY\"},\"uri\":\"trigger/device/property\"}],\"uri\":\"logical/or\"}",
"conditions":"{\"params\":{},\"items\":[{\"params\":{\"eventCode\":\"\",\"compareValue\":0,\"iotId\":\"z8nqxxxx000101\",\"compareType\":\"==\",\"propertyName\":\"LightMode\",\"propertyValue\":0,\"productKey\":\"a1B0kMs35NW\",\"deviceName\":\"z8nxxxx6SFY\"},\"uri\":\"condition/device/property\"}],\"uri\":\"logical/and\"}",
"actions":"[{\"params\":{\"switchStatus\":1,\"automationRuleId\":\"50xxxx520ceed\"},\"uri\":\"action/automation/setSwitch\"}]"}
],
"id":"1509086454180"
}
向手机推送消息action
定义描述
path |
描述 |
是否需要用户身份的鉴权 |
/action/mq/send |
向手机推送消息action |
是,客户端SDK需启用身份的鉴权,进行身份认证 |
请求参数
参数 |
类型 |
必填 |
描述 |
customData |
CustomData |
是 |
推送消息模型 |
customData. message |
String |
是 |
向手机推送消息的内容,最多60个字符 |
msgTag |
String |
是 |
推送消息模型,默认值:IlopBusiness_CustomMsg |
返回参数
无
示例
- 请求示例
"actions": [
{
"uri":"action/mq/send",
"params":{
"customData":{
"message":"电源开启了"
},
"msgTag":"IlopBusiness_CustomMsg"
}
}
]
- 正常返回示例
无
智能小组件查询场景
定义描述
path |
版本 |
描述 |
是否需要登录 |
/living/appwidget/list |
1.0.0 |
智能小组件查询,用于APP的场景快捷触发小组件中查询组件信息 |
是 |
请求参数
无
返回参数
参数 |
类型 |
描述 |
id |
Stirng |
场景ID |
name |
Stirng |
场景名称 |
description |
Stirng |
场景描述 |
enable |
Boolean |
场景是否启用 |
icon |
String |
场景图标 |
iconColor |
String |
场景图标色 |
valid |
Boolean |
场景是否有效 |
示例
- 请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.0",
"iotToken": "token"
},
"params": {
}
}
- 正常返回示例
{
"code": 200,
"message": "success"
"data":[{
"id": "d5edf3xxxxb15e2028",
"iconColor": "#19BBFF",
"name": "向手机发送通知",
"description": " 描述 ",
"enable": true
},
{
"id": "debf2dxxxx1496c2",
"iconColor": "#FFBBFF",
"name": "开灯",
"description": "描述",
"enable": false
}
]
}
智能小组件添加场景
定义描述
path |
版本 |
描述 |
是否需要登录 |
/living/appwidget/create |
1.0.0 |
智能小组件添加,用于APP的场景快捷触发小组件中添加组件 |
是 |
请求参数
无
返回参数
参数 |
类型 |
描述 |
sceneIds |
Array |
场景ID列表,最多8个场景 |
示例
- 请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.0",
"iotToken": "token"
},
"params": {
"sceneIds":["d5edfxxxx5e2028","debfxxxx496c2"]
}
}
- 正常返回示例
{
"code": 200,
"message": "success"
}