@soszrg
2019-05-09T03:32:54.000000Z
字数 5439
阅读 447
anxin
http://121.40.214.215:8001
Authorization: token 1:d79be1d657d9a8b45f6f903620e84b06cbf225e0
登出接口(token)
接口地址
GET /api/v1/projects/devices/
请求示例
GET /api/v1/projects/devices/?page=1&page_size=10&project_id=10&product_type=0{}
请求参数说明
| 参数 | 类型 | 必须 | 说明 |
|---|---|---|---|
| page | int | N | 页码 |
| page_size | int | N | 每页条目数 |
| project_id | int | Y | 项目id |
| product_type | int | Y | 产品类别 |
返回参数
{"meta":{"message":"info list","code":0},"data":{"count":5,"page_size":10,"next":null,"previous":null,"results":[{"id":22,"device_id":"a88d813af3291...","iot_secret":"","product":{"product_id":"c374be3301...","name":"test3"},"parent":{"device_id":"3e527594f328...","dsn":"zrgtest18112805"},"house":null,"dsn":"zrgtest18112809","house_id":null,"project_id":10,"alias":null,"wifi_ver":"","mcu_ver":"","online_times":0,"extra":{"a":1,"b":2},"status":true,"is_online":false,"is_active":false,"is_virtual":false,"created_at":"2018-11-29T00:21:28","updated_at":"2018-11-29T00:21:28"},{"id":21,"device_id":"63613c98f...","iot_secret":"","product":{"product_id":"c374be33010cd...","name":"test3"},"parent":{"device_id":"3e527594f3281...","dsn":"zrgtest18112805"},"house":null,"dsn":"zrgtest18112808","house_id":null,"project_id":10,"alias":null,"wifi_ver":"","mcu_ver":"","online_times":0,"extra":{"a":1,"b":2},"status":true,"is_online":false,"is_active":false,"is_virtual":false,"created_at":"2018-11-29T00:19:32","updated_at":"2018-11-29T00:19:32"}]}}
返回参数说明
| 参数 | 类型 | 说明 |
|---|---|---|
| id | int | 设备db id |
| device_id | string | 设备id |
| product.product_id | string | 产品id |
| product.name | string | 产品名 |
| parent.device_id | string | 父级设备id |
| parent.dsn | string | 父级设备mac/编号等 |
| house | json object | 所属房间信息(待定) |
| dsn | string | 设备mac/编号(等) |
| project_id | int | 项目id |
| alias | string | 设备别名 |
| wifi_ver | string | wifi固件版本 |
| mcu_ver | string | wifi固件版本 |
| online_times | int | 设备上线c |
| extra | json object | 拓展信息(冗余表信息存于此) |
| updated_at | string | 更新时间 |
| created_at | string | 创建时间 |
错误码
| code | 说明 |
|---|---|
| 10000 | 参数错误:具体信息参加Response的message字段 |
接口地址
POST /api/v1/projects/devices/
请求示例
POST /api/v1/projects/devices/{"project_id":42,"dsn":"00191108","product_id":"7355a1cefdb8dd8f88c2520cb4b2d0","parent_id": 2,"alias":"真实中继器1","extra":{"chanel_nums":120}}
请求参数说明
| 参数 | 类型 | 必须 | 说明 |
|---|---|---|---|
| product_id | string | Y | 产品id |
| parent_id | string | N | 父级设备id(使用db id) |
| house_id | int | N | 所属房间id(预留) |
| dsn | string | N | 中继器或采集器表号 |
| project_id | N | int | 项目id |
| alias | string | N | 设备别名 |
| extra | json object | N | 拓展信息(冗余表信息存于此) |
返回参数
{"meta":{"code":0,"message":"create ok"},"data":{"id":23,"device_id":"81fef4baf37...","product":{"product_id":"c374be33010...","name":"test3"},"parent":null,"house":null,"dsn":"zrgtest18112910","iot_secret":"","project_id":10,"alias":"","wifi_ver":"","mcu_ver":"","online_times":0,"extra":{"chanel_nums":1,"diam":"10","init_flow":"10.00"},"is_online":false,"is_virtual":false,"created_at":"2018-11-29T10:28:50","updated_at":"2018-11-29T10:28:50"}}
返回参数说明
| 参数 | 类型 | 说明 |
|---|---|---|
| id | int | 设备db id |
| device_id | string | 设备id |
| product.product_id | string | 产品id |
| product.name | string | 产品名 |
| parent.device_id | string | 父级设备id |
| parent.dsn | string | 父级设备mac/编号等 |
| house | json object | 所属房间信息(待定) |
| dsn | string | 设备mac/编号(等) |
| project_id | int | 项目id |
| alias | string | 设备别名 |
| extra | json object | 拓展信息(冗余表信息存于此) |
| updated_at | string | 更新时间 |
| created_at | string | 创建时间 |
错误码
| code | 说明 |
|---|---|
| 10000 | 参数错误:具体信息参加Response的message字段 |
| 10300 | 产品不存在 |
| 10301 | 设备不存在 |
| 10050 | 创建iot设备异常 |
接口地址
GET /api/v1/projects/devices/[device_id]/info/
请求示例
GET /api/v1/projects/devices/81fef4baf37e.../info/?project_id=10{}
请求参数说明
| 参数 | 类型 | 必须 | 说明 |
|---|---|---|---|
| device_id | string | Y | 设备id |
| project_id | int | Y | 项目id |
返回参数
{"meta":{"code":0,"message":"create ok"},"data":{"id":23,"device_id":"81fef4baf37...","product":{"product_id":"c374be33010...","name":"test3"},"parent":null,"house":null,"dsn":"zrgtest18112910","iot_secret":"","project_id":10,"alias":"","wifi_ver":"","mcu_ver":"","online_times":0,"extra":{"chanel_nums":1,"diam":"10","init_flow":"10.00"},"is_online":false,"is_virtual":false,"created_at":"2018-11-29T10:28:50","updated_at":"2018-11-29T10:28:50"}}
返回参数说明
略
接口地址
PUT /api/v1/projects/devices/[device_id]/info/
请求示例
PUT /api/v1/projects/devices/81fef4baf37e11e8.../info/{"project_id": 4,"house_id": 101,"parent_id": 22,"is_master": true,"extra":{"chanel_nums":1, # 信道总数"diam": "10", # 口径尺寸"init_flow": "10.00", # 初始流量/电量},}
请求参数说明
| 参数 | 类型 | 必须 | 说明 | 位置 |
|---|---|---|---|---|
| device_id | string | Y | 设备id | path |
| project_id | int | Y | 项目id | body |
| is_master | bool | N | 是否为主表 | body |
| house_id | int | N | 房间id | body |
| parent_id | int | N | 父级设备id | body |
| dsn | string | N | 表号 | body |
| extra | json对象 | N | 附加信息 | body |
返回参数
略
接口地址
DELETE /api/v1/projects/devices/[device_id]/info/
请求示例
DELETE /api/v1/projects/devices/81fef4baf37e11e8.../info/{}
请求参数说明
无
返回参数
{"meta":{"code":0,"message":"delete device[81fef4baf37e11e...:zrgtest18112910] ok"},"data":{}}
返回参数说明
无
接口地址
POST /api/v1/projects/devices/subs/
请求示例
POST /api/v1/projects/devices/subs/{"parent": "ahhxfaa...","houses": [12, 15, 16]}
请求参数说明
| 参数 | 类型 | 必须 | 说明 |
|---|---|---|---|
| parent | string | Y | 父设备id |
| houses | int array | Y | 要关联设备的房间id |
返回参数
{"meta":{"code":0,"message":"add sub devices ok"},"data":{}}
返回参数说明
无
错误码
| code | 说明 |
|---|---|
| 10000 | 参数错误:具体信息参加Response的message字段 |
| 10251 | 房间不存在 |
| 10303 | 父设备不存在 |
接口地址
GET /api/v1/projects/devices/subs/
请求示例
GET /api/v1/projects/devices/subs/?page_size=10&page=1&device_id=aaxx...&query_type=0&house_parent={}
请求参数说明
| 参数 | 类型 | 必须 | 说明 |
|---|---|---|---|
| device_id | string | Y | 采集器的设备id |
| query_type | int | Y | 查询类型 |
查询类型说明:
| 值 | 说明 |
|---|---|
| 0 | 查询未关联到该采集器的房间 |
| 其他 | 根据设备类型id(如水表品类id,电表品类id等)查询设备 |
返回参数
{"meta": {"message": "info list","code": 0},"data": {"count": 2,"page_size": 10,"next": null,"previous": null,"results": [{"id": 31,"address": ["发发发","1","1","2","201"]},{"id": 28,"address": ["发发发","1","1","1","tag"]}]}}
返回参数说明
无
错误码
略
接口地址
GET /api/v1/projects/devices/route/
请求示例
GET /api/v1/projects/devices/route/?collector_id=aaxx...{}
请求参数说明
| 参数 | 类型 | 必须 | 说明 |
|---|---|---|---|
| collector_id | string | Y | 采集器的设备id |
返回参数
{"meta": {"code": 0,"message": "route info"},"data": ["zrgtest1812104/00000000"]}
返回参数说明
无
错误码
略