设备数据API
查询设备列表
请求方式: POST
URL: http(s)://localhost:8844/api/v1/device/_query
http body 请求参数:
公共查询参数:请参考公共查询参数
根据设备实例(DeviceInstanceEntity)条件查询,字段名和值分别对应查询参数Term中的column和value。
设备实例(DeviceInstanceEntity)参数如下:
| 名称 | 类型 | 是否必选 | 示例值 | 描述 | | —- | —- | —- | —- | —- |
| id | String | 否 | test001 | 设备实例ID |
| name | String | 否 | 温控设备001 | 设备实例名称 |
| describe | String | 否 | | 说明 |
| productId | String | 否 | 1236859833832701952 | 型号ID |
| productName | String | 否 | 智能温控 | 型号名称 |
|
configuration
| Map
| deriveMetadata | String | 否 | | 派生元数据,有的设备的属性,功能,事件可能会动态的添加 |
| state | DeviceState | 否 | online | 状态 |
| creatorId | String | 否 | 1199596756811550720 | 创建人ID |
| creatorName | String | 否 | 管理员 | 创建人名称 |
| createTime | Long | 否 | 1584586676863 | 创建时间 |
| registryTime | Long | 否 | online | 激活时间 |
| orgId | String | 否 | department | 机构ID |
| parentId | String | 否 | | 父级设备ID |
返回参数:
| 名称 | 类型 | 描述 | | —- | —- | —- |
|
result
| PagerResult
| status | int | 状态码 |
| code | String | 业务编码 |
PagerResult
| 名称 | 类型 | 描述 | | —- | —- | —- |
| pageIndex | int | 页码 |
| pageSize | int | 每页数量 |
| total | int | 返回数据总数 |
|
data
| List
DeviceInfo参数如下:
| 名称 | 类型 | 描述 | | —- | —- | —- |
| id | String | 设备ID |
| name | String | 设备名称 |
| productId | String | 型号ID |
| productName | String | 型号名称 |
| state | DeviceState | 设备状态 |
| registerTime | long | 注册时间 |
| createTime | long | 创建时间 |
| parentId | String | 父级设备ID |
请求示例:
//请求
POST /api/v1/device/_query
Content-Type: application/json
X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ
{
"pageSize": 25,
"pageIndex": 0,
"terms": [{
"column": "productId",
"value": "1236859833832701952"
}]
}
//响应
HTTP/1.1 200 OK
X-Timestamp: 1574994269075
X-Sign: c23fa********f25
{
"result": {
"pageIndex": 0,
"pageSize": 1000,
"total": 3,
"data": [{
"id": "test0312",
"name": "设备0312",
"productId": "1236859833832701952",
"productName": "智能温控",
"state": {
"text": "未激活",
"value": "notActive"
},
"registerTime": 0,
"createTime": 1583997946670
}, {
"id": "test001",
"name": "温控设备0309",
"productId": "1236859833832701952",
"productName": "智能温控",
"state": {
"text": "离线",
"value": "offline"
},
"registerTime": 1583805253659,
"createTime": 1585809343175
}, {
"id": "MQTT_FX_Client",
"name": "mqttfx",
"productId": "1236859833832701952",
"productName": "智能温控",
"state": {
"text": "离线",
"value": "offline"
},
"registerTime": 1584330967254,
"createTime": 1584330960918
}]
},
"status": 200,
"code": "success"
}
::: tip 说明:
X-Sign为签名,body
+X-Timestamp
+SecuryeKey
MD5加密
X-Timestamp为时间戳
X-Client-Id为平台openApi客户端id
:::
获取设备详情
请求方式: GET
URL: http(s)://localhost:8844/api/v1/device/{deviceId}/_detail
说明:{deviceId}需要替换为设备实例的id。
返回参数:
| 名称 | 类型 | 描述 | | —- | —- | —- |
| result | DeviceDetail | 返回值 |
| status | int | 状态码 |
| code | String | 业务编码 |
DeviceDetail参数如下:
| 名称 | 类型 | 描述 | | —- | —- | —- |
| id | String | 设备ID |
| name | String | 设备名称 |
| protocol | String | 消息协议标识 |
| transport | String | 通信协议 |
| orgId | String | 所属机构ID |
| orgName | String | 所属机构名称 |
| productId | String | 型号ID |
| productName | String | 型号名称 |
| deviceType | DeviceType | 设备类型 |
| state | DeviceState | 设备状态 |
| address | String | 客户端地址 |
| onlineTime | long | 上线时间 |
| offlineTime | long | 离线时间 |
| registerTime | long | 注册时间 |
| createTime | long | 创建时间 |
| metadata | String | 设备元数据(在设备型号功能定义中定义) |
|
configuration
| Map
|
tags
| List
标签(DeviceTagEntity)参数说明:
| 名称 | 类型 | 描述 | | —- | —- | —- |
| deviceId | String | 设备ID |
| key | String | 键 |
| name | String | 标签名 |
| value | String | 值 |
| type | String | 标签类型 |
| createTime | Date | 创建时间 |
| description | String | 描述 |
请求示例:
//请求
GET /api/v1/device/1236859833832701952/_detail
X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ
//响应
HTTP/1.1 200 OK
X-Timestamp: 1574994269075
X-Sign: c23fa********f25
{
"result": {
"id": "test001",
"name": "温控设备0309",
"protocol": "demo-v1",
"transport": "MQTT",
"productId": "1236859833832701952",
"productName": "智能温控",
"deviceType": {
"text": "网关设备",
"value": "gateway"
},
"state": {
"text": "离线",
"value": "offline"
},
"address": "/127.0.0.1:46360",
"onlineTime": 1586422112901,
"offlineTime": 1586424932209,
"createTime": 1585809343175,
"registerTime": 1583805253659,
"metadata": "{\"events\":[{\"id\":\"fire_alarm\",\"name\":\"火警报警\",\"expands\":{\"eventType\":\"reportData\",\"level\":\"urgent\"},\"valueType\":{\"type\":\"object\",\"properties\":[{\"id\":\"a_name\",\"name\":\"区域名称\",\"valueType\":{\"type\":\"string\"}},{\"id\":\"b_name\",\"name\":\"建筑名称\",\"valueType\":{\"type\":\"string\"}},{\"id\":\"l_name\",\"name\":\"位置名称\",\"valueType\":{\"type\":\"string\"}}]}}],\"properties\":[{\"id\":\"temperature\",\"name\":\"温度\",\"valueType\":{\"type\":\"float\",\"min\":\"0\",\"max\":\"100\",\"step\":\"0.1\",\"unit\":\"celsiusDegrees\"},\"expands\":{\"readOnly\":\"true\"}}],\"functions\":[{\"id\":\"get-log\",\"name\":\"获取日志\",\"isAsync\":true,\"output\":{\"type\":\"string\",\"expands\":{\"maxLength\":\"2048\"}},\"inputs\":[{\"id\":\"start_date\",\"name\":\"开始日期\",\"valueType\":{\"type\":\"date\",\"dateFormat\":\"yyyy-MM-dd HH:mm:ss\"}},{\"id\":\"end_data\",\"name\":\"结束日期\",\"valueType\":{\"type\":\"date\",\"dateFormat\":\"yyyy-MM-dd HH:mm:ss\"}},{\"id\":\"time\",\"name\":\"分组\",\"valueType\":{\"type\":\"string\"}}]}]}",//在设备型号功能定义中定义
"configuration": {
"username": "test",
"password": "test"
},
"tags": []
},
"status": 200,
"code": "success"
}
查询设备详情列表
请求方式: POST
URL: http(s)://localhost:8844/api/v1/device/_detail/_query
http body 请求参数:
公共查询参数:请参考公共查询参数
请求示例:
//请求
POST /api/v1/device/_detail/_query
Content-Type: application/json
X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ
{
"pageSize": 25,
"pageIndex": 0,
"terms": [{
"column": "productId",
"value": "1236859833832701952"
}]
}
//响应
HTTP/1.1 200 OK
X-Timestamp: 1574994269075
X-Sign: c23fa********f25
{
"result": {
"pageIndex": 0,
"pageSize": 1000,
"total": 3,
"data": [
{
"id": "test001",
"name": "温控设备0309",
"protocol": "demo-v1",
"transport": "MQTT",
"productId": "1236859833832701952",
"productName": "智能温控",
"deviceType": {
"text": "网关设备",
"value": "gateway"
},
"state": {
"text": "离线",
"value": "offline"
},
"address": "/127.0.0.1:46360",
"onlineTime": 1586422112901,
"offlineTime": 1586424932209,
"createTime": 1585809343175,
"registerTime": 1583805253659,
"metadata": "{\"events\":[{\"id\":\"fire_alarm\",\"name\":\"火警报警\",\"expands\":{\"eventType\":\"reportData\",\"level\":\"urgent\"},\"valueType\":{\"type\":\"object\",\"properties\":[{\"id\":\"a_name\",\"name\":\"区域名称\",\"valueType\":{\"type\":\"string\"}},{\"id\":\"b_name\",\"name\":\"建筑名称\",\"valueType\":{\"type\":\"string\"}},{\"id\":\"l_name\",\"name\":\"位置名称\",\"valueType\":{\"type\":\"string\"}}]}}],\"properties\":[{\"id\":\"temperature\",\"name\":\"温度\",\"valueType\":{\"type\":\"float\",\"min\":\"0\",\"max\":\"100\",\"step\":\"0.1\",\"unit\":\"celsiusDegrees\"},\"expands\":{\"readOnly\":\"true\"}}],\"functions\":[{\"id\":\"get-log\",\"name\":\"获取日志\",\"isAsync\":true,\"output\":{\"type\":\"string\",\"expands\":{\"maxLength\":\"2048\"}},\"inputs\":[{\"id\":\"start_date\",\"name\":\"开始日期\",\"valueType\":{\"type\":\"date\",\"dateFormat\":\"yyyy-MM-dd HH:mm:ss\"}},{\"id\":\"end_data\",\"name\":\"结束日期\",\"valueType\":{\"type\":\"date\",\"dateFormat\":\"yyyy-MM-dd HH:mm:ss\"}},{\"id\":\"time\",\"name\":\"分组\",\"valueType\":{\"type\":\"string\"}}]}]}",//在设备型号功能定义中定义
"configuration": {
"username": "test",
"password": "test"
},
"tags": []
}
]
},
"status": 200,
"code": "success"
}
批量保存设备
请求方式: POST
URL: http(s)://localhost:8844/api/v1/device
http body 请求参数为DeviceSaveDetail集合:
DeviceSaveDetail 参数如下:
| 名称 | 类型 | 是否必选 | 示例值 | 描述 | | —- | —- | —- | —- | —- |
| id | String | 是 | test002 | 设备实例ID |
| name | String | 是 | 温控设备002 | 设备实例名称 |
| productId | String | 是 | 1236859833832701952 | 型号ID |
| productName | String | 是 | 智能温控 | 型号名称 |
|
configuration
| Map
| creatorId | String | 否 | 1199596756811550720 | 创建人ID |
| creatorName | String | 否 | 管理员 | 创建人名称 |
|
tags
| List
标签(DeviceTagEntity)参数说明:
| 名称 | 类型 | 描述 | | —- | —- | —- |
| deviceId | String | 设备ID |
| key | String | 键 |
| name | String | 标签名 |
| value | String | 值 |
| type | String | 标签类型 |
| createTime | Date | 创建时间 |
| description | String | 描述 |
返回参数:
| 名称 | 类型 | 描述 | | —- | —- | —- |
| result | int | 保存数量 |
| status | int | 状态码 |
| code | String | 业务编码 |
示例:
// 请求
POST /api/v1/device
X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ
Content-Type: application/json
[
{
"id": "test002",
"name": "设备002",
"productId": "1236859833832701952",
"configuration": {
"username": "test002",
"password": "test002"
},
"tags": [{
"deviceId": "test002",
"key": "area",
"name": "地区",
"value": "chongqing"
}]
},
{
"id": "test003",
"name": "设备名称",
"productId": "1236859833832701952",
"configuration": {}
}
]
// 响应
HTTP/1.1 200 OK
X-Timestamp: 1574994269075
X-Sign: c23fa********f25
{"result":3,"status":200,"code":"success"}
批量同步设备状态
请求方式: POST
URL: http://localhost:8844/api/v1/device/state/_sync
请求参数格式为动态查询参数
::: tip 提示
此操作将同步设备真实状态,如果一次同步数量较大,推荐使用websocket方式同步,可实时获取同步结果.
:::
请求示例:
//请求
POST /api/v1/device/state/_sync
Content-Type: application/json
X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ
{
"pageSize":10
}
//响应
HTTP/1.1 200 OK
X-Timestamp: 1574994269075
X-Sign: c23fa********f25
{
"status":200,
"result":[
{
"deviceId":"设备ID",
"state":{"value":"offline","text":"离线"}
}
]
}
批量激活设备
请求方式: POST
URL: http(s)://localhost:8844/api/v1/device/_deploy
http body 请求参数为设备id集合,List
返回参数:
| 名称 | 类型 | 描述 | | —- | —- | —- |
| result | int | 激活数量 |
| status | int | 状态码 |
| code | String | 业务编码 |
请求示例:
//请求
POST /api/v1/device/_deploy
Content-Type: application/json
X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ
["test002","test003", "test004"]
//响应
HTTP/1.1 200 OK
X-Timestamp: 1574994269075
X-Sign: c23fa********f25
{"result":3,"status":200,"code":"success"}
批量注销设备
请求方式: POST
URL: http(s)://localhost:8844/api/v1/device/_unDeploy
http body 请求参数为设备id集合,List
返回参数:
| 名称 | 类型 | 描述 | | —- | —- | —- |
| result | int | 注销成功数量 |
| status | int | 状态码 |
| code | String | 业务编码 |
请求示例:
//请求
POST /api/v1/device/_unDeploy
Content-Type: application/json
X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ
["test002","test003", "test004"]
//响应
HTTP/1.1 200 OK
X-Timestamp: 1574994269075
X-Sign: c23fa********f25
{"result":3,"status":200,"code":"success"}
批量删除设备
请求方式: POST
URL: http(s)://localhost:8844/api/v1/device/_delete
http body 请求参数为设备id集合,List
返回参数:
| 名称 | 类型 | 描述 | | —- | —- | —- |
| result | int | 注销成功数量 |
| status | int | 状态码 |
| code | String | 业务编码 |
请求示例:
//请求
POST /api/v1/device/_delete
Content-Type: application/json
X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ
["test002","test003", "test004"]
//响应
HTTP/1.1 200 OK
X-Timestamp: 1574994269075
X-Sign: c23fa********f25
{"result":3,"status":200,"code":"success"}
根据设备ID查询设备日志
请求方式: POST
URL: http(s)://localhost:8844/api/v1/device/{deviceId}/log/_query
说明:{deviceId}需要替换为设备实例的id。
http body 请求参数:
公共查询参数:请参考公共查询参数
根据设备操作日志(DeviceOperationLogEntity)条件查询,字段名和值分别对应查询参数Term中的column和value。
设备操作日志(DeviceOperationLogEntity)参数如下:
| 名称 | 类型 | 是否必选 | 示例值 | 描述 | | —- | —- | —- | —- | —- |
| id | String | 否 | LoymU3EBCTcV5s5DbSn7 | 设备实例ID |
| productId | String | 否 | 1236859833832701952 | 型号ID |
| type | DeviceLogType | 否 | readProperty | 类型 |
| createTime | Long | 否 | 1584586676863 | 创建时间 |
| orgId | String | 否 | department | 机构ID |
返回参数:
| 名称 | 类型 | 描述 | | —- | —- | —- |
|
result
| PagerResult
| status | int | 状态码 |
| code | String | 业务编码 |
PagerResult
| 名称 | 类型 | 描述 | | —- | —- | —- |
| pageIndex | int | 页码 |
| pageSize | int | 每页数量 |
| total | int | 返回数据总数 |
|
data
| List
DeviceInfo参数如下:
| 名称 | 类型 | 描述 | | —- | —- | —- |
| id | String | 设备ID |
| name | String | 设备名称 |
| productId | String | 型号ID |
| productName | String | 型号名称 |
| state | DeviceLogType | 设备状态 |
| registerTime | long | 注册时间 |
| createTime | long | 创建时间 |
| parentId | String | 父级设备ID |
请求示例:
//请求
POST /api/v1/device/test001/log/_query
Content-Type: application/json
X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ
{
"pageSize": 25,
"pageIndex": 0,
"terms": [{
"column": "createTime$btw",
"value": "2020-01-01,2020-06-01"
}]
}
//响应
HTTP/1.1 200 OK
X-Timestamp: 1574994269075
X-Sign: c23fa********f25
{
"result": {
"pageIndex": 0,
"pageSize": 25,
"total": 4,
"data": [{
"id": "fa1528090a464e3f0bf3839ce0c1315",
"deviceId": "test001",
"productId": "1236859833832701952",
"type": {
"text": "上线",
"value": "online"
},
"createTime": 1586422112000,
"content": "设备上线"
}, {
"id": "eb7d05c8dda18bc37434bf7f98799ba7",
"deviceId": "test001",
"productId": "1236859833832701952",
"type": {
"text": "离线",
"value": "offline"
},
"createTime": 1586419084000,
"content": "设备离线"
}, {
"id": "34a89eb7b89646bd98fc5ab6617b370e",
"deviceId": "test001",
"productId": "1236859833832701952",
"type": {
"text": "上线",
"value": "online"
},
"createTime": 1586413536000,
"content": "设备上线"
}, {
"id": "2f1aaa63865afb3cdcec4aa72771ab9",
"deviceId": "test001",
"productId": "1236859833832701952",
"type": {
"text": "读取属性回复",
"value": "readPropertyReply"
},
"createTime": 1583809148000,
"content": "{\"temperature\":\"50\"}"
}]
},
"status": 200,
"code": "success"
}
查询设备属性
请求方式: POST
URL: http(s)://localhost:8844/api/v1/device/{deviceId}/properties/_query
说明:{deviceId}需要替换为设备实例的id。
http body 请求参数:
公共查询参数:请参考公共查询参数
根据设备属性(DevicePropertiesEntity)条件查询,字段名和值分别对应查询参数Term中的column和value。
设备属性(DevicePropertiesEntity)参数如下:
| 名称 | 类型 | 是否必选 | 示例值 | 描述 | | —- | —- | —- | —- | —- |
| id | String | 否 | | 属性ID |
| productId | String | 否 | 1236859833832701952 | 型号ID |
| property | String | 否 | temperature | 属性标识 |
| propertyName | String | 否 | 温度 | 属性名称 |
| stringValue | String | 否 | | 字符串值 |
| formatValue | String | 否 | | 格式化值 |
| numberValue | String | 否 | | 数字值 |
| geoValue | GeoPoint | 否 | | 坐标值 |
| timestamp | long | 否 | | 时间戳 |
| objectValue | String | 否 | | 结构体值 |
| value | String | 否 | | 值 |
| timeValue | Date | 否 | | 时间值 |
| orgId | String | 否 | | 机构ID |
GeoPoint参数如下:
| 名称 | 类型 | 是否必选 | 示例值 | 描述 | | —- | —- | —- | —- | —- |
| lat | double | 否 | 106.57 | 经度 |
| lon | double | 否 | 29.52 | 纬度 |
返回参数:
| 名称 | 类型 | 描述 | | —- | —- | —- |
|
result
| PagerResult
| status | int | 状态码 |
| code | String | 业务编码 |
PagerResult
| 名称 | 类型 | 描述 | | —- | —- | —- |
| pageIndex | int | 页码 |
| pageSize | int | 每页数量 |
| total | int | 返回数据总数 |
|
data
| List
DeviceInfo参数如下:
| 名称 | 类型 | 描述 | | —- | —- | —- |
| id | String | 属性ID |
| productId | String | 型号ID |
| property | String | 属性标识 |
| propertyName | String | 属性名称 |
| stringValue | String | 字符串值 |
| formatValue | String | 格式化值 |
| numberValue | String | 数字值 |
| geoValue | GeoPoint | 坐标值 |
| timestamp | long | 否 时间戳 |
| objectValue | String | 结构体值 |
| value | String | 值 |
| timeValue | Date | 时间值 |
| orgId | String | 机构ID |
请求示例:
//请求
POST /api/v1/device/test001/properties/_query
Content-Type: application/json
X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ
{
"pageSize": 25,
"pageIndex": 0,
"terms": [{
"column": "property",
"value": "temperature"
}]
}
//响应
HTTP/1.1 200 OK
X-Timestamp: 1574994269075
X-Sign: c23fa********f25
{
"result": {
"pageIndex": 0,
"pageSize": 25,
"total": 3,
"data": [{
"id": "amugXXEBQZKUd4flBbDN",
"deviceId": "test001",
"property": "temperature",
"propertyName": "温度",
"formatValue": "50.00℃",
"numberValue": 50.0,
"timestamp": 1583809148000,
"value": "50",
"productId": "1236859833832701952"
}]
},
"status": 200,
"code": "success"
}
获取设备最新的全部属性
请求方式: GET
URL: http(s)://localhost:8844/api/v1/device/{deviceId}/properties/_latest
说明:{deviceId}需要替换为设备实例的id。
返回参数:
| 名称 | 类型 | 描述 | | —- | —- | —- |
| result | DevicePropertiesEntity | 返回值 |
| status | int | 状态码 |
| code | String | 业务编码 |
DevicePropertiesEntity参数如下:
| 名称 | 类型 | 描述 | | —- | —- | —- |
| id | String | 否 |
| productId | String | 否 |
| property | String | 否 |
| propertyName | String | 否 |
| stringValue | String | 否 |
| formatValue | String | 否 |
| numberValue | String | 否 |
| geoValue | GeoPoint | 否 |
| timestamp | long | 否 |
| objectValue | String | 否 |
| value | String | 否 |
| timeValue | Date | 否 |
| orgId | String | 否 |
| deviceId | String | 否 |
| type | String | 否 |
请求示例:
//请求
POST /api/v1/device/test001/properties/_latest
Content-Type: application/json
X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ
//响应
HTTP/1.1 200 OK
X-Timestamp: 1574994269075
X-Sign: c23fa********f25
{
"result": [{
"id": "amugXXEBQZKUd4flBbDN",
"deviceId": "test001",
"property": "temperature",
"propertyName": "温度",
"formatValue": "50.00℃",
"numberValue": 50.0,
"timestamp": 1583809148000,
"value": "50",
"productId": "1236859833832701952"
}],
"status": 200,
"code": "success"
}
聚合查询设备属性
请求方式: GET
URL: http(s)://localhost:8844/api/v1/device/{deviceId}/agg/{agg}/{property}/_query
说明:{deviceId}需要替换为设备实例的id,
{agg}需要替换为聚合类型,包含:MIN, MAX, AVG, SUM, COUNT, NONE
{property}需要替换为设备属性。
返回参数:
| 名称 | 类型 | 描述 | | —- | —- | —- |
| result | List
| status | int | 状态码 |
| code | String | 业务编码 |
请求示例:
查询过去30分钟设备test001的温度属性每分钟的平均温度。
//请求
POST /api/v1/device/test001/agg/AVG/temperature/_query
Content-Type: application/json
X-Sign: f4823a*********e76eb1d
X-Timestamp: 1598579554299
X-Client-Id: kF**********HRZ
{
"interval": "1h",//时间间隔,单位为英文时间单位首字母,如小时h、天d等
"format": "yyyy-MM-dd HH:mm:ss",//时间格式
"from": "now-24h",//起始时间
"to": "now",//终止时间
"query": {
"pageSize": 25//指定返回数据条数,默认25
}
}
//响应
HTTP/1.1 200 OK
X-Timestamp: 1574994269075
X-Sign: c23fa********f25
{
"result": [{
"temperature": 32.8235294117647,
"time": "2020-08-28 09:52:00"
}, {
"temperature": 32.13333333333333,
"time": "2020-08-28 09:51:00"
}, {
"temperature": 34.11666666666667,
"time": "2020-08-28 09:50:00"
}, {
"temperature": 33.9,
"time": "2020-08-28 09:49:00"
}, {
"temperature": 33.85,
"time": "2020-08-28 09:48:00"
}, {
"temperature": 34.45,
"time": "2020-08-28 09:47:00"
}, {
"temperature": 32.75,
"time": "2020-08-28 09:46:00"
}, {
"temperature": 35.6,
"time": "2020-08-28 09:45:00"
}, {
"temperature": 35.06666666666667,
"time": "2020-08-28 09:44:00"
}, {
"temperature": 34.15,
"time": "2020-08-28 09:43:00"
}, {
"temperature": 37.629629629629626,
"time": "2020-08-28 09:42:00"
}, {
"temperature": 33.8,
"time": "2020-08-28 09:41:00"
}, {
"temperature": 33.42857142857143,
"time": "2020-08-28 09:40:00"
}, {
"temperature": 0.0,
"time": "2020-08-28 09:39:00"
}, {
"temperature": 0.0,
"time": "2020-08-28 09:38:00"
}, {
"temperature": 0.0,
"time": "2020-08-28 09:37:00"
}, {
"temperature": 0.0,
"time": "2020-08-28 09:36:00"
}, {
"temperature": 0.0,
"time": "2020-08-28 09:35:00"
}, {
"temperature": 0.0,
"time": "2020-08-28 09:34:00"
}, {
"temperature": 0.0,
"time": "2020-08-28 09:33:00"
}, {
"temperature": 0.0,
"time": "2020-08-28 09:32:00"
}, {
"temperature": 0.0,
"time": "2020-08-28 09:31:00"
}, {
"temperature": 0.0,
"time": "2020-08-28 09:30:00"
}, {
"temperature": 0.0,
"time": "2020-08-28 09:29:00"
}, {
"temperature": 0.0,
"time": "2020-08-28 09:28:00"
}],
"code": "success",
"status": 200
}
查询设备事件
请求方式: POST
URL: http(s)://localhost:8844/api/v1/device/{deviceId}/event/{eventId}/_query
说明:{deviceId}需要替换为设备实例的id,{eventId}需替换为设备型号中事件标识。
http body 请求参数:
公共查询参数:请参考公共查询参数
::: tip 注意
此处的参数中Term为设备型号功能定义中的事件内容
:::
返回参数:
| 名称 | 类型 | 描述 | | —- | —- | —- |
| result | PagerResult
| status | int | 状态码 |
| code | String | 业务编码 |
PagerResult
| 名称 | 类型 | 描述 | | —- | —- | —- |
| pageIndex | int | 页码 |
| pageSize | int | 每页数量 |
| total | int | 返回数据总数 |
| data | List
请求示例:
//请求
POST /api/v1/device/test001/event/fire_alarm/_query
Content-Type: application/json
X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ
{
"pageSize": 25,
"pageIndex": 0,
"terms": [{
"column": "a_name",//型号事件定义中的结构体的属性
"value": "南岸区"
}]
}
//响应
HTTP/1.1 200 OK
X-Timestamp: 1574994269075
X-Sign: c23fa********f25
{
"result": {
"pageIndex": 0,
"pageSize": 25,
"total": 1,
"data": [{
"b_name": "C2 栋",
"productId": "1236859833832701952",
"pname": "智能温控",
"event_count": 1,
"l_name": "12-05-201",
"alarm_describe": "火灾报警",
"deviceId": "test001",
"event_id": 1,
"alarm_type": 1,
"createTime": 1586701932647,
"id": "Pn_ObnEBbNs2V4rRJb4F",
"aid": 105,
"a_name": "南岸区",
"timestamp": 1586701932647
}]
},
"status": 200,
"code": "success"
}
设备操作API
获取设备属性
此操作将发送指令ReadPropertyMessage
到设备.并获取设备返回数据ReadPropertyMessageReply
.
请求方式: GET
URL: `http(s)://localhost:8844/api/v1/device/{deviceId}/property/{propertyId}
说明:{deviceId}需要替换为设备实例的id,{propertyId}需要替换成属性标识。
返回参数:
| 名称 | 类型 | 描述 | | —- | —- | —- |
|
result
| Map
| status | int | 状态码 |
| code | String | 业务编码 |
请求示例:
//请求
GET /api/v1/device/test001/property/temperature
Content-Type: application/json
X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ
//响应
HTTP/1.1 200 OK
X-Timestamp: 1574994269075
X-Sign: c23fa********f25
{
"result": {
"temperature": "50"
},
"status": 200,
"code": "success"
}
设置设备属性
此操作将发送指令WritePropertyMessage
到设备.并获取设备返回数据WritePropertyMessageReply
.
请求方式: POST
URL: http(s)://localhost:8844/api/v1/device/{deviceId}/properties
说明:{deviceId}需要替换为设备实例的id。
http body 请求参数:
此处的参数为设备型号功能定义中的属性,如:
{"temperature": 50.0}//temperature为属性标识
返回参数:
| 名称 | 类型 | 描述 | | —- | —- | —- |
|
result
| Map
| status | int | 状态码 |
| code | String | 业务编码 |
请求示例:
//请求
POST /api/v1/device/test001/property/temperature
Content-Type: application/json
X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ
{"temperature": 50.0}
//响应
HTTP/1.1 200 OK
X-Timestamp: 1574994269075
X-Sign: c23fa********f25
{
"result": {
"temperature": "50"
},
"status": 200,
"code": "success"
}
设备功能调用
此操作将发送指令FunctionInvokeMessage
到设备,并等待返回FunctionInvokeMessageReply
.
请求方式: POST
URL: http(s)://localhost:8844/api/v1/device/{deviceId}/function/{functionId}
说明:{deviceId}需要替换为设备实例的id,{functionId}需要替换为设备型号中功能定义的功能标识。
请求示例:
//请求
POST /api/v1/device/test001/function/play_voice
Content-Type: application/json
X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ
{
"text": "你好" //与物模型中定义到参数一致
}
//响应
HTTP/1.1 200 OK
X-Timestamp: 1574994269075
X-Sign: c23fa********f25
{
"result": ['ok'], //注意是集合.因为可能返回多条结果
"status": 200,
"code": "success"
}
地理信息管理
根据geojson保存数据
请求方式: POST
URL: http(s)://localhost:8844/api/v1/geo/object/geo.json
http body 请求参数:
GeoJson(参考GeoJSON) 参数如下:
| 名称 | 类型 | 是否必选 | 示例值 | 描述 | | —- | —- | —- | —- | —- |
| type | String | 是 | FeatureCollection | 类型,固定为FeatureCollection |
|
features
| List
GeoJsonFeature 参数如下:
| 名称 | 类型 | 是否必选 | 示例值 | 描述 | | —- | —- | —- | —- | —- |
| type | String | 是 | Feature | 类型,固定为Feature |
|
properties
| Map
| geometry | GeoShape | 否 | | 图形 |
properties 参数如下:
| 名称 | 类型 | 是否必选 | 示例值 | 描述 | | —- | —- | —- | —- | —- |
| objectId | String | 是 | chongqing | |
| id | String | 是 | chongqing | |
| objectType | String | 是 | city | |
GeoShape 参数如下:
| 名称 | 类型 | 是否必选 | 示例值 | 描述 | | —- | —- | —- | —- | —- |
| type | Type | 是 | Polygon | 类型 |
| coordinates | List