# API 列表
# 1 设备管理
# 1.1 设置设备属性
- 使用说明:
设置设备属性值。
- 接口地址:
POST /openapi/v1/things/{device_id}/properties - 请求参数:
字段名 | 类型 | 位置 | 是否必填 | 说明 |
device_id | string | path | true | 设备 id |
- 请求体:
字段名 | 类型 | 说明 |
params | list | 设备属性列表(具体属性可以查询设备所属产品的物模型) |
- 返回参数:
字段名 | 类型 | 说明 |
message_id | uint32 | 当前设备消息唯一 id,用于调试 |
- 请求示例:
POST /openapi/v1/things/7e90e6fdf4a543dUeAPS/properties
{
"params": {
"property1": 1,
"property2": "hello"
}
} - 返回示例:
{
"code": 0,
"message": "success",
"data": {
"message_id": 1
}
} # 1.2 调用设备服务
- 使用说明:
调用设备的指定服务。设备的服务定义于设备所属产品的物模型中,调用该接口时,会根据 service_id 值,选择服务对应的调用方式。(目前只支持异步调用)
- 接口地址:
POST /openapi/v1/things/{device_id}/services/{service_id} - 请求参数:
字段名 | 类型 | 位置 | 是否必填 | 说明 |
device_id | string | path | true | 设备唯一 id |
service_id | string | path | true | 设备服务 id |
- 请求体:
字段名 | 类型 | 说明 |
params | list | 设备服务参数列表(具体属性可以查询设备所属产品的物模型) |
- 返回参数:
字段名 | 类型 | 说明 |
message_id | uint32 | 当前设备消息唯一 id,用于调试 |
- 请求示例:
POST /openapi/v1/things/7e90e6fdf4a543dUeAPS/services/timer
{
"params": {
"param1": 1,
"param2": "hello"
}
} - 返回示例:
{
"code": 0,
"message": "success",
"data": {
"message_id": 1
}
} # 1.3 查询设备详情
# 1. 通过 device_id 查询
- 接口地址:
GET /openapi/v1/things/{device_id}/detail - 返回参数:
字段名 | 类型 | 说明 |
device_info | json | 设备详情 |
device_name | string | 设备名(设备三元组之一) |
product_key | string | 产品唯一标识(设备三元组之一) |
device_secret | string | 设备密钥(设备三元组之一) |
device_id | string | 设备唯一标识 |
node_type | string | 节点类型:direct(直连设备),gateway(网关设备),gateway-sub(网关子设备) |
protocol_type | string | 协议类型:zigbee,ble |
validate_type | string | 设备数据校验类型:none(无校验),weak(弱校验) |
data_format | string | 设备数据格式:json,raw(hex 格式) |
product_name | string | 产品名称 |
nickname | string | 设备昵称 |
register_at | date | 设备注册日期 |
updated_at | date | 设备最近更新日期 |
ip | string | 设备 ip 地址 |
status | string | 在线状态:online(在线),offline(离线) |
- 请求示例:
GET /openapi/v1/things/xxx/detail
- 返回示例:
{
"code": 0,
"message": "SUCCESS",
"data": {
"device_info": {
"device_secret": "xxxx",
"device_name": "000000b0",
"product_key": "f4e7b826",
"node_type": "direct",
"protocol_type": "",
"validate_type": "none",
"data_format": "json",
"product_name": "xxxx",
"nickname": "",
"device_id": "xxx",
"register_at": "0001-01-01T00:00:00Z",
"updated_at": "0001-01-01T00:00:00Z",
"ip": "",
"status": "unactive",
"access_key": "xxxx"
}
}
} # 2.通过 device_name 和 product_key 查询
- 接口地址:
GET /openapi/v1/products/{product_key}/device-names/{device_name}/detail - 请求示例:
GET /openapi/v1/products/xxx/device-names/xxx/detail
# 1.4 查询设备在线状态
- 使用说明:
查询设备在线状态。
- 接口地址:
GET /openapi/v1/things/{device_id}/status - 请求参数:
字段名 | 类型 | 位置 | 是否必填 | 说明 |
device_id | string | path | true | 设备唯一 id |
- 返回参数:
字段名 | 类型 | 说明 |
status | string | online,offline |
- 请求示例:
GET /openapi/v1/things/b951e7fd4221460xK2Ni/status
- 返回示例:
{
"code": 0,
"message": "success",
"data": {
"status": "online"
}
} # 1.5 修改设备状态
- 使用说明:
修改设备状态。
- 接口地址:
PUT /openapi/v1/things/{device_id}/status - 请求参数:
字段名 | 类型 | 位置 | 是否必填 | 说明 |
device_id | string | path | true | 设备唯一 id |
- 请求体:
字段名 | 类型 | 说明 |
action | string | enable(启用) disble(禁用) unbind (解绑) bind (绑定) |
- 请求示例:
PUT /openapi/v1/things/b951e7fd4221460xK2Ni/status
{
"action": "enable"
} - 返回示例:
{
"code": 0,
"message": "success"
} # 1.6 验证蓝牙设备身份
- 使用说明:
用于设备蓝牙辅助配网时设备身份校验。
- 接口地址:
POST /openapi/v1/auth/ble/products/{product_key}/identity - 请求参数:
字段名 | 类型 | 位置 | 是否必填 | 说明 |
product_key | string | path | true | 产品唯一标识 |
- 请求体:
字段名 | 类型 | 说明 |
device_name | string | 设备名称 |
random | string | 配网时用户身份标识 |
cipher | string | 密钥,用于校验身份 |
- 返回参数:
字段名 | 类型 | 说明 |
ble_key | string | 用于设备、app 数据交互 |
- 请求示例:
{
"device_name": "xxx",
"random": "xxx",
"cipher": "xxx"
} - 返回示例:
{
"code": 0,
"message": "success",
"data": {
"ble_key": "xxx"
}
} # 1.7 修改网关设备拓扑动作
- 使用说明:
用于管理网关设备与子设备的拓扑关系。网关设备收到消息后会进入对应状态。
- 接口地址:
PUT /openapi/v1/things/{device_id}/topo - 请求参数:
字段名 | 类型 | 位置 | 是否必填 | 说明 |
device_id | string | path | true | 网关设备 id,设备唯一标识 |
- 请求体:
字段名 | 类型 | 说明 |
action | string | sub.add.start(开始子设备添加) sub.add.stop(停止子设备添加) |
session_id | string | 当动作为 sub.add.stop 时必填 |
params | object | 参数 |
timeout | int | 网关添加子设备超时时间,单位秒; 不传则默认为 60; |
product_keys | array | 网关添加的子设备类型,即子设备的 product_key |
- 返回参数:
字段名 | 类型 | 说明 |
session_id | string | 该次配网请求唯一标识 |
- 请求示例:
PUT /openapi/v1/things/5a7060a3822d4b6Yc25j/topo
{
"action": "sub.add.start",
"params": {
"timeout": 10, //网关添加子设备超时时间,单位秒; 不传则默认为60;
"product_keys": ["xxx", "xxx"]
}
} - 返回示例:
{
"code": 0,
"message": "success",
"data": {
"session_id": "xxxx"
}
} - 请求示例:
PUT /openapi/v1/things/5a7060a3822d4b6Yc25j/topo
{
"action": "sub.add.stop",
"session_id": "xxx"
} - 返回示例:
{
"code": 0,
"message": "success"
} # 1.8 删除设备拓扑关系
- 使用说明:
用于删除网关与子设备的拓扑关系
- 接口地址:
DELETE /openapi/v1/things/{device_id}/topo - 请求体:
字段名 | 类型 | 说明 |
params | list | 子设备列表 |
device_name | string | 设备名称 |
product_key | string | 产品唯一标识 |
- 请求示例:
DELETE /openapi/v1/things/5a7060a3822d4b6Yc25j/topo
{
"params": [
{
"device_name": "xxx",
"product_key": "xxx"
},
{
"device_name": "xxx",
"product_key": "xxx"
}
]
} - 返回示例:
{
"code": 0,
"message": "success"
} # 1.9 查询设备拓扑关系
- 使用说明:
用于获取网关设备下的子设备信息
- 接口地址:
GET /openapi/v1/things/{device_id}/topo - 请求参数:
字段名 | 类型 | 位置 | 是否必填 | 说明 |
device_id | string | path | true | 网关设备 id,设备唯一标识 |
session_id | string | query | true | 配网动作唯一标识 |
- 返回参数:
字段名 | 类型 | 说明 |
device_id | string | 子设备 id,设备唯一标识 |
device_name | string | 子设备三元组设备名 |
product_key | string | 子设备三元组产品名 |
- 请求示例:
GET /openapi/v1/things/xxx/topo?session_id=xxx
- 返回示例:
{
"code": 0,
"message": "success",
"data": {
"sub_devices": [
{
"device_id": "xxx",
"device_name": "xxx",
"product_key": "xxx"
},
{
"device_id": "xxx",
"device_name": "xxx",
"product_key": "xxx"
}
]
}
} # 1.10 查询设备物模型属性
- 使用说明:
查询设备最新属性。
- 接口地址:
GET /openapi/v1/things/{device_id}/properties - 请求参数:
字段名 | 类型 | 位置 | 是否必填 | 说明 |
device_id | string | path | true | 设备 id |
- 返回参数:
字段名 | 类型 | 说明 |
properties | object | 设备属性 |
- 请求示例:
GET /openapi/v1/things/xxx/properties
- 返回示例:
{
"code": 0,
"message": "success",
"data": {
"properties": {
"prop1": 1,
"prop2": 2,
"prop3": 3
}
}
} # 2 产品管理
# 2.1 查询单个产品详情
- 接口地址:
GET /openapi/v1/products/{product_key} - 请求参数:
字段名 | 类型 | 位置 | 是否必填 | 说明 |
product_key | string | path | true | 产品唯一标识 |
- 返回参数:
字段名 | 类型 | 说明 |
product_info | json | 产品详情 |
product_key | string | 产品唯一标识 |
product_secret | string | 产品密钥 |
name | string | 产品名称 |
device_type | string | 设备品类 |
network_type | string | 网络类型:wifi,ethernet,cellular,lorawan,others |
node_type | string | 节点类型: direct(直连设备), gateway(网关设备), gateway-sub(网关子设备) |
protocol_type | string | 协议类型:zigbee,ble |
validate_type | string | 设备数据校验类型: none(无校验), weak(弱校验) |
data_format | string | 设备数据格式: json,raw(hex 格式) |
register_at | date | 设备注册日期 |
updated_at | date | 产品最近更新日期 |
created_at | date | 产品创建日期 |
dynamic_register | bool | 动态注册开关 |
status | string | 状态: developing(开发中), released(已发布) |
- 请求示例:
GET /openapi/v1/products/6f2f5483
- 返回示例:
{
"code": 0,
"message": "SUCCESS",
"data": {
"product_info": {
"id": 11,
"product_key": "6f2f5483",
"product_secret": "xxxx",
"project_id": 0,
"name": "sub-json-test",
"device_type": "light",
"network_type": "",
"protocol_type": "zigbee",
"description": "",
"photo_url": "http://192.168.2.111:4000/api/v1/oss/buckets/fogcloud-config?filename=XuyAq1635839607.png",
"configuration": "",
"created_at": "2021-11-02T15:53:32.909771+08:00",
"updated_at": "2021-11-02T15:53:32.909772+08:00",
"node_type": "gateway-sub",
"data_format": "json",
"auth_type": "secret",
"status": "developing",
"dynamic_register": false
}
}
} # 2.2 查询产品列表
- 使用说明:
获取当前项目下产品列表,数据分页返回
- 接口地址:
GET /openapi/v1/products
- 请求参数:
字段名 | 类型 | 位置 | 是否必填 | 说明 |
page | int | query | false | 当前页数。(不传则默认为 1) |
page_size | int | query | false | 每页数据量。(不传则默认为 10) |
- 返回参数:
字段名 | 类型 | 说明 |
results | list | 列表数据 |
total | int | 数据总数 |
page | int | 当前页数 |
page_size | int | 当前页大小 |
pages | int | 总页数 |
- 请求示例:
GET /openapi/v1/products?page=1&page_size=2 - 返回示例:
{
"code": 0,
"message": "SUCCESS",
"data": {
"page": 1,
"page_size": 2,
"pages": 0,
"results": [
{
"id": 17,
"product_key": "1ea2536e",
"product_secret": "4abb17934225668d617b07d5f3273ee9",
"project_id": 0,
"name": "a",
"device_type": "",
"network_type": "wifi",
"protocol_type": "",
"description": "",
"photo_url": "http://192.168.2.111:4000/api/v1/oss/buckets/fogcloud-config?filename=v9ZsM1636598368.png",
"configuration": "",
"created_at": "2021-11-11T10:39:30.439694+08:00",
"updated_at": "2021-11-11T10:39:30.439694+08:00",
"node_type": "direct",
"data_format": "json",
"auth_type": "secret",
"status": "developing",
"dynamic_register": false
},
{
"id": 16,
"product_key": "42a26cb7",
"product_secret": "edb676e49cc55737429f2b03a2afe4aa",
"project_id": 0,
"name": "SK_TEST_VIP",
"device_type": "",
"network_type": "wifi",
"protocol_type": "",
"description": "",
"photo_url": "http://192.168.2.111:4000/api/v1/oss/buckets/fogcloud-config?filename=ZuAbs1636532596.png",
"configuration": "",
"created_at": "2021-11-10T16:23:17.926998+08:00",
"updated_at": "2021-11-11T10:39:14.243438+08:00",
"node_type": "direct",
"data_format": "json",
"auth_type": "secret",
"status": "developing",
"dynamic_register": false
}
],
"total": 10
}
} # 3 物模型管理
# 3.1 查询产品物模型
- 接口地址:
GET /openapi/v1/products/{product_key}/thing-model - 请求参数
字段名 | 类型 | 位置 | 是否必填 | 说明 |
model_type | string | query | true | 物模型数据格式:metadata,tsl |
- 返回参数:
物模型数据格式见文档
- 请求示例:
GET /openapi/v1/products/6f2f5483/thing-model?model_type=metadata
- 返回示例:
{
"code": 0,
"message": "SUCCESS",
"data": {
"thing_model": {
"properties": [
{
"id": "param1",
"name": "param1",
"required": false,
"standard": false,
"funcType": "property",
"accessMode": "rw",
"dataType": {
"type": "int",
"size": 10,
"length": 10240,
"elementType": "int"
}
}
],
"events": [
{
"id": "post",
"name": "post",
"required": true,
"standard": false,
"funcType": "event",
"desc": "属性上报",
"method": "thing.event.property.post",
"eventType": "info",
"outputData": [
{
"id": "param1",
"name": "param1",
"dataType": {
"type": "int",
"size": 10,
"length": 10240,
"elementType": "int"
}
}
]
}
],
"services": [
{
"id": "set",
"name": "set",
"required": true,
"standard": false,
"funcType": "service",
"desc": "属性设置",
"method": "thing.service.property.set",
"eventType": "",
"outputData": [],
"callType": "async",
"inputData": [
{
"id": "param1",
"name": "param1",
"dataType": {
"type": "int",
"size": 10,
"length": 10240,
"elementType": "int"
}
}
]
}
]
}
}
} # 4 设备影子查询
# 4.1 查询设备影子
- 接口说明:
设备影子包含设备最新的属性值、期望的属性值、在线状态,和属性更新时间戳。
- 接口地址:
GET /openapi/v1/things/{device_id}/shadow - 返回参数: 设备影子数据格式见文档
- 请求示例:
GET /openapi/v1/things/4b1da8c4faee4deP1Ljl/shadow
- 返回示例:
{
"code": 0,
"message": "SUCCESS",
"data": {
"thing_shadow": {
"state": {
"desired": {
"brightness": 777,
"switch": 1
},
"reported": {}
},
"metadata": {
"desired": {
"brightness": {
"timestamp": 1635478451
},
"switch": {
"timestamp": 1635478451
}
},
"reported": {}
},
"id": 0,
"timestamp": 1635478451,
"status": "offline"
}
}
} # 4.2 更新设备影子期望值
- 接口说明:
设置设备影子期望值,可用于设备离线时进行控制指令缓存,设备恢复网络连接后可以根据期望值进行属性更新。
- 接口地址:
PUT /openapi/v1/things/{device_id}/shadow - 请求体:
字段名 | 类型 | 说明 |
state | json 对象 | 期望的设备属性数据 |
- 请求示例:
PUT /openapi/v1/things/4b1da8c4faee4deP1Ljl/shadow
{
"state": {
"desired": {
"switch": 1,
"brightness": 666
}
}
} - 返回示例:
{
"code": 0,
"message": "SUCCESS"
} # 5 固件升级相关
# 5.1 检查设备更新
- 接口地址:
GET /openapi/v1/things/{device_id}/upgrade?module=default - 请求参数
字段名 | 类型 | 位置 | 是否必填 | 说明 |
device_id | string | path | true | 设备唯一 id |
module | string | query | false | 模块名称(不传则默认为 default) |
- 返回参数:
字段名 | 类型 | 说明 |
size | int32 | 固件大小,单位 byte |
sign | string | 固件 md5 签名 |
sign_method | string | 摘要算法,固定为 md5 |
version | string | 固件版本,采用"x.y.z"格式 |
url | string | 固件下载 url |
module | string | 模块名称 |
task_id | string | 当前固件升级任务唯一标识 |
description | string | 固件描述 |
- 请求示例:
GET /openapi/v1/things/60ff5696991b405bkmhn/upgrade
- 返回示例:
{
"code": 0,
"message": "SUCCESS",
"data": {
"size": 0,
"sign": "90d5683b2887b65fc65b5a4b93248fd0",
"sign_method": "MD5",
"version": "1.0.1",
"url": "http://example.com/api/v1/oss/buckets/fogcloud-firmware?filename=f4e7b826/1635748072ekh3Yt.zip",
"module": "default",
"task_id": "15",
"description": "xxxx"
}
} # 5.2 升级设备
- 接口地址:
POST /openapi/v1/things/{device_id}/upgrade - 请求体
字段名 | 类型 | 说明 |
task_id | string | 固件升级任务唯一标识 |
- 请求示例:
POST /openapi/v1/things/60ff5696991b405bkmhn/upgrade
{
"task_id": "xxx"
} - 返回示例:
{
"code": 0,
"message": "SUCCESS"
} # 5.3 查询设备升级进度
- 接口地址:
GET /openapi/v1/things/{device_id}/upgrade-step?task_id=0 - 请求参数
字段名 | 类型 | 位置 | 是否必填 | 说明 |
device_id | string | path | true | 设备唯一 id |
task_id | string | query | false | 任务 id |
- 返回参数:
字段名 | 类型 | 说明 |
step | int32 | 升级进度。-1(升级失败),0~100(升级进度百分比) |
- 请求示例:
GET /openapi/v1/things/60ff5696991b405bkmhn/upgrade-step?task_id=1
- 返回示例:
{
"code": 0,
"message": "SUCCESS",
"data": {
"step": 10
}
} # 5.4 查询设备固件版本号
- 接口地址:
GET /openapi/v1/things/{device_id}/version?module=default - 请求参数
字段名 | 类型 | 位置 | 是否必填 | 说明 |
module | string | query | false | 模块名称(默认为 default) |
- 返回参数:
字段名 | 类型 | 说明 |
version | string | 版本号 |
- 请求示例:
GET /openapi/v1/things/60ff5696991b405bkmhn/version?module=mcu
- 返回示例:
{
"code": 0,
"message": "SUCCESS",
"data": {
"version": "1.2.1"
}
} # 6 规则引擎
# 6.1 新增场景
- 接口地址:
POST /openapi/v1/rule-engine/scenes
- 请求参数:
字段名 | 类型 | 位置 | 是否必填 | 说明 |
name | string | body | true | 场景名称,具有唯一性 |
desc | string | body | false | 场景描述 |
status | string | body | true | 场景状态。取值:enable(启用),disable(禁用) |
triggers | array | body | false | 触发条件 |
conditions | array | body | false | 执行条件 |
actions | array | body | false | 执行动作 |
- 触发条件字段说明:
字段名 | 类型 | 位置 | 是否必填 | 说明 |
URI | enum | body | true | 触发类型: "trigger/device/property"(设备属性), "trigger/device/event"(设备事件), "trigger/device/status"(设备状态), "trigger/cron"(定时器) |
params | struct | body | true | 详细触发参数 |
params.product_key | string | body | true | 产品身份标识,三元组之一 |
params.device_name | string | body | true | 设备身份标识,三元组之一 (注:设置为"*"时,表示产品下任意设备) |
params.property_id | string | body | false | 设备属性 id (注:设置为"*"时,表示任意属性) |
params.event_id | string | body | false | 设备事件 id (注:设置为"*"时,表示任意事件) |
params.status | enum | body | false | 设备状态: "online"(在线) "offline"(离线) "*"(任意状态) (注:触发类型为设备状态时可用) |
params.compare_type | enum | body | false | 比较类型: "=="(等于) "!="(不等于) ">"(大于) ">="(大于或等于) "<"(小于) "<="(小于或等于) "between"(闭区间) "in"(在......之中) "notIn"(不在......之中) "like"(字符串 like 匹配) |
params.compare_val | string | body | false | 比较值 |
params.cron | string | body | false | 标准 cron 表达式(支持秒) (注:触发类型为定时器时可用) |
- 执行条件字段说明:
字段名 | 类型 | 位置 | 是否必填 | 说明 |
URI | enum | body | true | 执行条件类型: "condition/device/property"(设备属性), "condition/device/status"(设备状态), "condition/time/range"(时间范围) |
params | struct | body | true | 详细触发参数 |
params.product_key | string | body | true | 产品身份标识,三元组之一 |
params.device_name | string | body | true | 设备身份标识,三元组之一; (注:设置为"*"时,表示产品下任意设备) |
params.property_id | string | body | false | 设备属性 id (注:设置为"*"时,表示任意属性) |
params.status | enum | body | false | 设备状态: "online"(在线) "offline"(离线) "*"(任意状态) (注:执行条件类型为设备状态时可用) |
params.status_duration | int | body | false | 设备状态持续时间,单位分钟; (注:执行条件类型为设备状态时可用) |
params.compare_type | string | body | false | 比较类型: "=="(等于) "!="(不等于) ">"(大于) ">="(大于或等于) "<"(小于) "<="(小于或等于) "between"(闭区间) "in"(在......之中) "notIn"(不在......之中) "like"(字符串 like 匹配) |
params.compare_val | string | body | false | 比较值 |
- 执行动作字段说明:
字段名 | 类型 | 位置 | 是否必填 | 说明 |
URI | enum | body | true | 执行动作类型: "action/device/property"(设置设备属性), "action/device/service"(调用设备服务), "action/rule"(触发其他场景) "action/webhook"(触发 webhook) |
params | struct | body | true | 详细触发参数 |
params.scene_id | string | body | false | 被触发的其他场景 id (注:当执行动作为触发其他场景时必填) |
params.device_id | string | body | false | 设备唯一标识 (注:当执行动作为设备相关时必填) |
params.service_id | string | body | false | 设备服务 id |
params.property_id | string | body | false | 设备属性 id |
params.items | object | body | false | 设备服务调用入参或设备属性设置值 |
params.URL | string | body | false | webhook 的 URL (注:当执行动作为 wehook 时必填) |
params.method | string | body | false | webhook 请求方法 (注:当执行动作为 wehook 时必填) |
params.desc | string | body | false | webhook 描述 (注:当执行动作为 wehook 时可用) |
params.connect_timeout | int | body | false | webhook 连接超时时间,单位秒 (注:当执行动作为 wehook 时可用) |
params.request_timeout | int | body | false | webhook 请求超时时间,单位秒 (注:当执行动作为 wehook 时可用) |
# 请求示例
POST /openapi/v1/rule-engine/scenes
{
"name": "rule_1",
"status": "enable",
"triggers": [
{
"URI": "trigger/device/property",
"params": {
"type": "trigger/device/property",
"product_key": "de8d0d3f",
"device_name": "00002697",
"property_id": "prop1",
"compare_type": "==",
"compare_val": "100"
}
},
{
"URI": "trigger/device/event",
"params": {
"type": "trigger/device/event",
"product_key": "de8d0d3f",
"device_name": "0000270e",
"event_id": "*"
}
},
{
"URI": "trigger/device/status",
"params": {
"type": "trigger/device/status",
"time_range": {},
"items": {},
"product_key": "de8d0d3f",
"device_name": "0000270f",
"status": "online"
}
},
{
"URI": "trigger/cron",
"params": {
"type": "trigger/cron",
"cron": "5 * * * * *"
}
}
],
"conditions": [
{
"URI": "condition/device/property",
"params": {
"type": "condition/device/property",
"product_key": "de8d0d3f",
"device_name": "0000270e",
"property_id": "prop2",
"compare_type": "<",
"compare_val": "10"
}
},
{
"URI": "condition/device/status",
"params": {
"type": "condition/device/status",
"product_key": "de8d0d3f",
"device_name": "0000270b",
"status": "online",
"status_duration": 10
}
},
{
"URI": "condition/time/range",
"params": {
"type": "condition/time/range",
"time_range": {
"start_timestamp": 1646296350,
"end_timestamp": 1647073950
}
}
}
],
"actions": [
{
"URI": "action/device/service",
"params": {
"type": "action/device/service",
"items": {
"prop2": "17"
},
"product_key": "de8d0d3f",
"device_id": "fab44c87bf7948f6M0WI",
"service_id": "prop2"
}
},
{
"URI": "action/webhook",
"params": {
"type": "action/webhook",
"URL": "https://demo.webhook.com",
"method": "POST",
"connect_timeout": 10,
"request_timeout": 10,
"desc": "for example"
}
}
]
} # 6.2 删除场景
- 接口地址:
DELETE /openapi/v1/rule-engine/scenes/{id} # 6.3 更新场景
- 接口地址:
PUT /openapi/v1/rule-engine/scenes/{id} 请求参数同新增场景
# 6.4 查询场景详情
- 接口地址:
GET /openapi/v1/rule-engine/scenes/{id} - 请求示例:
GET /openapi/v1/rule-engine/scenes/61e521e7f0988d8865d42864
- 返回示例:
{
"code": 0,
"message": "请求成功",
"data": {
"id": "61e521e7f0988d8865d42864",
"created_at": 1642406375,
"updated_at": 1646382807,
"name": "rule_1",
"status": "enable",
"triggers": [
{
"URI": "trigger/device/property",
"params": {
"product_key": "de8d0d3f",
"device_name": "00002697",
"property_id": "prop1",
"compare_type": "==",
"compare_val": "100"
}
},
{
"URI": "trigger/device/event",
"params": {
"product_key": "de8d0d3f",
"device_name": "0000270e",
"event_id": "*"
}
},
{
"URI": "trigger/device/status",
"params": {
"product_key": "de8d0d3f",
"device_name": "0000270f",
"status": "online"
}
},
{
"URI": "trigger/cron",
"params": {
"cron": "5 * * * * *",
"cron_id": "1499664307204395008"
}
}
],
"conditions": [
{
"URI": "condition/device/property",
"params": {
"product_key": "de8d0d3f",
"device_name": "0000270e",
"property_id": "prop2",
"compare_type": "==",
"compare_val": "10"
}
},
{
"URI": "condition/device/status",
"params": {
"product_key": "de8d0d3f",
"device_name": "0000270b",
"status_duration": 10,
"status": "online"
}
},
{
"URI": "condition/time/range",
"params": {
"time_range": {
"start_timestamp": 1646296350,
"end_timestamp": 1647073950
}
}
}
],
"actions": [
{
"URI": "action/device/service",
"params": {
"service_id": "prop2",
"device_id": "fab44c87bf7948f6M0WI",
"product_key": "de8d0d3f",
"items": {
"prop2": "17"
}
}
},
{
"URI": "action/webhook",
"params": {
"URL": "https://demo.webhook.com",
"method": "POST",
"desc": "for example",
"connect_timeout": 10,
"request_timeout": 10
}
}
]
}
} # 6.5 查询场景列表
- 接口地址:
GET /openapi/v1/rule-engine/scenes
# 6.6 手动执行场景动作
- 接口地址:
POST /openapi/v1/rule-engine/scenes/{id}/actions # 6.7 更新场景状态
- 接口地址:
PUT /openapi/v1/rule-engine/scenes/{id}/status # 7 对象存储服务
# 7.1 上传对象
- 接口地址:
POST /openapi/v1/oss
- 请求表单
字段名 | 类型 | 说明 |
file | binary | 文件,通过 form 表单提交 |
- 返回参数:
字段名 | 类型 | 说明 |
url | string | 文件下载 url |
md5 | string | 文件 md5 摘要 |
- 请求示例:
POST /openapi/v1/oss
- 返回示例:
{
"code": 0,
"message": "SUCCESS",
"data": {
"url": "xxx",
"md5": "xxx"
}
} 说明:返回的 url 支持请求头 GET/DELETE