场景服务2.0
更新时间:2019-09-07 00:24:20
提供一组客户端用户创建和配置自动化场景的接口,可以实现触发某些条件时,执行某些任务的功能,如当到达某个时间时、设备自动开启等功能。
更新日期 |
更新内容 |
2019-07 |
场景服务2.0,兼容1.0版,将TCA模型简化为CA模型,支持跨天定时,支持设置时间段,执行任务中支持推送手机消息等 |
2018-08 |
场景服务1.0 ,提供基础的场景、自动化、定时的增删改查功能 ,查看历史文档 |
场景自动化的创建、编辑、删除、查询
触发条件和执行任务
场景自动化的执行
APP小组件
设备定时
额外说明
创建场景
定义描述
path |
版本 |
描述 |
是否需要登录 |
/scene/create |
1.0.5 |
创建场景 |
是 |
调整入参groupId
必须存在,增加入参字段iconColor
。
请求参数
参数 |
类型 |
必填 |
描述 |
groupId |
String |
是 |
0=场景 1=自动化 |
enable |
Boolean |
是 |
true打开 false关闭 |
name |
String |
是 |
用户给场景起的名称 |
icon |
String |
是 |
场景图标 |
iconColor |
String |
是 |
场景图标色 |
description |
String |
否 |
对场景的描述 |
triggers |
Object |
否 |
IFTTT 规则的 trigger 对象 |
conditions |
Object |
否 |
IFTTT 规则的 condition 对象 |
caConditions |
Array |
否 |
Since 场景2.0,CA 规则的 condition 对象(只有all模式下支持时间段,any模式下时间段将被忽略) |
actions |
Array |
是 |
action 对象 |
sceneType |
String |
否 |
Since 场景2.0,场景规则:IFTTT 和CA ;缺省值为IFTTT;当以CA模式创建场景时,设置type为CA,mode可为以下两种:all:当所有触发器都满足,执行操作;any:任一触发器满足,执行操作 |
mode |
String |
否 |
Since 场景2.0,CA 规则的模式:all 和any |
注:action不能为空,trigger可以空,condition可以空,caCondition可以空
trigger对象,condition对象,caCondition对象以及action对象文档查看 链接
返回参数
参数 |
类型 |
描述 |
sceneId |
String |
创建的场景Id |
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.5",
"iotToken": "token"
},
"params": {
"enable": true,
"icon": "https://gaic.alicdn.com/ztms/cloud-intelligence-icons/icons/scene_img_choice_icon_9.png",
"groupId": "1",
"mode": "all",
"sceneType": "CA",
"caConditions": [{
"uri": "condition/timeRange",
"params": {
"beginDate": "08:00",
"endDate": "07:00",
"format": "HH:mm"
}
}, {
"uri": "condition/device/property",
"params": {
"propertyName": "PowerSwitch",
"compareValue": 1,
"compareType": "==",
"productKey": "a113CVGLO6k",
"deviceName": "VD_ChYDyO70Gc"
}
}],
"iconColor": "#19BBFF",
"name": "向手机发送通知",
"actions": [{
"uri": "action/mq/send",
"params": {
"customData": {
"message": "电源开启了"
},
"msgTag": "IlopBusiness_CustomMsg"
}
}]
}
}
返回示例
{
"code": 200,
"data": "debf2d332cbf48569d42b430d51496c2",
"message": "success"
}
错误码
错误码 |
错误信息 |
来源 |
描述 |
10196 |
device exist circle |
业务 |
设备存在循环依赖(要求:特定产品的特定属性在T C A中不能重复出现) |
10197 |
scene exist circle |
业务 |
场景存在循环依赖(要求:action中指定的场景不能形成环) |
10198 |
scene depth illegal |
业务 |
场景嵌套深度非法(要求:场景最多嵌套一层场景) |
10199 |
scene width illegal |
业务 |
action中场景个数非法(要求action中场景个数不能超过100) |
更新场景
定义描述
path |
版本 |
描述 |
是否需要登录 |
/scene/update |
1.0.5 |
更新场景 |
是 |
请求参数
参数 |
类型 |
必填 |
描述 |
groupId |
String |
是 |
0=场景 1=自动化 |
sceneId |
String |
是 |
场景Id |
enable |
Boolean |
是 |
true打开 false关闭 |
name |
String |
是 |
用户给场景起的名称 |
icon |
String |
是 |
场景图标 |
iconColor |
String |
是 |
场景图标色 |
description |
String |
否 |
对场景的描述 |
triggers |
Object |
否 |
IFTTT 规则的 trigger 对象 |
conditions |
Object |
否 |
IFTTT 规则的 condition 对象 |
caConditions |
Array |
否 |
Since 场景2.0,CA 规则的 condition 对象(只有all模式下支持时间段,any模式下时间段将被忽略) |
actions |
Array |
是 |
action 对象 |
sceneType |
String |
否 |
Since 场景2.0,场景规则:IFTTT和CA;缺省值为IFTTT;当以CA模式创建场景时,设置type为CA,mode可为以下两种:all:当所有触发器都满足,执行操作;any:任一触发器满足,执行操作 |
mode |
String |
否 |
Since 场景2.0,CA 规则的模式:all 和any |
Trigger对象,Condition对象,Action对象文档查看 链接
返回参数
参数 |
类型 |
描述 |
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:\/\/gaic.alicdn.com\/ztms\/cloud-intelligence-icons\/icons\/scene_img_choice_icon_1.png",
"sceneId" : "2420d2b561f244e7888dc1f93c54fc4e",
"groupId" : "1",
"name" : "10:27 周一 周二 - 电源开关 开启",
"actions" : [
{
"uri" : "action\/device\/setProperty",
"params" : {
"iotId" : "uumR5a7euISb5g5YmC6J000101",
"propertyName" : "PowerSwitch",
"propertyValue" : 1
}
}
]
}
}
返回示例
{
"code": 200,
"data": "bdc60beb0e6a4a24a8e03b417d617697",
"message": "success"
}
错误码
错误码 |
错误信息 |
来源 |
描述 |
10196 |
device exist circle |
业务 |
设备存在循环依赖(要求:特定产品的特定属性在T C A中不能重复出现) |
10197 |
scene exist circle |
业务 |
场景存在循环依赖(要求:action中指定的场景不能形成环) |
10198 |
scene depth illegal |
业务 |
场景嵌套深度非法(要求:场景最多嵌套一层场景) |
10199 |
scene width illegal |
业务 |
action中场景个数非法(要求action中场景个数不能超过100) |
10200 |
scene empty |
业务 |
没有这个场景 |
删除场景
定义描述
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": "0c96536b09404a50ac6645c5306a6657",
"groupId": null
}
}
返回示例
{
"code": 200,
"data": "0c96536b09404a50ac6645c5306a6657",
"message": "success"
}
错误码
错误码 |
错误信息 |
来源 |
描述 |
10200 |
scene empty |
业务 |
没有这个场景 |
查询场景列表
定义描述
path |
版本 |
描述 |
是否需要登录 |
/scene/list/get |
1.0.5 |
查询场景列表 |
是 |
请求参数
参数 |
类型 |
必填 |
约束 |
描述 |
groupId |
String |
是 |
ilop |
0=场景 1=自动化 |
type |
String |
否 |
ilop |
业务类型(目前可以选择填ilop或不填) |
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 |
true 场景置为打开 false场景置为关闭 |
场景开关(App上的开关) |
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,
"type": "ilop"
}
}
返回示例
{
"code": 200,
"data": {
"pageNo": 1,
"pageSize": 20,
"scenes": [{
"description": "电热毯-hy-信噪比--127 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "260de82dd0cc484a80415a104691be22",
"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": "45dc6fc753d345b69b01d29f6974e5f7",
"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": "3ce63673e5164d49b0ec1f1367f2dc88",
"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": "5b4bdee4d1d5457081082ee522612f81",
"name": "灯0522",
"status": 2,
"iconColor":"#19BBFF",
"valid":false,
"groupId":"1"
}],
"total": 4
},
"message": "success"
}
错误码
错误码 |
错误信息 |
来源 |
描述 |
2000 |
request parameter error. |
业务 |
参数为空或不合法 |
2062 |
identityId does not exist. |
业务 |
identityId不存在 |
查询我的智能页面
定义描述
path |
版本 |
描述 |
是否需要登录 |
/scene/list/all |
1.0.0 |
查询我的智能页面中的所有场景信息 |
是,客户端SDK需启用身份的鉴权 |
请求参数
参数 |
类型 |
必填 |
描述 |
pageNo |
Integer |
否 |
当前页号,缺省默认值1 |
pageSize |
Integer |
是 |
页大小,大于等于1 |
返回参数
参数 |
类型 |
必有 |
描述 |
sceneListV2DTO |
SceneListV2DTO |
是 |
我的智能场景列表 |
sceneListV2DTO.scene0 |
String |
是 |
场景列表Json |
sceneListV2DTO.scene1 |
String |
是 |
自动化列表Json |
示例
请求示例
{
"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 |
改变场景列表中表项的排序 |
是 |
请求参数
参数 |
类型 |
必填 |
约束 |
描述 |
type |
String |
否 |
ilop |
业务类型(目前可以选择填ilop或不填) |
|
newOrders |
Array |
是 |
|
序号变化的场景数组 |
|
newOrders.sceneId |
String |
是 |
|
场景id |
|
newOrders.fromOrder |
Integer |
是 |
|
顺序变化前的序号 |
|
newOrders.toOrder |
Integer |
是 |
|
新的序号 |
返回参数
参数 |
类型 |
描述 |
code |
Integer |
操作成功状态 |
示例
请求实例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.1",
"iotToken": "token"
},
"params": {
"type": "ilop",
"groupId": null,
"newOrders": [{
"fromOrder": 1,
"sceneId": "a596de546faf48b096410a80d9685d25",
"toOrder": 2
}, {
"fromOrder": 2,
"sceneId": "c1a8de4d6faa477bb6ec023003b473c3",
"toOrder": 1
}]
}
}
返回实例
{
"code": 200,
"message": "success"
}
错误码
错误码 |
错误信息 |
来源 |
描述 |
2000 |
request parameter error. |
业务 |
参数为空或不合法 |
2062 |
identityId does not exist. |
业务 |
identityId不存在 |
执行场景
定义描述
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": "debf2d332cbf48569d42b430d51496c2"
}
}
返回实例
{
"code": 200,
"data": "debf2d332cbf48569d42b430d51496c2",
"message": "success"
}
错误码
错误码 |
错误信息 |
来源 |
描述 |
10200 |
scene empty |
业务 |
没有这个场景 |
获取场景日志列表
定义描述
path |
版本 |
描述 |
是否需要登录 |
/scene/log/list/get |
1.0.2 |
获取场景日志列表 |
是 |
请求参数
场景日志查询的方式:
场景日志需要指定一个查询的时间起点,定义为T1,后端会查从T1开始向前追溯15天的日志,即
[T1-15*3600*24, T1] 这个时间段之间的日志
故约定:App端打开日志查询的界面时,记录下页面打开的时间点作为T1,在后续的查询中,一直携带T1作为time。
如果页面要查看T1之后的某个时间点开始的Log,需要重新指定此时的时间点T2,并且把已查询到的结果全部删除掉,令pageNo=1,重新开始查询。
参数 |
类型 |
必填 |
枚举与约束 |
描述 |
pageNo |
Integer |
是 |
不小于1 |
请求的页数 |
pageSize |
Integer |
是 |
|
一次拉取的条目数 |
nowTime |
Long |
是 |
|
查询日志的起始时间,参考场景日志查询的方式。单位毫秒 |
返回参数
参数 |
类型 |
枚举与约束 |
描述 |
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": 20,
"groupId": null,
"nowTime": 1527129084824
}
}
返回示例
{
"code": 200,
"data": {
"logs": [{
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5d15270912000056576d52bf",
"result": 0,
"sceneId": "d5edf3a80e5c40d48aba0591b15e2028",
"sceneName": "t时间设备",
"time": 1527091200000
}, {
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5d15270912000056577d52bf",
"result": 0,
"sceneId": "81eb22a299dd4262932365212d0993ce",
"sceneName": "t时间",
"time": 1527091200000
}, {
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5d15270912000036575d52bf",
"result": 0,
"sceneId": "3f522eb034f842ba8d8e627612336709",
"sceneName": "测",
"time": 1527091200000
}, {
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5d15270912000056578d52bf",
"result": 0,
"sceneId": "3202047e1e4a4af38e5c4ab66a757ee3",
"sceneName": "t时间设备",
"time": 1527091200000
}, {
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5d15270549875871014d52bf",
"result": 1,
"sceneId": "70d90fe996964a718b42ec2997188911",
"sceneName": "灯",
"time": 1527054987000
}, {
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5d15269604322384548d3112",
"result": 1,
"sceneId": "5b4bdee4d1d5457081082ee522612f81",
"sceneName": "灯0522",
"time": 1526960432000
}, {
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5d15269550384782579d3112",
"result": 1,
"sceneId": "70d90fe996964a718b42ec2997188911",
"sceneName": "灯",
"time": 1526955038000
}, {
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5d15269550370082578d3112",
"result": 1,
"sceneId": "3c8bc0c09f4e411cb3d535598669741f",
"sceneName": "两个灯0522",
"time": 1526955037000
}, {
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5d15269550356242576d3112",
"result": 1,
"sceneId": "70d90fe996964a718b42ec2997188911",
"sceneName": "灯",
"time": 1526955035000
}, {
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5d15269550340772575d3112",
"result": 1,
"sceneId": "3c8bc0c09f4e411cb3d535598669741f",
"sceneName": "两个灯0522",
"time": 1526955034000
}, {
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5d15269550326602573d3112",
"result": 1,
"sceneId": "70d90fe996964a718b42ec2997188911",
"sceneName": "灯",
"time": 1526955032000
}, {
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5d15269550311612572d3112",
"result": 1,
"sceneId": "3c8bc0c09f4e411cb3d535598669741f",
"sceneName": "两个灯0522",
"time": 1526955031000
}, {
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5d15269550296422570d3112",
"result": 1,
"sceneId": "70d90fe996964a718b42ec2997188911",
"sceneName": "灯",
"time": 1526955029000
}, {
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5d15269550281812569d3112",
"result": 1,
"sceneId": "3c8bc0c09f4e411cb3d535598669741f",
"sceneName": "两个灯0522",
"time": 1526955028000
}, {
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5d15269184000015774d3112",
"result": 0,
"sceneId": "81eb22a299dd4262932365212d0993ce",
"sceneName": "t时间",
"time": 1526918400000
}, {
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5d15269184000015772d3112",
"result": 0,
"sceneId": "3f522eb034f842ba8d8e627612336709",
"sceneName": "测",
"time": 1526918400000
}, {
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5d15269184000015771d3112",
"result": 0,
"sceneId": "3202047e1e4a4af38e5c4ab66a757ee3",
"sceneName": "t时间设备",
"time": 1526918400000
}, {
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5d15269184000015773d3112",
"result": 0,
"sceneId": "d5edf3a80e5c40d48aba0591b15e2028",
"sceneName": "t时间设备",
"time": 1526918400000
}, {
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5d15268970952516329d3112",
"result": 1,
"sceneId": "70d90fe996964a718b42ec2997188911",
"sceneName": "灯",
"time": 1526897095000
}, {
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "0bc19f5d15268829550571368d3112",
"result": 1,
"sceneId": "9fda7bc446e44ccc8edf4c0e39f89305",
"sceneName": "两个灯",
"time": 1526882955000
}],
"pageNo": 1,
"pageSize": 20,
"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 |
是 |
一次拉取的条目数 |
|
groupId |
String |
否 |
0=场景 1=自动化 |
返回参数
参数 |
类型 |
约束与枚举 |
描述 |
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": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.1",
"iotToken": "token"
},
"params": {
"pageNo": 1,
"pageSize": 1000,
"groupId": null,
"logId": "0bc19f5d15270912000056576d52bf",
"sceneId": "d5edf3a80e5c40d48aba0591b15e2028",
"time": 1527091200000
}
}
应答示例
{
"code": 200,
"data": {
"details": [{
"detail": "light-hy - NightLightSwitch - 关闭1 设置设备参数",
"deviceName": "hyhyhy",
"failedReason": "device in scene's action is unbind",
"productKey": "b1wT8gS8Hrm"
}],
"pageNo": 1,
"pageSize": 1000
},
"message": "success"
}
错误码
错误码 |
错误信息 |
来源 |
描述 |
10200 |
scene empty |
业务 |
没有这个场景 |
获取场景详情
定义描述
path |
版本 |
描述 |
是否需要登录 |
/scene/info/get |
1.0.5 |
获取场景详情 |
是 |
请求参数
参数 |
类型 |
必填 |
描述 |
sceneId |
String |
是 |
待查询的场景Id |
groupId |
String |
否 |
场景类型:如果为null说明是旧版场景,0=场景 1=自动化 |
返回参数
参数 |
类型 |
约束与枚举 |
描述 |
sceneId |
String |
|
场景id |
enable |
Boolean |
true 场景置为打开 false场景置为关闭 |
场景开关(App上的开关) |
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 |
版本 |
描述 |
是否需要用户身份的鉴权 |
/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": "zjoOvFZWenq1xdxRyvcI0010c4dc00",
"compareType": ">",
"propertyName": "Qu0wChfloat",
"propertyValue": 1
},
"uri": "action/device/setProperty"
}],
"iotId":"zjoOvFZWenq1xdxRyvcI0010c4dc00",
"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": "0c96536b09404a50ac6645c5306a6657",
"message": "success"
}
错误码
错误码 |
错误信息 |
来源 |
描述 |
10196 |
device exist circle |
业务 |
设备存在循环依赖(要求:特定产品的特定属性在T C A中不能重复出现) |
10197 |
scene exist circle |
业务 |
场景存在循环依赖(要求:action中指定的场景不能形成环) |
10198 |
scene depth illegal |
业务 |
场景嵌套深度非法(要求:场景最多嵌套一层场景) |
10199 |
scene width illegal |
业务 |
action中场景个数非法(要求action中场景个数不能超过100) |
更新设备定时
定义描述
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": "gaI0CRK2GV7KmDVc8gk300109b3700",
"compareType": {
"i18nKey": "scene.common.compareType.equal",
"type": "=="
},
"propertyName": "NightLightSwitch",
"propertyValue": 0
},
"uri": "action/device/setProperty",
"status": 1
}],
"conditions": {
"params": {},
"items": [{
"params": {
"compareValue": 0,
"iotId": "gaI0CRK2GV7KmDVc8gk300109b3700",
"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": "bdc60beb0e6a4a24a8e03b417d617697",
"iotId": "gaI0CRK2GV7KmDVc8gk300109b3700",
"triggers": {
"params": {},
"items": [{
"params": {
"cron": "0 0 * * *",
"cronType": "linux",
"timezoneID": "Asia/Shanghai"
},
"uri": "trigger/timer",
"status": 1
}],
"uri": "logical/or"
}
}
}
返回示例
{
"code": 200,
"data": "0c96536b09404a50ac6645c5306a6657",
"message": "success"
}
错误码
错误码 |
错误信息 |
来源 |
描述 |
10196 |
device exist circle |
业务 |
设备存在循环依赖(要求:特定产品的特定属性在T C A中不能重复出现) |
10197 |
scene exist circle |
业务 |
场景存在循环依赖(要求:action中指定的场景不能形成环) |
10198 |
scene depth illegal |
业务 |
场景嵌套深度非法(要求:场景最多嵌套一层场景) |
10199 |
scene width illegal |
业务 |
action中场景个数非法(要求action中场景个数不能超过100) |
10200 |
scene empty |
业务 |
没有这个场景 |
删除设备定时
定义描述
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": "0c96536b09404a50ac6645c5306a6657",
"iotId": "gaI0CRK2GV7KmDVc8gk300109b3700"
}
}
返回示例
{
"code": 200,
"data": "0c96536b09404a50ac6645c5306a6657",
"message": "success"
}
错误码
错误码 |
错误信息 |
来源 |
描述 |
10200 |
scene empty |
业务 |
没有这个场景 |
获取设备定时详情
定义描述
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": "260de82dd0cc484a80415a104691be22",
"iotId": "gaI0CRK2GV7KmDVc8gk300109b3700"
}
}
返回示例
{
"code": 200,
"data": {
"actions": [{
"params": {
"compareValue": -127,
"localizedProductName": "电热毯-hy",
"iotId": "SY7a6IDsvT0m2tTdzm0z00103d0c00",
"compareType": "==",
"propertyName": "WiFI_SNR",
"localizedPropertyName": "信噪比",
"deviceNickName": "电热毯-hy",
"propertyValue": -127,
"localizedCompareValueName": "-127",
"productKey": "b1DQZAMjUql",
"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": "260de82dd0cc484a80415a104691be22",
"status": 2
},
"message": "success"
}
错误码
错误码 |
错误信息 |
来源 |
描述 |
10200 |
scene empty |
业务 |
没有这个场景 |
查询设备定时列表
定义描述
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 |
true 场景置为打开 false场景置为关闭 |
场景开关(App上的开关) |
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": "zjoOvFZWenq1xdxRyvcI0010c4dc00"
}
}
返回示例
{
"code": 200,
"data": {
"pageNo": 1,
"pageSize": 20,
"scenes": [{
"description": "电热毯-hy-信噪比--127 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "260de82dd0cc484a80415a104691be22",
"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": "45dc6fc753d345b69b01d29f6974e5f7",
"name": "凉宫",
"status": 1
}],
"total": 2
},
"message": "success"
}
错误码
错误码 |
错误信息 |
来源 |
描述 |
2000 |
request parameter error. |
业务 |
参数为空或不合法 |
trigger与condition、caConditions条目树节点对象的定义
当前triggers,conditions、caConditions支持单个叶子结点或者在一个逻辑节点下挂多个叶子结点
actions是叶子结点列表
参数 |
类型 |
约束与枚举 |
描述 |
uri |
String |
见下表 |
节点url动作 |
params |
Object |
当节点为叶子结点时有效 |
节点参数 |
items |
Array |
当节点为逻辑节点时有效 |
叶子结点 |
URL枚举
逻辑节点支持的URL
url |
描述逻辑 |
适用范围 |
logical/and |
逻辑与 |
condition逻辑节点 |
logical/or |
逻辑或 |
trigger逻辑节点 |
triggers支持的URL
url |
描述逻辑 |
适用范围 |
trigger/timer |
定时器 |
triggers叶子节点 |
trigger/device/property |
设备属性 |
triggers叶子节点 |
trigger/device/event |
设备事件 |
triggers叶子节点 |
trigger/device/status |
设备属性 |
triggers叶子节点,(历史接口,当前请使用trigger/device/property) |
conditions支持的URL
url |
描述逻辑 |
适用范围 |
condition/device/property |
设备属性 |
conditions叶子节点 |
condition/timeRange |
比较当前时间是否在一个区间内 |
conditions叶子节点 |
caCondition支持的URL
url |
描述逻辑 |
适用范围 |
condition/device/property |
设备属性 |
conditions叶子节点 |
condition/timeRange |
比较当前时间是否在一个区间内 |
conditions叶子节点 |
actions支持的URL
url |
描述逻辑 |
适用范围 |
action/device/setProperty |
设置设备属性 |
actions叶子节点 |
action/device/invokeService |
调用设备服务 |
actions叶子节点 |
action/device/setStatus |
设置设备属性 |
actions叶子节点(历史接口,当前请使用action/device/setProperty) |
action/scene/trigger |
触发场景 |
actions叶子节点 |
叶子结点参数定义
/trigger/timer
参数 |
类型 |
描述 |
示例 |
参考 |
cron |
String |
定时表达式 |
33 10 1,2,3,4 |
cron表达式格式:http://crontab.org/ |
cronType |
String |
表达式类型,不能设置年;linux:表示crontab类型,5位;quartz_cron:quartz类型cron,7位,支持年。当前只能最小设置分钟级别,第一位秒级 必须是 0 |
linux |
cron表达式格式:http://crontab.org/ |
timezoneID |
时区ID,可空 |
时区ID,可空 |
Asia/Shanghai |
trigger/device/property
参数 |
类型 |
约束与枚举 |
描述 |
额外描述 |
iotId |
String |
|
iotId |
propertyName |
String |
|
设备属性名称 |
compareType |
String |
>, >=, ==,<=,<, !=,in,like等 |
比较类型 |
compareValue |
Object |
|
比较的值 |
localizedProductName |
String |
|
产品本地描述 |
仅查询时存在 |
localizedCompareValueName |
String |
|
比较值的本地描述 |
仅查询时存在 |
localizedPropertyName |
String |
|
属性本地描述 |
仅查询时存在 |
deviceNickName |
String |
|
设备昵称 |
仅查询时存在 |
productKey |
String |
|
ProductKey |
仅查询时存在 |
deviceName |
String |
|
设备名称 |
仅查询时存在 |
trigger/device/event
参数 |
类型 |
约束与枚举 |
描述 |
额外描述 |
iotId |
String |
|
iotId |
eventCode |
String |
|
设备eventCode |
propertyName |
String |
|
设备属性名称 |
compareType |
String |
>, >=, ==,<=,<, !=,in,like等 |
比较类型 |
compareValue |
Object |
|
比较的值 |
productKey |
String |
|
ProductKey |
仅查询时存在 |
deviceName |
String |
|
设备名称 |
仅查询时存在 |
condition/timeRange
参数 |
类型 |
描述 |
示例 |
参考 |
cron |
String |
定时表达式 |
33 10 1,2,3,4 |
cron表达式格式:http://crontab.org/ |
cronType |
String |
表达式类型,不能设置年;linux:表示crontab类型,5位;quartz_cron:quartz类型cron,7位,支持年。当前只能最小设置分钟级别,第一位秒级 必须是 0 |
linux |
cron表达式格式:http://crontab.org/ |
timezoneID |
时区ID,可空 |
时区ID,可空 |
Asia/Shanghai |
condition/device/property
参数 |
类型 |
描述 |
示例 |
备注 |
iotId |
String |
iotId |
|
|
propertyName |
String |
设备属性 |
|
|
compareType |
String |
比较类型 |
>, >=, ==,<=,<, !=,in,like等 |
|
compareValue |
Object |
比较值 |
|
|
localizedProductName |
String |
产品本地描述 |
|
仅查询时存在 |
localizedCompareValueName |
String |
比较值的本地描述 |
|
仅查询时存在 |
localizedPropertyName |
String |
属性本地描述 |
|
仅查询时存在 |
deviceNickName |
String |
设备昵称 |
|
仅查询时存在 |
productKey |
String |
ProductKey |
|
仅查询时存在 |
deviceName |
String |
设备名称 |
|
仅查询时存在 |
action/scene/trigger
参数 |
类型 |
描述 |
示例 |
sceneId |
String |
场景id |
action/device/invokeService
参数 |
类型 |
描述 |
示例 |
iotId |
String |
iotId |
|
serviceName |
服务名称 |
serviceArgs |
key:value 格式 |
服务参数集 |
action/device/setProperty
参数 |
类型 |
描述 |
示例 |
备注 |
iotId |
String |
iotId |
|
|
propertyName |
String |
设备属性名称 |
|
|
propertyValue |
Object |
属性值 |
|
|
status |
Integer |
action生效状态 |
0 action失效 1 action有效 |
|
localizedProductName |
String |
产品本地描述 |
|
仅查询时存在 |
localizedCompareValueName |
String |
比较值的本地描述 |
|
仅查询时存在 |
localizedPropertyName |
String |
属性本地描述 |
|
仅查询时存在 |
deviceNickName |
String |
设备昵称 |
|
仅查询时存在 |
productKey |
String |
ProductKey |
|
仅查询时存在 |
deviceName |
String |
设备名称 |
|
仅查询时存在 |
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.1",
"iotToken": "token"
},
"params": {
"sceneId": "260de82dd0cc484a80415a104691be22",
"groupId": "1"
}
}
返回示例
{
"code": 200,
"data": {
"mode":"all",
"valid":false,
"sceneType":"CA",
"enable":true,
"name":"日常风扇-工作模式 - 睡眠风",
"icon":"https://gaic.alicdn.com/ztms/cloud-intelligence-icons/icon/scene_img_choice_icon_7.png",
"iconColor":"#23CEC5",
"actionsJson":[
"{"params":{"iotId":"PTQeXooisgH3qrzW9TLb000101","localizedProductName":"日常风扇","propertyName":"WorkMode","localizedPropertyName":"工作模式","deviceNickName":"日常风扇","propertyValue":3,"localizedCompareValueName":"睡眠风","productKey":"a1RWKbzRwpu","propertyItems":{"WorkMode":3},"deviceName":"VD_soyCyFnIhH"},"uri":"action/device/setProperty","status":0}"
],
"id":"4dc9c2f7b39a477cad675e5a8451a254",
"caConditionsJson":[
"{"params":{"compareValue":1,"localizedProductName":"日常风扇","iotId":"PTQeXooisgH3qrzW9TLb000101","compareType":"==","propertyName":"PowerSwitch","localizedPropertyName":"电源开关","deviceNickName":"日常风扇","localizedCompareValueName":"开启","productKey":"a1RWKbzRwpu","deviceName":"VD_soyCyFnIhH"},"uri":"condition/device/property"}"
]
},
"message": "success"
}
trigger/device/event请求示例
{
"uri":"trigger/device/event",
"params":{
"productKey": "test_pk",
"deviceName": "test_dn",
"eventCode": "temp_warning",
"propertyName": "temp",
"compareType": ">",
"compareValue": 30
}
}
错误码
错误码 |
错误信息 |
来源 |
描述 |
10200 |
scene empty |
业务 |
没有这个场景 |
场景生效与失效
定义描述
path |
版本 |
描述 |
是否需要登录 |
/living/scene/switch |
1.0.0 |
场景自动化开启/关闭 |
是 |
请求参数
参数 |
类型 |
必填 |
约束 |
描述 |
sceneId |
String |
是 |
|
场景ID |
enable |
Boolean |
是 |
|
true 场景置为打开 false场景置为关闭 |
场景开关(App上的开关) |
返回参数
无
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.0",
"iotToken": "token"
},
"params": {
"sceneId": "0c96536b09404a50ac6645c5306a6657",
"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": "45dc6fc753d345b69b01d29f6974e5f7",
"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": "45dc6fc753d345b69b01d29f6974e5f7",
"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": "45dc6fc753d345b69b01d29f6974e5f7",
"flowType": 0
}
}
返回示例
{
"code": 200,
"data": {
"simplifyAbilityDTOs":[{
"name": "开关",
"identifier": "switch",
"categoryType": "xxxx",
"type": 1
}],
"abilityDsl": {}
},
"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":["b8fe2abac19e498ea8e367a026b76c31"]}
}
返回示例
{
"code":200,
"data":
[
{"sceneType":"IFTTT",
"name":"主灯开关 开启 - 灯模式 mono - 开启",
"icon":"https://img.alicdn.com/tfs/TB10G8tPrvpK1RjSZFqXXcXUVXa-144-144.png",
"sceneId":"b8fe2abac19e498ea8e367a026b76c31",
"sceneSwitch":1,
"triggers":"{\"params\":{},\"items\":[{\"params\":{\"eventCode\":\"\",\"compareValue\":1,\"iotId\":\"z8nqhWz3kZWdDGjp6SFY000101\",\"compareType\":\"==\",\"propertyName\":\"LightSwitch\",\"propertyValue\":1,\"productKey\":\"a1B0kMs35NW\",\"deviceName\":\"z8nqhWz3kZWdDGjp6SFY\"},\"uri\":\"trigger/device/property\"}],\"uri\":\"logical/or\"}",
"conditions":"{\"params\":{},\"items\":[{\"params\":{\"eventCode\":\"\",\"compareValue\":0,\"iotId\":\"z8nqhWz3kZWdDGjp6SFY000101\",\"compareType\":\"==\",\"propertyName\":\"LightMode\",\"propertyValue\":0,\"productKey\":\"a1B0kMs35NW\",\"deviceName\":\"z8nqhWz3kZWdDGjp6SFY\"},\"uri\":\"condition/device/property\"}],\"uri\":\"logical/and\"}",
"actions":"[{\"params\":{\"switchStatus\":1,\"automationRuleId\":\"503f5c75af4348f28d424a6cd520ceed\"},\"uri\":\"action/automation/setSwitch\"}]"}
],
"id":"1509086454180"
}
向手机推送消息action
定义描述
| path | 描述 |
| --- | --- |
| /action/mq/send | 向手机推送消息action |
请求参数
参数 |
类型 |
必填 |
约束 |
描述 |
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": "d5edf3a80e5c40d48aba0591b15e2028",
"iconColor": "#19BBFF",
"name": "向手机发送通知",
"description": " 描述 ",
"enable": true
},
{
"id": "debf2d332cbf48569d42b430d51496c2",
"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":["d5edf3a80e5c40d48aba0591b15e2028","debf2d332cbf48569d42b430d51496c2"]
}
}
返回示例
{
"code": 200,
"message": "success"
}