定时场景API
# 说明
定时场景的字段请查看字段说明
# 列表查询
接口说明
根据查询条件查询场景列表。
接口版本
v1接口地址
/api-web-v1/scenes
请求方法
GET
请求参数
参数类型 | 参数名称 | 数据类型 | 是否必须 | 参数描述 | 默认 | 示例 |
---|---|---|---|---|---|---|
query | label | string | false | 模糊查询字段 | name | |
query | search | string | false | 模糊查询值 | 测试 | |
query | time | string | false | 时间范围查询字段,必须是场景字段中的时间或时间戳字段名,例如createdAt,updatedAt | createdAt | |
query | range | string[] or string | false | 时间范围,开始时间到结束时间,可以是string[]或者以逗号分割的开始时间到结束时间或时间戳 | 2019-10-22T00:00:00.000Z,2022-01-22T00:00:00.000Z | |
query | page | number | false | 分页第几页 | 1 | |
query | limit | number | false | 单页几条数据 | 10 | |
query | sort | string | false | 根据哪个字段排序 | _id | -createdAt |
query | select | string | false | 只查询部分字段,字段名之间用过空格分隔,去掉某个字段的查询字段名前面加- | ||
query | autopopulate | boolean | false | 自动关联数据,部分字段自动关联关系表查询,设置这个值可开关自动联表查询 | true | false |
query | populate | string | false | 指定关联表查询,查询多个关联表用逗号分隔 | control |
请求参数举例
注意
GET请求所有参数类型都会变成string拼接在url上面,文档为了表述清晰,将示例结构以json格式编写
{
"page":"1",
"limit":"10",
"sort":"-createdAt",
"autopopulate":"false"
}
返回参数
参数名称 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|
code | number | True | 是否成功 |
data | json | True | 返回数据 |
-total | number | False | 场景总条数 |
-rows | array | False | 当前返回的场景对象列表 |
返回参数举例
{
"code": 0,
"data": {
"total": 232,
"rows": [
{
"icon": "tree",
"roll": false,
"doneAc": [],
"tags": [],
"alertType": false,
"_id": "6139b7c00e9fd7001b319113",
"type": 0,
"isRun": false,
"sort": 1,
"actions": [
{
"aTypeValue": [
"o",
"5fa3b1dba4475c001b2136ad",
"610375509d0b8a001bdbfb58",
"61038435306dcc001b913789",
"6103843a306dcc001b91379a"
],
"_id": "6139b7c00e9fd7001b319114",
"sort": 1,
"performTime": 0,
"performType": 1,
"performContent": null,
"interval": [
{
"label": "开启",
"value": 1
},
{
"label": "关闭",
"value": 0
}
],
"operate": "6103843a306dcc001b91379a",
"type": "o"
},
{
"aTypeValue": [
"o",
"5fa3b1dba4475c001b2136ad",
"610375509d0b8a001bdbfb58",
"61038435306dcc001b913789",
"61038451306dcc001b9137dd"
],
"_id": "6139b7c00e9fd7001b319115",
"sort": 2,
"performTime": 1000,
"performType": 1,
"performContent": null,
"interval": [
{
"label": "开启",
"value": 1
},
{
"label": "关闭",
"value": 0
}
],
"operate": "61038451306dcc001b9137dd",
"type": "o"
}
],
"name": "2楼培养室空调定时开启",
"sceneDis": "jn",
"control": "5fa3b1dba4475c001b2136ad",
"executeTime": [
{
"weeks": [
0
],
"_id": "6139bb6e0e9fd7001b31cd84",
"days": null,
"months": null,
"years": null,
"hours": 6,
"minutes": 0,
"seconds": 0
}
],
"creator": "5dc3e4795b5edb001c2c1314",
"createdAt": "2021-09-09T07:29:04.578Z",
"updatedAt": "2021-11-20T06:10:05.266Z",
"__v": 4,
"state": 1
},
{
"icon": "tree",
"roll": false,
"doneAc": [],
"tags": [],
"alertType": false,
"_id": "61387586eb8c0e001c99c71d",
"type": 0,
"isRun": false,
"sort": 1,
"actions": [
{
"aTypeValue": [
"o",
"5fa3b1dba4475c001b2136ad",
"60bf3e0d9c8abd001bdc6c4b",
"60d05895f43f1e001c6fd206",
"60d058b8f43f1e001c6fd26f"
],
"_id": "61387586eb8c0e001c99c71e",
"sort": 1,
"performTime": 0,
"performType": 0,
"performContent": null,
"interval": [
{
"label": "开启",
"value": 1
},
{
"label": "关闭",
"value": 0
}
],
"operate": "60d058b8f43f1e001c6fd26f",
"type": "o"
},
{
"aTypeValue": [
"o",
"5fa3b1dba4475c001b2136ad",
"60bf3e0d9c8abd001bdc6c4b",
"60d05895f43f1e001c6fd206",
"60d05988f43f1e001c6fd3f2"
],
"_id": "61387586eb8c0e001c99c71f",
"sort": 2,
"performTime": 0,
"performType": 0,
"performContent": null,
"interval": [
{
"label": "开启",
"value": 1
},
{
"label": "关闭",
"value": 0
}
],
"operate": "60d05988f43f1e001c6fd3f2",
"type": "o"
}
],
"name": "3楼农化液相仪器室空调自动关闭",
"control": "5fa3b1dba4475c001b2136ad",
"sceneDis": "jn",
"executeTime": [
{
"weeks": [
0
],
"_id": "6195bea68a58a9001cd28e1b",
"years": null,
"months": null,
"days": null,
"hours": 17,
"minutes": 11,
"seconds": 26
}
],
"creator": "5dc3e4795b5edb001c2c1314",
"createdAt": "2021-09-08T08:34:14.489Z",
"updatedAt": "2021-11-18T02:49:34.703Z",
"__v": 3,
"state": 1
}
]
}
}
# 查询场景ID
接口说明
根据场景ID查询场景
接口版本
v1接口地址
/api-v1/scenes/:id
请求方法
GET
请求参数
参数类型 | 参数名称 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|---|
params | id | string | True | 场景ID |
请求参数举例
注意
GET请求所有参数类型都会拼接在url上面,文档为了表述清晰,将示例结构以json格式编写
{
"_id": "61387586eb8c0e001c99c71d"
}
返回参数
参数名称 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|
code | number | True | 是否成功 |
data | json | false | 返回场景信息 |
返回参数举例
{
"code": 0,
"data": {
"icon": "tree",
"roll": false,
"doneAc": [],
"tags": [],
"alertType": false,
"_id": "61387586eb8c0e001c99c71d",
"type": 0,
"isRun": false,
"sort": 1,
"actions": [
{
"aTypeValue": [
"o",
"5fa3b1dba4475c001b2136ad",
"60bf3e0d9c8abd001bdc6c4b",
"60d05895f43f1e001c6fd206",
"60d058b8f43f1e001c6fd26f"
],
"_id": "61387586eb8c0e001c99c71e",
"sort": 1,
"performTime": 0,
"performType": 0,
"performContent": null,
"interval": [
{
"label": "开启",
"value": 1
},
{
"label": "关闭",
"value": 0
}
],
"operate": "60d058b8f43f1e001c6fd26f",
"type": "o"
},
{
"aTypeValue": [
"o",
"5fa3b1dba4475c001b2136ad",
"60bf3e0d9c8abd001bdc6c4b",
"60d05895f43f1e001c6fd206",
"60d05988f43f1e001c6fd3f2"
],
"_id": "61387586eb8c0e001c99c71f",
"sort": 2,
"performTime": 0,
"performType": 0,
"performContent": null,
"interval": [
{
"label": "开启",
"value": 1
},
{
"label": "关闭",
"value": 0
}
],
"operate": "60d05988f43f1e001c6fd3f2",
"type": "o"
}
],
"name": "3楼农化液相仪器室空调自动关闭",
"control": "5fa3b1dba4475c001b2136ad",
"sceneDis": "jn",
"executeTime": [
{
"weeks": [
0
],
"_id": "6195bea68a58a9001cd28e1b",
"years": null,
"months": null,
"days": null,
"hours": 17,
"minutes": 11,
"seconds": 26
}
],
"creator": "5dc3e4795b5edb001c2c1314",
"createdAt": "2021-09-08T08:34:14.489Z",
"updatedAt": "2021-11-18T02:49:34.703Z",
"__v": 3,
"state": 1
}
}
# 新建
接口说明
新建一个场景。
接口版本
v1接口地址
/api-v1/scenes
请求方法
POST
请求参数
参数类型 | 参数名称 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|---|
body | - | Object | True | 场景对象字段说明 |
请求参数举例
{
"icon": "tree",
"roll": false,
"doneAc": [],
"tags": [],
"alertType": false,
"type": 0,
"isRun": false,
"sort": 1,
"actions": [
{
"aTypeValue": [
"o",
"5fa3b1dba4475c001b2136ad",
"60bf3e0d9c8abd001bdc6c4b",
"60d05895f43f1e001c6fd206",
"60d058b8f43f1e001c6fd26f"
],
"sort": 1,
"performTime": 0,
"performType": 0,
"performContent": null,
"interval": [
{
"label": "开启",
"value": 1
},
{
"label": "关闭",
"value": 0
}
],
"operate": "60d058b8f43f1e001c6fd26f",
"type": "o"
}
],
"name": "TEST场景测试",
"control": "5fa3b1dba4475c001b2136ad",
"sceneDis": "jn",
"executeTime": [
{
"weeks": [
0
],
"years": null,
"months": null,
"days": null,
"hours": 17,
"minutes": 11,
"seconds": 26
}
],
"state": 1
}
// Make sure to add code blocks to your code group
返回参数
参数名称 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|
code | number | True | 是否成功 |
data | json | True | 返回创建的对象 |
返回参数举例
{
"code": 0,
"data": {
"icon": "tree",
"roll": false,
"doneAc": [],
"tags": [],
"alertType": false,
"type": 0,
"isRun": false,
"sort": 1,
"_id": "61387586eb8c0e001c99c71d",
"actions": [
{
"aTypeValue": [
"o",
"5fa3b1dba4475c001b2136ad",
"60bf3e0d9c8abd001bdc6c4b",
"60d05895f43f1e001c6fd206",
"60d058b8f43f1e001c6fd26f"
],
"_id": "61387586eb8c0e001c99c71e",
"sort": 1,
"performTime": 0,
"performType": 0,
"performContent": null,
"interval": [
{
"label": "开启",
"value": 1
},
{
"label": "关闭",
"value": 0
}
],
"operate": "60d058b8f43f1e001c6fd26f",
"type": "o"
}
],
"name": "TEST场景测试",
"control": "5fa3b1dba4475c001b2136ad",
"sceneDis": "jn",
"executeTime": [
{
"weeks": [
0
],
"_id": "6195bea68a58a9001cd28e1b",
"years": null,
"months": null,
"days": null,
"hours": 17,
"minutes": 11,
"seconds": 26
}
],
"state": 1
}
}
# 编辑
接口说明
修改场景。
接口版本
v1接口地址
/api-v1/scenes/:id
请求方法
PUT
请求参数
参数类型 | 参数名称 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|---|
params | id | string | True | 修改的场景ID |
body | - | Object | True | 场景对象字段说明 |
请求参数举例
{
"name":"测试场景修改"
}
// Make sure to add code blocks to your code group
返回参数
参数名称 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|
code | number | True | 是否成功 |
data | json | True | 返回创建的对象 |
返回参数举例
{
"code": 0,
"data": {
"icon": "tree",
"roll": false,
"doneAc": [],
"tags": [],
"alertType": false,
"type": 0,
"isRun": false,
"sort": 1,
"_id": "61387586eb8c0e001c99c71d",
"actions": [
{
"aTypeValue": [
"o",
"5fa3b1dba4475c001b2136ad",
"60bf3e0d9c8abd001bdc6c4b",
"60d05895f43f1e001c6fd206",
"60d058b8f43f1e001c6fd26f"
],
"_id": "61387586eb8c0e001c99c71e",
"sort": 1,
"performTime": 0,
"performType": 0,
"performContent": null,
"interval": [
{
"label": "开启",
"value": 1
},
{
"label": "关闭",
"value": 0
}
],
"operate": "60d058b8f43f1e001c6fd26f",
"type": "o"
}
],
"name": "TEST场景测试",
"control": "5fa3b1dba4475c001b2136ad",
"sceneDis": "jn",
"executeTime": [
{
"weeks": [
0
],
"_id": "6195bea68a58a9001cd28e1b",
"years": null,
"months": null,
"days": null,
"hours": 17,
"minutes": 11,
"seconds": 26
}
],
"state": 1
}
}
# 删除
接口说明
删除一个场景。
接口版本
v1接口地址
/api-v1/scenes/:id
请求方法
DELETE
请求参数
参数类型 | 参数名称 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|---|
params | id | string | True | 删除的场景ID |
请求参数举例
只需发送删除场景的ID
返回参数
参数名称 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|
code | number | True | 是否成功 |
message | string | false | 成功删除返回complete |
返回参数举例
{
"code": 0,
"message": "complete"
}
此接口需实际场景。文档不提供删除在线调试
# 执行
接口说明
执行一个场景。
接口版本
v1接口地址
/api-v1/scenes/:id/click
请求方法
GET
请求参数
参数类型 | 参数名称 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|---|
params | id | string | True | 立即执行 |
请求参数举例
只需发送执行场景的ID
返回参数
参数名称 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|
code | number | True | 是否成功 |
message | string | false | 成功删除返回complete |
返回参数举例
{
"code": 0,
"message": '成功'
}
此接口需实际场景。文档不提供删除在线调试
# 场景启停
接口说明
场景启停一个场景。
接口版本
v1接口地址
/api-v1/scenes/:id/time
请求方法
PUT
请求参数
参数类型 | 参数名称 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|---|
params | id | string | True | 场景ID |
params | state | int | True | 当前状态 |
请求参数举例
只需发送启停场景的ID和状态
返回参数
参数名称 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|
code | number | True | 是否成功 |
message | string | false | 成功删除返回发送 |
返回参数举例
{
"code": 0,
"message": '发送'
}
此接口需实际场景。文档不提供删除在线调试
上次更新: 2022/07/13, 14:05:11