场景服务
更新时间:2018-08-01 16:58:34
提供一组客户端用户创建和配置自动化场景的接口。
获取支持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"
}
错误码
| 错误码 | 错误信息 | 来源 | 描述 |
|---|---|---|---|
| 200 | success | 系统 | 成功 |
| 400 | request error. | 系统 | 请求错误 |
| 401 | request auth error. | 系统 | 请求认证错误 |
| 403 | request forbidden. | 系统 | 请求被禁止 |
| 404 | service not found. | 系统 | 服务未找到 |
| 429 | too many requests. | 系统 | 太多请求 |
| 460 | request parameter error. | 系统 | 请求参数错误 |
| 500 | service error. | 系统 | 服务端错误 |
| 503 | service not available. | 系统 | 服务不可用 |
获取设备的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"
}
错误码
| 错误码 | 错误信息 | 来源 | 描述 |
|---|---|---|---|
| 200 | success | 系统 | 成功 |
| 400 | request error. | 系统 | 请求错误 |
| 401 | request auth error. | 系统 | 请求认证错误 |
| 403 | request forbidden. | 系统 | 请求被禁止 |
| 404 | service not found. | 系统 | 服务未找到 |
| 429 | too many requests. | 系统 | 太多请求 |
| 460 | request parameter error. | 系统 | 请求参数错误 |
| 500 | service error. | 系统 | 服务端错误 |
| 503 | service not available. | 系统 | 服务不可用 |
获取设备的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"
}
错误码
| 错误码 | 错误信息 | 来源 | 描述 |
|---|---|---|---|
| 200 | success | 系统 | 成功 |
| 400 | request error. | 系统 | 请求错误 |
| 401 | request auth error. | 系统 | 请求认证错误 |
| 403 | request forbidden. | 系统 | 请求被禁止 |
| 404 | service not found. | 系统 | 服务未找到 |
| 429 | too many requests. | 系统 | 太多请求 |
| 460 | request parameter error. | 系统 | 请求参数错误 |
| 500 | service error. | 系统 | 服务端错误 |
| 503 | service not available. | 系统 | 服务不可用 |
查询场景列表
定义描述
| path | 版本 | 描述 | 是否需要登录 |
|---|---|---|---|
| /scene/list/get | 1.0.2 | 查询场景列表 | 是 |
请求参数
| 参数 | 类型 | 必填 | 约束 | 描述 |
|---|---|---|---|---|
| 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.name
|
String
|
场景名称
|
|
|
scene.description
|
String
|
场景描述
|
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.1",
"iotToken": "token"
},
"params": {
"groupId": null,
"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
}, {
"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
}, {
"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
}, {
"description": "light-hy-LightSwitch-1 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "5b4bdee4d1d5457081082ee522612f81",
"name": "灯0522",
"status": 2
}, {
"description": "fengsan-hy-PowerSwitch-关闭 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "d6546aa844c24542b904423322887c3c",
"name": "的",
"status": 1
}, {
"description": "light-hy-LightSwitch-1, light-hy-LightSwitch-1 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "3c8bc0c09f4e411cb3d535598669741f",
"name": "两个灯0522",
"status": 2
}, {
"description": "light-hy-LightSwitch-1 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "70d90fe996964a718b42ec2997188911",
"name": "灯",
"status": 2
}, {
"description": "light-hy-LightSwitch-1, light-hy-LightSwitch-1 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "9fda7bc446e44ccc8edf4c0e39f89305",
"name": "两个灯",
"status": 2
}, {
"description": "light-hy-LightSwitch-1 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "51f632233dbd41618a50010b7f98d736",
"name": "灯",
"status": 2
}, {
"description": "light-hy-NightLightSwitch-关闭1 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "3f522eb034f842ba8d8e627612336709",
"name": "测",
"status": 2
}, {
"description": "light-hy-LightSwitch-1, light-hy-LightSwitch-1 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "b27071403662484baa0227e9abb645c4",
"name": "a多设备",
"status": 2
}, {
"description": "light-hy-LightSwitch-2 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "37cdaf4347694e3992752f21a349befb",
"name": "a关b开",
"status": 2
}, {
"description": "light-hy-LightSwitch-1, light-hy-LightSwitch-1 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/holiday.png",
"id": "d7f75a36a80b4b66bbcc228b31db4193",
"name": "",
"status": 2
}, {
"description": "light-hy-LightSwitch-1 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "99cd3559d06d4ded873bc6897ae67f74",
"name": "c时间设备",
"status": 2
}, {
"description": "light-hy-NightLightSwitch-开启2 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "3202047e1e4a4af38e5c4ab66a757ee3",
"name": "t时间设备",
"status": 2
}, {
"description": "light-hy-gongzuomoshi-手动0 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "4d3122b9cc9e463db3c71daf7b9cb584",
"name": "tc多设备",
"status": 2
}, {
"description": "light-hy-gongzuomoshi-手动0 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "57a5e7bcf89444cf9fb88afcb100ca83",
"name": "tc多属性",
"status": 2
}, {
"description": "light-hy-LightSwitch-2 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "acd4c825c94045019d6c6b07cee37939",
"name": "tc>设备",
"status": 2
}, {
"description": "light-hy-LightSwitch-1 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "fa20b66196d54cb583506ef27a0126dd",
"name": "c时间",
"status": 2
}, {
"description": "light-hy-LightSwitch-1 ",
"enable": true,
"icon": "https://g.aliplus.com/scene_icons/default.png",
"id": "5a743b38a9f0414b8911931323a3c2aa",
"name": "t时间",
"status": 2
}],
"total": 33
},
"message": "success"
}
错误码
| 错误码 | 错误信息 | 来源 | 描述 |
|---|---|---|---|
| 200 | success | 系统 | 成功 |
| 400 | request error. | 系统 | 请求错误 |
| 401 | request auth error. | 系统 | 请求认证错误 |
| 403 | request forbidden. | 系统 | 请求被禁止 |
| 404 | service not found. | 系统 | 服务未找到 |
| 429 | too many requests. | 系统 | 太多请求 |
| 460 | request parameter error. | 系统 | 请求参数错误 |
| 500 | service error. | 系统 | 服务端错误 |
| 503 | service not available. | 系统 | 服务不可用 |
| 2000 | request parameter error. | 业务 | 参数为空或不合法 |
| 2062 | identityId does not exist. | 业务 | identityId不存在 |
改变场景列表中表项的排序
定义描述
| path | 版本 | 描述 | 是否需要登录 |
|---|---|---|---|
| /scene/list/reorder | 1.0.2 | 改变场景列表中表项的排序 | 是 |
请求参数
|
参数
|
类型
|
必填
|
约束
|
描述
|
|
type
|
String
|
否
|
ilop
|
业务类型(目前可以选择填ilop或不填)
|
|
newOrders
|
Array
|
是
|
序号变化的场景数组
|
|
|
newOrders.sceneId
|
String
|
是
|
场景id
|
|
|
newOrders.fromOrder
|
Integer
|
是
|
顺序变化前的序号
|
|
|
newOrders.toOrder
|
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"
}
错误码
| 错误码 | 错误信息 | 来源 | 描述 |
|---|---|---|---|
| 200 | success | 系统 | 成功 |
| 400 | request error. | 系统 | 请求错误 |
| 401 | request auth error. | 系统 | 请求认证错误 |
| 403 | request forbidden. | 系统 | 请求被禁止 |
| 404 | service not found. | 系统 | 服务未找到 |
| 429 | too many requests. | 系统 | 太多请求 |
| 460 | request parameter error. | 系统 | 请求参数错误 |
| 500 | service error. | 系统 | 服务端错误 |
| 503 | service not available. | 系统 | 服务不可用 |
| 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"
}
错误码
| 错误码 | 错误信息 | 来源 | 描述 |
|---|---|---|---|
| 200 | success | 系统 | 成功 |
| 400 | request error. | 系统 | 请求错误 |
| 401 | request auth error. | 系统 | 请求认证错误 |
| 403 | request forbidden. | 系统 | 请求被禁止 |
| 404 | service not found. | 系统 | 服务未找到 |
| 429 | too many requests. | 系统 | 太多请求 |
| 460 | request parameter error. | 系统 | 请求参数错误 |
| 500 | service error. | 系统 | 服务端错误 |
| 503 | service not available. | 系统 | 服务不可用 |
| 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"
}
错误码
| 错误码 | 错误信息 | 来源 | 描述 |
|---|---|---|---|
| 200 | success | 系统 | 成功 |
| 400 | request error. | 系统 | 请求错误 |
| 401 | request auth error. | 系统 | 请求认证错误 |
| 403 | request forbidden. | 系统 | 请求被禁止 |
| 404 | service not found. | 系统 | 服务未找到 |
| 429 | too many requests. | 系统 | 太多请求 |
| 460 | request parameter error. | 系统 | 请求参数错误 |
| 500 | service error. | 系统 | 服务端错误 |
| 503 | service not available. | 系统 | 服务不可用 |
获取失败日志详情
定义描述
| path | 版本 | 描述 | 是否需要登录 |
|---|---|---|---|
| /scene/failedlog/get | 1.0.3 | 获取失败日志详情 | 是 |
请求参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| logId | String | 是 | 待查询的日志id |
| sceneId | String | 是 | 场景id |
| time | Long | 是 | /scene/log/list/get 返回的logs.time 单位毫秒 |
| pageNo | Integer | 是 | 请求的页数,第一次为1 |
| pageSize | Integer | 是 | 一次拉取的条目数 |
| groupId | String | 否 | 全屋时,表示全屋的houseId |
返回参数
|
参数
|
类型
|
约束与枚举
|
描述
|
|
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"
}
错误码
| 错误码 | 错误信息 | 来源 | 描述 |
|---|---|---|---|
| 200 | success | 系统 | 成功 |
| 400 | request error. | 系统 | 请求错误 |
| 401 | request auth error. | 系统 | 请求认证错误 |
| 403 | request forbidden. | 系统 | 请求被禁止 |
| 404 | service not found. | 系统 | 服务未找到 |
| 429 | too many requests. | 系统 | 太多请求 |
| 460 | request parameter error. | 系统 | 请求参数错误 |
| 500 | service error. | 系统 | 服务端错误 |
| 503 | service not available. | 系统 | 服务不可用 |
| 10200 | scene empty | 业务 | 没有这个场景 |
获取场景详情
定义描述
| path | 版本 | 描述 | 是否需要登录 |
|---|---|---|---|
| /scene/info/get | 1.0.2 | 获取场景详情 | 是 |
请求参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| sceneId | Long | 是 | 待查询的场景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
|
trigger与condition条目树节点对象的定义
当前triggers,conditions支持单个叶子结点或者在一个逻辑节点下挂多个叶子结点
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叶子节点 |
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
|
定时表达式
|
||
|
cronType
|
为了云、端统一,请使用:linux
|
cron类型
|
linux:crontab类型
|
|
timezoneID
|
东8区
|
时区ID,可空
|
Asia/Shanghai
|
trigger/device/property
| 参数 | 类型 | 约束与枚举 | 描述 |
|---|---|---|---|
| productKey | String | | productKey |
| deviceName | String | | deviceName |
| propertyName | String | | 设备属性名称 |
| compareType | String | >, >=, ==,<=,<, !=,in,like等 | 比较类型 |
| compareValue | Object | | 比较的值 |
trigger/device/event
| 参数 | 类型 | 约束与枚举 | 描述 |
|---|---|---|---|
| productKey | String | | productKey |
| deviceName | String | | deviceName |
| eventCode | String | | 设备eventCode |
| propertyName | String | | 设备属性名称 |
| compareType | String | >, >=, ==,<=,<, !=,in,like等 | 比较类型 |
| compareValue | Object | | 比较的值 |
condition/timeRange
| 参数 | 类型 | 描述 | 示例 |
|---|---|---|---|
| format | String | 格式化类型 | HH:mm |
| timezoneID | String | 时区ID | Asia/Shanghai |
| beginDate | String | 开始时间 | 12:55 |
| endDate | String | 截止时间 | 13:05 |
condition/device/property
|
参数
|
类型
|
描述
|
示例
|
|
productKey
|
String
|
产品Key
|
|
|
deviceName
|
String
|
设备名称
|
|
|
propertyName
|
String
|
设备属性
|
|
|
compareType
|
String
|
比较类型
|
>, >=, ==,<=,<, !=,
in,like等
|
|
compareValue
|
Object
|
比较值
|
action/scene/trigger
| 参数 | 类型 | 描述 | 示例 |
|---|---|---|---|
| sceneId | String | 场景id | |
action/device/invokeService
|
参数
|
类型
|
描述
|
示例
|
|
productKey
|
|
设备产品key
|
|
|
deviceName
|
|
设备名称
|
|
|
serviceName
|
|
服务名称
|
|
|
serviceArgs
|
{}
|
服务参数集,
key:value 格式
|
|
action/device/setProperty
|
参数
|
类型
|
描述
|
示例
|
|
productKey
|
String
|
设备产品key
|
|
|
deviceName
|
String
|
设备名称
|
|
|
propertyItems
|
{}
|
设备属性集,
key:value 格式
|
|
|
status
|
Integer
|
action生效状态
|
0 action失效
1 action有效
|
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.1",
"iotToken": "token"
},
"params": {
"sceneId": "260de82dd0cc484a80415a104691be22",
"groupId": null
}
}
返回示例
{
"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"
}
错误码
| 错误码 | 错误信息 | 来源 | 描述 |
|---|---|---|---|
| 200 | success | 系统 | 成功 |
| 400 | request error. | 系统 | 请求错误 |
| 401 | request auth error. | 系统 | 请求认证错误 |
| 403 | request forbidden. | 系统 | 请求被禁止 |
| 404 | service not found. | 系统 | 服务未找到 |
| 429 | too many requests. | 系统 | 太多请求 |
| 460 | request parameter error. | 系统 | 请求参数错误 |
| 500 | service error. | 系统 | 服务端错误 |
| 503 | service not available. | 系统 | 服务不可用 |
| 10200 | scene empty | 业务 | 没有这个场景 |
创建场景
定义描述
| path | 版本 | 描述 | 是否需要登录 |
|---|---|---|---|
| /scene/create | 1.0.2 | 创建场景 | 是 |
请求参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| enable | Boolean | 是 | true打开 false关闭 |
| name | String | 是 | 用户给场景起的名称 |
| icon | String | 是 | 场景图标 |
| description | String | 否 | 对场景的描述 |
| triggers | Object | 否 | trigger对象 |
| conditions | Object | 否 | condition对象 |
| actions | Array | 是 | action对象 |
注:action不能为空,trigger可以空,condition可以空
Trigger对象,Condition对象,Action对象文档查看 链接
返回参数
| 参数 | 类型 | 描述 |
|---|---|---|
| sceneId | String | 创建的场景Id |
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.1",
"iotToken": "token"
},
"params": {
"actions": [{
"params": {
"compareValue": 1,
"iotId": "zjoOvFZWenq1xdxRyvcI0010c4dc00",
"compareType": ">",
"propertyName": "Qu0wChfloat",
"propertyValue": 1
},
"uri": "action/device/setProperty"
}],
"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"
},
"groupId": null
}
}
返回示例
{
"code": 200,
"data": "debf2d332cbf48569d42b430d51496c2",
"message": "success"
}
错误码
| 错误码 | 错误信息 | 来源 | 描述 |
|---|---|---|---|
| 200 | success | 系统 | 成功 |
| 400 | request error. | 系统 | 请求错误 |
| 401 | request auth error. | 系统 | 请求认证错误 |
| 403 | request forbidden. | 系统 | 请求被禁止 |
| 404 | service not found. | 系统 | 服务未找到 |
| 429 | too many requests. | 系统 | 太多请求 |
| 460 | request parameter error. | 系统 | 请求参数错误 |
| 500 | service error. | 系统 | 服务端错误 |
| 503 | service not available. | 系统 | 服务不可用 |
| 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.2 | 更新场景 | 是 |
请求参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| sceneId | String | 是 | 场景Id |
| enable | Boolean | 是 | true打开 false关闭 |
| name | String | 是 | 用户给场景起的名称 |
| icon | String | 是 | 场景图标 |
| description | String | 否 | 对场景的描述 |
| triggers | Object | 否 | trigger对象 |
| conditions | Object | 否 | condition对象 |
| actions | Array | 是 | action对象 |
Trigger对象,Condition对象,Action对象文档查看 链接
返回参数
| 参数 | 类型 | 描述 |
|---|---|---|
| sceneId | String | 更新的场景Id |
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.1",
"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",
"triggers": {
"params": {},
"items": [{
"params": {
"cron": "0 0 * * *",
"cronType": "linux",
"timezoneID": "Asia/Shanghai"
},
"uri": "trigger/timer",
"status": 1
}],
"uri": "logical/or"
},
"groupId": null
}
}
返回示例
{
"code": 200,
"data": "bdc60beb0e6a4a24a8e03b417d617697",
"message": "success"
}
错误码
| 错误码 | 错误信息 | 来源 | 描述 |
|---|---|---|---|
| 200 | success | 系统 | 成功 |
| 400 | request error. | 系统 | 请求错误 |
| 401 | request auth error. | 系统 | 请求认证错误 |
| 403 | request forbidden. | 系统 | 请求被禁止 |
| 404 | service not found. | 系统 | 服务未找到 |
| 429 | too many requests. | 系统 | 太多请求 |
| 460 | request parameter error. | 系统 | 请求参数错误 |
| 500 | service error. | 系统 | 服务端错误 |
| 503 | service not available. | 系统 | 服务不可用 |
| 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"
}
错误码
| 错误码 | 错误信息 | 来源 | 描述 |
|---|---|---|---|
| 200 | success | 系统 | 成功 |
| 400 | request error. | 系统 | 请求错误 |
| 401 | request auth error. | 系统 | 请求认证错误 |
| 403 | request forbidden. | 系统 | 请求被禁止 |
| 404 | service not found. | 系统 | 服务未找到 |
| 429 | too many requests. | 系统 | 太多请求 |
| 460 | request parameter error. | 系统 | 请求参数错误 |
| 500 | service error. | 系统 | 服务端错误 |
| 503 | service not available. | 系统 | 服务不可用 |
| 10200 | scene empty | 业务 | 没有这个场景 |