获取设备的属性
接口地址:/api/yt/device/attributes/{deviceProfileId}{?dataType}
请求方式:GET
请求数据类型:application/x-www-form-urlencoded
响应数据类型:*/*
请求参数:
参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 |
deviceProfileId | deviceProfileId | path | true | string |
dataType | dataType,可用值:BOOL,DOUBLE,INT,STRUCT,TEXT | query | false | string |
请求示例:
http://${host}:${port}/api/yt/device/attributes/01944550-5ddb-11ef-b746-1f75222e5f46?dataType=INT
响应参数:
参数名称 | 参数说明 | 数据类型 |
name | 功能名称 | string |
identifier | 功能标识 | string |
accessMode | 读写模式:读r 写w | string |
detail | 功能json | JsonNode |
extensionDesc | TCP/UDP属性扩展描述 | JsonNode |
响应示例:
[
{
"identifier": "CurrentTemperature",
"extensionDesc": {
"writeOnly": false,
"bitMask": 7,
"operationType": "holdingRegister_r_03",
"originalDataType": "INT16_AB",
"registerAddress": "01",
"scaling": 10
},
"name": "温度",
"detail": {
"dataType": {
"type": "INT",
"specs": {
"valueRange": {
"min": -32768,
"max": 32767
},
"unit": "°C",
"unitName": "摄氏度 / °C"
}
}
},
"accessMode": "r"
},
{
"identifier": "CurrentHumidity",
"extensionDesc": {
"writeOnly": false,
"bitMask": 7,
"operationType": "holdingRegister_r_03",
"originalDataType": "INT16_AB",
"registerAddress": "00",
"scaling": 10
},
"name": "湿度",
"detail": {
"dataType": {
"type": "INT",
"specs": {
"unit": "%RH",
"unitName": "相对湿度 / %RH",
"valueRange": {
"min": -32768,
"max": 32767
}
},
"specsList": []
}
},
"accessMode": "r"
}
]
子设备查询
接口地址:/api/yt/device/relation?page=1&pageSize=10
请求方式:GET
请求数据类型:application/x-www-form-urlencoded
响应数据类型:*/*
请求参数:
参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 |
name | 设备名称模糊查询 | query | false | string |
deviceState | 设备状态 | query | false | string |
fromId | 主设备id | query | false | string |
orderBy | 排序字段 | query | false | string |
orderType | 排序 | query | false | string |
请求示例:
http://222.180.200.114:30427/api/yt/device/relation?page=1&pageSize=10&fromId=ffed9510-5f99-11ef-be16-5dff24403ae5
响应参数:
参数名称 | 参数说明 | 类型 |
items | array | |
alias | 别名 | string |
createdTime | 创建时间 | string(date-time) |
deviceState | 设备状态,可用值:INACTIVE,OFFLINE,ONLINE | string |
label | 标签 | string |
lastOnlineTime | 最后在线时间 | integer(int64) |
tbDeviceId | TB设备ID | string |
tbDeviceName | TB设备名称 | string |
total | integer(int32) |
响应示例:
{
"total": 1,
"items": [
{
"id": "a7d66e90-5f82-11ef-be16-5dff24403ae5",//设备id
"tbDeviceId": "a7d66e90-5f82-11ef-be16-5dff24403ae5",//tb设备id
"tbDeviceName": "iXo40906B2uY6U37",//tb设备名称
"alias": "测试子设备",//别名
"label": null,//标签
"deviceState": "INACTIVE",//设备状态
"createdTime": 1724220023801, //创建时间
"lastOnlineTime": null//最后连接时间
}
]
}
获取满足条件的所有设备
接口地址:/api/yt/device/gateway/list{?organizationId,transportType}
请求方式:GET
请求数据类型:application/x-www-form-urlencoded
响应数据类型:*/*
请求参数:
参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 |
organizationId | 组织ID | query | false | string |
transportType | 传输类型,可用值:COAP,DEFAULT,LWM2M,MQTT,SNMP,TCP | query | false | string |
请求示例:
http://222.180.200.114:30427/api/yt/device/gateway/list?organizationId=f85dab7d-69e3-424d-89d3-8ed5f45ab396&transportType=DEFAULT
响应示例:
{
"total": 1,
"items": [
{
"id": "fb665df0-5e96-11ef-81b9-2ff152897d7a",
"name": "9G9ssfLm5U1ZX2r9",
"enabled": false,
"tenantId": "01482120-5ddb-11ef-b746-1f75222e5f46",
"deviceInfo": {
"longitude": "",
"latitude": "",
"address": ""
},
"alias": "测试设备",
"deviceState": "INACTIVE",
"profileId": "01944550-5ddb-11ef-b746-1f75222e5f46",
"deviceProfileId": "01944550-5ddb-11ef-b746-1f75222e5f46",
"tbDeviceId": "fb665df0-5e96-11ef-81b9-2ff152897d7a",
"brand": "DIY_",
"sn": "9G9ssfLm5U1ZX2r9",
"organizationId": "f85dab7d-69e3-424d-89d3-8ed5f45ab396",
"customerId": "72f7a060-5df0-11ef-b746-1f75222e5f46",
"customerName": "Public",
"deviceProfile": {
"id": "01944550-5ddb-11ef-b746-1f75222e5f46",
"name": "默认MQTT直连设备",
"description": "Default device profile",
"tenantId": "01482120-5ddb-11ef-b746-1f75222e5f46",
"transportType": "DEFAULT",
"provisionType": "DISABLED",
"deviceType": "DIRECT_CONNECTION",
"tbProfileId": "01944550-5ddb-11ef-b746-1f75222e5f46",
"profileData": {
"configuration": {
"type": "DEFAULT"
},
"transportConfiguration": {
"type": "DEFAULT"
},
"provisionConfiguration": {
"type": "DISABLED",
"provisionDeviceSecret": null
},
"alarms": null,
"thingsModel": [
{
"functionType": "properties",
"functionName": "测试结构体",
"identifier": "jgt",
"callType": null,
"accessMode": "rw",
"eventType": null,
"functionJson": {
"dataType": {
"type": "STRUCT",
"specs": [
{
"remark": "备注",
"dataType": {
"type": "INT",
"specs": {
"step": 1,
"unit": "°C",
"unitName": "摄氏度 / °C",
"valueRange": {
"max": 10,
"min": 0
}
}
},
"identifier": "nb",
"functionName": "结构体内部"
}
]
}
},
"extensionDesc": null,
"status": 1,
"deviceProfileId": "01944550-5ddb-11ef-b746-1f75222e5f46",
"remark": null
},
{
"functionType": "properties",
"functionName": "温度",
"identifier": "CurrentTemperature",
"callType": null,
"accessMode": "r",
"eventType": null,
"functionJson": {
"dataType": {
"type": "INT",
"specs": {
"unit": "°C",
"unitName": "摄氏度 / °C",
"valueRange": {
"max": 32767,
"min": -32768
}
}
}
},
"extensionDesc": {
"bitMask": 7,
"scaling": 10,
"writeOnly": false,
"operationType": "holdingRegister_r_03",
"registerAddress": "01",
"originalDataType": "INT16_AB"
},
"status": 1,
"deviceProfileId": "01944550-5ddb-11ef-b746-1f75222e5f46",
"remark": null
},
{
"functionType": "properties",
"functionName": "测试",
"identifier": "test",
"callType": null,
"accessMode": "rw",
"eventType": null,
"functionJson": {
"dataType": {
"type": "INT",
"specs": {
"step": 1,
"unit": "m㎡",
"unitName": "平方毫米 / m㎡",
"valueRange": {
"max": 10,
"min": 0
}
}
}
},
"extensionDesc": null,
"status": 1,
"deviceProfileId": "01944550-5ddb-11ef-b746-1f75222e5f46",
"remark": null
},
{
"functionType": "properties",
"functionName": "湿度",
"identifier": "CurrentHumidity",
"callType": null,
"accessMode": "r",
"eventType": null,
"functionJson": {
"dataType": {
"type": "INT",
"specs": {
"unit": "%RH",
"unitName": "相对湿度 / %RH",
"valueRange": {
"max": 32767,
"min": -32768
}
},
"specsList": []
}
},
"extensionDesc": {
"bitMask": 7,
"scaling": 10,
"writeOnly": false,
"operationType": "holdingRegister_r_03",
"registerAddress": "00",
"originalDataType": "INT16_AB"
},
"status": 1,
"deviceProfileId": "01944550-5ddb-11ef-b746-1f75222e5f46",
"remark": null
}
]
},
"type": "DEFAULT",
"categoryName": "默认MQTT直连设备",
"default": false
},
"organizationDTO": {
"id": "f85dab7d-69e3-424d-89d3-8ed5f45ab396",
"creator": "80808080-8080-8080-8080-808080808080",
"createTime": "2024-08-19 11:28:18",
"updateTime": "2024-08-19 14:04:05",
"name": "默认",
"enabled": false,
"tenantId": "01482120-5ddb-11ef-b746-1f75222e5f46",
"sort": 0,
"children": []
},
"deviceType": "DIRECT_CONNECTION",
"alarmStatus": 0,
"enable": false,
"transportType": "DEFAULT",
"customerAdditionalInfo": {
"isPublic": true
},
"isCollect": 0,
"profileName": "默认MQTT直连设备",
"organizationName": "默认",
"isEdge": 0
}
]
}
获取网关设备
接口地址:/api/yt/device/gateway/{tbDeviceId}
请求方式:GET
请求数据类型:application/x-www-form-urlencoded
响应数据类型:*/*
请求参数:
参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 |
tbDeviceId | tb设备Id | path | true | string |
请求示例:
http://222.180.200.114:30427/api/yt/device/gateway/08bbc360-5f9a-11ef-be16-5dff24403ae5
响应参数:
参数名称 | 参数说明 | 类型 |
id | 主键id | String |
name | 设备名称 | String |
tenantId | 租户id | String |
deviceInfo | 设备信息 | JsonNode |
alias | 别名 | String |
profileId | TB设备配置ID | String |
deviceProfileId | 平台设备配置ID | String |
tbDeviceId | TB设备ID | String |
brand | 设备厂商 | String |
sn | 设备SN | String |
organizationId | 设备组织id | String |
deviceType | 设备类型:GATEWAY,DIRECT_CONNECTION,SENSOR | DeviceTypeEnum |
alarmStatus | 告警状态:0正常,1告警 | alarmStatus |
enable | 启用/禁用 | boolean |
响应示例:
{
"id": "ffed9510-5f99-11ef-be16-5dff24403ae5",
"name": "8HYGXPUqNOzf4G39",
"enabled": false,
"tenantId": "01482120-5ddb-11ef-b746-1f75222e5f46",
"deviceInfo": {
"longitude": "",
"latitude": "",
"address": ""
},
"alias": "测试网关",
"profileId": "01883760-5ddb-11ef-b746-1f75222e5f46",
"deviceProfileId": "01883760-5ddb-11ef-b746-1f75222e5f46",
"tbDeviceId": "ffed9510-5f99-11ef-be16-5dff24403ae5",
"brand": "DIY_",
"sn": "8HYGXPUqNOzf4G39",
"organizationId": "f85dab7d-69e3-424d-89d3-8ed5f45ab396",
"deviceType": "GATEWAY",
"alarmStatus": 0,
"enable": false
}
获取网关子设备信息
接口地址:/api/yt/device/get_subset/{tbDeviceId}
请求方式:GET
请求数据类型:application/x-www-form-urlencoded
响应数据类型:*/*
请求参数:
参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 |
tbDeviceId | tb设备Id | path | true | string |
请求示例:
http://222.180.200.114:30427/api/yt/device/get_subset/ffed9510-5f99-11ef-be16-5dff24403ae5
响应参数:
参数名称 | 参数说明 | 类型 |
id | 主键id | String |
name | 设备名称 | String |
tenantId | 租户id | String |
deviceInfo | 设备信息 | JsonNode |
alias | 别名 | String |
profileId | TB设备配置ID | String |
deviceProfileId | 平台设备配置ID | String |
tbDeviceId | TB设备ID | String |
brand | 设备厂商 | String |
sn | 设备SN | String |
organizationId | 设备组织id | String |
deviceType | 设备类型:GATEWAY,DIRECT_CONNECTION,SENSOR | DeviceTypeEnum |
alarmStatus | 告警状态:0正常,1告警 | alarmStatus |
enable | 启用/禁用 | boolean |
响应示例:
{
"id": "08bbc360-5f9a-11ef-be16-5dff24403ae5",
"name": "k00s2jk2r4EN4Zx5",
"enabled": false,
"tenantId": "01482120-5ddb-11ef-b746-1f75222e5f46",
"deviceInfo": {
"longitude": "",
"latitude": "",
"address": ""
},
"alias": "测试网关子",
"deviceProfileId": "0167de20-5ddb-11ef-b746-1f75222e5f46",
"gatewayId": "ffed9510-5f99-11ef-be16-5dff24403ae5",
"tbDeviceId": "08bbc360-5f9a-11ef-be16-5dff24403ae5",
"brand": "DIY_",
"sn": "k00s2jk2r4EN4Zx5",
"organizationId": "f85dab7d-69e3-424d-89d3-8ed5f45ab396",
"customerId": "13814000-1dd2-11b2-8080-808080808080",
"deviceType": "SENSOR",
"alarmStatus": 0,
"enable": false
}
客户列表(获取publicId)
接口地址: /api/customers?pageSize=10&page=0&sortProperty=createdTime&sortOrder=DESC
请求方式:GET
请求数据类型:application/x-www-form-urlencoded
响应数据类型:*/*
请求参数:
参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 |
textSearch | 模糊搜索字段 | query | false | string |
sortProperty | 排序规则:名称(titile)、创建时间、(createdTime)、客户(customerTitle)、设备配置(deviceProfileName)、标签(label)、状态(active) | query | false | string |
sortOrder | 排序(ASC,DESC) | query | false | Integer |
请求示例:
http://222.180.200.114:30427/api/customers?pageSize=10&page=0&sortProperty=createdTime&sortOrder=DESC
响应示例:
{
"data": [
{
"id": {//客户id
"entityType": "CUSTOMER",
"id": "72f7a060-5df0-11ef-b746-1f75222e5f46"
},
"createdTime": 1724047277414,
"country": null,//国家
"state": null,//状态
"city": null,//城市
"address": null,//住址
"address2": null,//住址
"zip": null,
"phone": null,//电话
"email": null,//邮箱
"title": "Public",//客户标题
"tenantId": {//租户id
"entityType": "TENANT",
"id": "01482120-5ddb-11ef-b746-1f75222e5f46"
},
"externalId": null,//外部id
"name": "Public"
}
],
"totalPages": 1,
"totalElements": 1,
"hasNext": false
}
客户获取设备列表(通过publicId获取)
接口地址:/api/customer/{publicId}/deviceInfos?pageSize=10&page=0&sortProperty=createdTime&sortOrder=DESC
请求方式:GET
请求数据类型::application/x-www-form-urlencoded
响应数据类型:*/*
请求参数:
参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 |
type | 产品名称 | query | false | string |
textSearch | 模糊搜索字段 | query | false | string |
sortProperty | 排序规则:名称(name)、创建时间、(createdTime)、客户(customerTitle)、设备配置(deviceProfileName)、标签(label)、状态(active) | query | false | string |
sortOrder | 排序(ASC,DESC) | query | false | Integer |
请求示例:
http://222.180.200.114:30427/api/customer/72f7a060-5df0-11ef-b746-1f75222e5f46/deviceInfos?pageSize=10&page=0&sortProperty=createdTime&sortOrder=DESC
响应示例:
{
"data": [
{
"alarmStatus": 0,//告警状态
"alias": "string",//设备别名
"brand": "string",//设备厂商
"code": "string",//设备标识符
"codeType": "CUSTOM",//产品协议
"creator": "3fa85f64-5717-4562-b3fc-2c963f66afa6",//创建人id
"description": "string",//设备描述
"deviceInfo": {},//用于存放设备附属信息 设备图片,经纬度等
"deviceState": "ACTIVE",//设备状态
"deviceType": "DIRECT_CONNECTION",//设备类型 DeviceTypeEnum枚举值
"gatewayId": {//设备挂靠网关设备主键id
"id": "784f394c-42b6-435a-983c-b7beff2784f9",
"entityType": "DEVICE"
},
"organizationId": "string",//组织id
"sn": "string",//设备编号(设备名称)
"transportType": "string",//协议类型
"updateTime": 0,//修改时间
"updater": "3fa85f64-5717-4562-b3fc-2c963f66afa6",//修改人id
"id": {//设备id
"id": "784f394c-42b6-435a-983c-b7beff2784f9",
"entityType": "DEVICE"
},
"createdTime": 1609459200000,//创建时间
"tenantId": {//租户id
"id": "784f394c-42b6-435a-983c-b7beff2784f9",
"entityType": "TENANT"
},
"customerId": {//客户id
"id": "784f394c-42b6-435a-983c-b7beff2784f9",
"entityType": "CUSTOMER"
},
"name": "A4B72CCDFF33",//设备编号(设备名称)
"type": "Temperature Sensor",//产品名称
"label": "Room 234 Sensor",//标签
"deviceProfileId": {//产品id
"id": "784f394c-42b6-435a-983c-b7beff2784f9",
"entityType": "DEVICE_PROFILE"
},
"firmwareId": {//OTA升级固件id
"id": "784f394c-42b6-435a-983c-b7beff2784f9",
"entityType": "OTA_PACKAGE"
},
"softwareId": {//OTA升级软件id
"id": "784f394c-42b6-435a-983c-b7beff2784f9",
"entityType": "OTA_PACKAGE"
},
"additionalInfo": {}//存放TB附加信息
}
]
}
平台用户获取设备列表
接口地址:/api/yt/device?page=1&pageSize=10
请求方式:POST
请求数据类型:application/json
响应数据类型:*/*
请求参数:
参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 |
organizationId | 组织ID | query | false | string |
name | 设备名称 | query | false | string |
deviceProfileId | 设备配置ID | query | false | string |
alarmStatus | 告警状态:0 否 1是 | query | false | Integer |
deviceState | 设备状态:在线(ONLINE)、待激活(INACTIVE)、离线(OFFLINE) | query | false | enum |
deviceType | 设备类型:网关(GATEWAY)、直连设备(DIRECT_CONNECTION)、网关子设备(SENSOR) | query | false | enum |
isCollect | 是否收藏:0否 1是 | query | false | Integer |
请求示例:
响应参数:
参数名称 | 参数说明 | 类型 |
id | 主键id | string |
name | 设备名称 | |
deviceInfo | 设备信息 | JsonNode |
alias | 别名 | String |
activeTime | 激活时间 | LocalDateTime |
deviceState | 设备状态 | DeviceState |
profileId | TB设备配置ID | String |
deviceProfileId | 平台设备配置ID | String |
gatewayId | 关联网关设备 | String |
gatewayName | 网关名称 | String |
gatewayAlias | 网关别名 | String |
deviceToken | 设备凭证 | TkCredentialsDto |
tbDeviceId | TB设备ID | String |
brand | 设备厂商 | String |
sn | 设备SN | String |
code | 设备标识符,例如:地址码 | String |
codeType | 标识符/地址码类型:产品协议为TCP/UDP使用,MODBUS/CUSTOM | CodeTypeEnum |
organizationId | 设备组织id | String |
label | 设备标签 | String |
customerId | 分配客户id | String |
customerName | 客户名称 | String |
deviceProfile | 设备配置/产品信息 | DeviceProfileDTO |
organizationDTO | 组织信息 | OrganizationDTO |
deviceType | 设备类型:GATEWAY,DIRECT_CONNECTION,SENSOR | DeviceTypeEnum |
alarmStatus | 告警状态:0正常,1告警 | alarmStatus |
lastOnlineTime | 最后在线时间 | Long |
lastOfflineTime | 最后离线时间 | Long |
description | 描述 | String |
enable | 启用/禁用 | boolean |
transportType | 协议类型 | String |
isCollect | 是否收藏:0否1是 | Integer |
firmwareId | OTA升级固件ID | String |
softwareId | OTA升级软件ID | String |
profileName | 产品名称 | String |
organizationName | 组织名称 | String |
isEdge | 是否来自边端 | Integer |
响应示例:
{
"total": 1,
"items": [
{
"id": "fb665df0-5e96-11ef-81b9-2ff152897d7a",
"name": "9G9ssfLm5U1ZX2r9",
"enabled": false,
"tenantId": "01482120-5ddb-11ef-b746-1f75222e5f46",
"deviceInfo": {
"longitude": "",
"latitude": "",
"address": ""
},
"alias": "测试设备",
"deviceState": "INACTIVE",
"profileId": "01944550-5ddb-11ef-b746-1f75222e5f46",
"deviceProfileId": "01944550-5ddb-11ef-b746-1f75222e5f46",
"tbDeviceId": "fb665df0-5e96-11ef-81b9-2ff152897d7a",
"brand": "DIY_",
"sn": "9G9ssfLm5U1ZX2r9",
"organizationId": "f85dab7d-69e3-424d-89d3-8ed5f45ab396",
"customerId": "72f7a060-5df0-11ef-b746-1f75222e5f46",
"customerName": "Public",
"deviceProfile": {
"id": "01944550-5ddb-11ef-b746-1f75222e5f46",
"name": "默认MQTT直连设备",
"description": "Default device profile",
"tenantId": "01482120-5ddb-11ef-b746-1f75222e5f46",
"transportType": "DEFAULT",
"provisionType": "DISABLED",
"deviceType": "DIRECT_CONNECTION",
"tbProfileId": "01944550-5ddb-11ef-b746-1f75222e5f46",
"profileData": {
"configuration": {
"type": "DEFAULT"
},
"transportConfiguration": {
"type": "DEFAULT"
},
"provisionConfiguration": {
"type": "DISABLED",
"provisionDeviceSecret": null
},
"alarms": null,
"thingsModel": [
{
"functionType": "properties",
"functionName": "测试结构体",
"identifier": "jgt",
"callType": null,
"accessMode": "rw",
"eventType": null,
"functionJson": {
"dataType": {
"type": "STRUCT",
"specs": [
{
"remark": "备注",
"dataType": {
"type": "INT",
"specs": {
"step": 1,
"unit": "°C",
"unitName": "摄氏度 / °C",
"valueRange": {
"max": 10,
"min": 0
}
}
},
"identifier": "nb",
"functionName": "结构体内部"
}
]
}
},
"extensionDesc": null,
"status": 1,
"deviceProfileId": "01944550-5ddb-11ef-b746-1f75222e5f46",
"remark": null
},
{
"functionType": "properties",
"functionName": "温度",
"identifier": "CurrentTemperature",
"callType": null,
"accessMode": "r",
"eventType": null,
"functionJson": {
"dataType": {
"type": "INT",
"specs": {
"unit": "°C",
"unitName": "摄氏度 / °C",
"valueRange": {
"max": 32767,
"min": -32768
}
}
}
},
"extensionDesc": {
"bitMask": 7,
"scaling": 10,
"writeOnly": false,
"operationType": "holdingRegister_r_03",
"registerAddress": "01",
"originalDataType": "INT16_AB"
},
"status": 1,
"deviceProfileId": "01944550-5ddb-11ef-b746-1f75222e5f46",
"remark": null
},
{
"functionType": "properties",
"functionName": "测试",
"identifier": "test",
"callType": null,
"accessMode": "rw",
"eventType": null,
"functionJson": {
"dataType": {
"type": "INT",
"specs": {
"step": 1,
"unit": "m㎡",
"unitName": "平方毫米 / m㎡",
"valueRange": {
"max": 10,
"min": 0
}
}
}
},
"extensionDesc": null,
"status": 1,
"deviceProfileId": "01944550-5ddb-11ef-b746-1f75222e5f46",
"remark": null
},
{
"functionType": "properties",
"functionName": "湿度",
"identifier": "CurrentHumidity",
"callType": null,
"accessMode": "r",
"eventType": null,
"functionJson": {
"dataType": {
"type": "INT",
"specs": {
"unit": "%RH",
"unitName": "相对湿度 / %RH",
"valueRange": {
"max": 32767,
"min": -32768
}
},
"specsList": []
}
},
"extensionDesc": {
"bitMask": 7,
"scaling": 10,
"writeOnly": false,
"operationType": "holdingRegister_r_03",
"registerAddress": "00",
"originalDataType": "INT16_AB"
},
"status": 1,
"deviceProfileId": "01944550-5ddb-11ef-b746-1f75222e5f46",
"remark": null
}
]
},
"type": "DEFAULT",
"categoryName": "默认MQTT直连设备",
"default": false
},
"organizationDTO": {
"id": "f85dab7d-69e3-424d-89d3-8ed5f45ab396",
"creator": "80808080-8080-8080-8080-808080808080",
"createTime": "2024-08-19 11:28:18",
"updateTime": "2024-08-19 14:04:05",
"name": "默认",
"enabled": false,
"tenantId": "01482120-5ddb-11ef-b746-1f75222e5f46",
"sort": 0,
"children": []
},
"deviceType": "DIRECT_CONNECTION",
"alarmStatus": 0,
"enable": false,
"transportType": "DEFAULT",
"customerAdditionalInfo": {
"isPublic": true
},
"isCollect": 0,
"profileName": "默认MQTT直连设备",
"organizationName": "默认",
"isEdge": 0
}
]
}
获取设备最新值
接口地址:/api/plugins/telemetry/{entityType}/{entityId}/values/timeseries
请求方式:GET
请求数据类型:application/x-www-form-urlencoded
响应数据类型:*/*
请求参数:
参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 |
entityType | 实体类型:默认使用DEVICE | path | ture | string |
entityId | 设备ID:使用设备列表分页返回的tbDeviceId | path | ture | string |
keys | 设备标识符:多个标识符使用”,”分割。例如:temperature,humidity | query | false | string |
useStrictDataTypes | 启用/禁用遥测值到字符串的转换。默认情况下启用转换。将参数设置为“true”以禁用转换。 | query | false | boolean |
注意:keys的获取,需要调用产品接口 获取物模型TSL 获取
请求示例:
http://222.180.200.114:30427/api/plugins/telemetry/DEVICE/fb665df0-5e96-11ef-81b9-2ff152897d7a/values/timeseries?keys=CurrentTemperature,CurrentHumidity
响应参数:
参数名称 | 参数说明 | 数据类型 |
CurrentTemperature | 请求的温度标识符 | json |
CurrentHumidity | 请求的湿度标识符 | json |
响应示例:
{
//对应标识符的最新数据的时间跟值
"CurrentTemperature": [
{
"ts": 1703841242459,
"value": "37.3"
}
],
"CurrentHumidity": [
{
"ts": 1703841242459,
"value": "63.3"
}
]
}
获取设备历史值
接口地址:/api/plugins/telemetry/{entityType}/{entityId}/values/timeseries{?agg,endTs,interval,keys,orderBy,startTs,useStrictDataTypes}”
请求方式:GET
请求数据类型:application/x-www-form-urlencoded
响应数据类型:*/*
请求参数:
参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 |
entityType | 实体类型:默认使用DEVICE | path | ture | string |
entityId | 设备ID:使用设备列表分页返回的tbDeviceId | path | ture | string |
keys | 设备标识符 | query | false | string |
开始时间与结束时间由前端选择方式传输: 例如: 1.查询方式=最后,最后数据=1天 startTs传当前时间的时间戳,endTS传startTs+1天的时间戳 2.查询方式=时间段,则传入选择的时间段 | ||||
startTs | 开始时间(时间戳) | query | false | Long |
endTs | 结束时间(时间戳) | query | false | Long |
聚合功能(agg)与分组间隔(interval):例如:1.最后数据=1天、数据聚合功能=最小值、分组间隔=10分 此时查询的数据展示为:从当前时间起一天内,每间隔10分钟统计一次,取每10分钟数据中的最小值进行展示2.最后数据=1天、数据聚合功能=平均值、分组间隔=1小时此时查询的数据展示为:从当前时间起一天内,每间隔1小时统计一次,取每1小时数据之和的平均值进行展示 | ||||
agg | 聚合功能 | query | false | String |
interval | 分组间隔 | query | false | int |
orderBy | 数据排序 | query | false | String |
useStrictDataTypes | 启用/禁用遥测值到字符串的转换。默认情况下启用转换。将参数设置为“true”以禁用转换。 | query | false | boolean |
注意:keys的获取,需要调用产品接口 获取物模型TSL 获取
请求示例:
http://222.180.200.114:30427/api/plugins/telemetry/DEVICE/fb665df0-5e96-11ef-81b9-2ff152897d7a/values/timeseries?keys=CurrentTemperature&startTs=1724145819652&endTs=1724232219652&agg=NONE&limit=7&orderBy=ASC
响应参数:
参数名称 | 参数说明 | 数据类型 |
CurrentTemperature | 请求的温度标识符 | array |
ts | 数据时间 | long |
value | 值 | string |
响应示例:
{
"CurrentTemperature": [
{
"ts": 1724232322609,
"value": "13"
},
{
"ts": 1724232320167,
"value": "12"
},
{
"ts": 1724232317116,
"value": "11"
},
{
"ts": 1724232294423,
"value": "55"
},
{
"ts": 1724232292435,
"value": "60"
},
{
"ts": 1724223371631,
"value": "50"
}
]
}
获取设备最新/历史值(websocket)
接口地址:/api/ws/plugins/telemetry
请求方式:POST
请求数据类型:application/json
响应数据类型:*/*
请求示例:
//获取设备最新/历史值时 websocket订阅是同一接口
//获取最新值
"tsSubCmds": [//主题
{
"entityType": "DEVICE",//数据类型
"entityId": "42985640-5881-11ef-8de7-2ff152897d7a",//设备id
"scope": "LATEST_TELEMETRY",//固定值
"cmdId": 0,//订阅id 后续回调使用
//需要订阅的属性
"keys": "text,image,longitude,height,ArmSwing,speed,humidity,color,temperature,latitude"
}
]
//获取历史值
"historyCmds": [//主题
{
"entityType": "DEVICE",//数据类型
"entityId": "42985640-5881-11ef-8de7-2ff152897d7a",,//设备id
"cmdId": 0,//订阅id 后续回调使用
//需要订阅的属性
"keys": "text,image,longitude,height,ArmSwing,speed,humidity,color,temperature,latitude",
"limit": 0,
"agg": "MIN",//聚合功能
"interval": 2000,//interval
"startTs": 112,//开始时间
"endTs": 123//结束时间
}
]
详情(通平台用户token获取)
接口地址:/api/yt/device/{id}
请求方式:GET
请求数据类型:application/x-www-form-urlencoded
响应数据类型:*/*
请求参数:
参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 |
id | id | path | true | string |
请求示例:
http://222.180.200.114:30427/api/yt/device/ffed9510-5f99-11ef-be16-5dff24403ae5
响应参数:
参数名称 | 参数说明 | 类型 |
id | 主键id | string |
name | 设备名称 | |
deviceInfo | 设备信息 | JsonNode |
alias | 别名 | String |
activeTime | 激活时间 | LocalDateTime |
deviceState | 设备状态 | DeviceState |
profileId | TB设备配置ID | String |
deviceProfileId | 平台设备配置ID | String |
gatewayId | 关联网关设备 | String |
gatewayName | 网关名称 | String |
gatewayAlias | 网关别名 | String |
deviceToken | 设备凭证 | TkCredentialsDto |
tbDeviceId | TB设备ID | String |
brand | 设备厂商 | String |
sn | 设备SN | String |
code | 设备标识符,例如:地址码 | String |
codeType | 标识符/地址码类型:产品协议为TCP/UDP使用,MODBUS/CUSTOM | CodeTypeEnum |
organizationId | 设备组织id | String |
label | 设备标签 | String |
customerId | 分配客户id | String |
customerName | 客户名称 | String |
deviceProfile | 设备配置/产品信息 | DeviceProfileDTO |
organizationDTO | 组织信息 | OrganizationDTO |
deviceType | 设备类型:GATEWAY,DIRECT_CONNECTION,SENSOR | DeviceTypeEnum |
alarmStatus | 告警状态:0正常,1告警 | alarmStatus |
lastOnlineTime | 最后在线时间 | Long |
lastOfflineTime | 最后离线时间 | Long |
description | 描述 | String |
enable | 启用/禁用 | boolean |
transportType | 协议类型 | String |
isCollect | 是否收藏:0否1是 | Integer |
firmwareId | OTA升级固件ID | String |
softwareId | OTA升级软件ID | String |
profileName | 产品名称 | String |
organizationName | 组织名称 | String |
isEdge | 是否来自边端 | Integer |
响应示例:
{
"id": "fb665df0-5e96-11ef-81b9-2ff152897d7a",
"createTime": "2024-08-20 09:53:22",
"name": "9G9ssfLm5U1ZX2r9",
"enabled": false,
"tenantId": "01482120-5ddb-11ef-b746-1f75222e5f46",
"deviceInfo": {
"longitude": "",
"latitude": "",
"address": ""
},
"alias": "测试设备",
"deviceState": "INACTIVE",
"profileId": "01944550-5ddb-11ef-b746-1f75222e5f46",
"deviceProfileId": "01944550-5ddb-11ef-b746-1f75222e5f46",
"tbDeviceId": "fb665df0-5e96-11ef-81b9-2ff152897d7a",
"brand": "DIY_",
"sn": "9G9ssfLm5U1ZX2r9",
"organizationId": "f85dab7d-69e3-424d-89d3-8ed5f45ab396",
"deviceProfile": {
"id": "01944550-5ddb-11ef-b746-1f75222e5f46",
"name": "默认MQTT直连设备",
"description": "Default device profile",
"tenantId": "01482120-5ddb-11ef-b746-1f75222e5f46",
"transportType": "DEFAULT",
"provisionType": "DISABLED",
"deviceType": "DIRECT_CONNECTION",
"tbProfileId": "01944550-5ddb-11ef-b746-1f75222e5f46",
"profileData": {
"configuration": {
"type": "DEFAULT"
},
"transportConfiguration": {
"type": "DEFAULT"
},
"provisionConfiguration": {
"type": "DISABLED",
"provisionDeviceSecret": null
},
"alarms": null,
"thingsModel": [
{
"functionType": "properties",
"functionName": "测试结构体",
"identifier": "jgt",
"callType": null,
"accessMode": "rw",
"eventType": null,
"functionJson": {
"dataType": {
"type": "STRUCT",
"specs": [
{
"remark": "备注",
"dataType": {
"type": "INT",
"specs": {
"step": 1,
"unit": "°C",
"unitName": "摄氏度 / °C",
"valueRange": {
"max": 10,
"min": 0
}
}
},
"identifier": "nb",
"functionName": "结构体内部"
}
]
}
},
"extensionDesc": null,
"status": 1,
"deviceProfileId": "01944550-5ddb-11ef-b746-1f75222e5f46",
"remark": null
},
{
"functionType": "properties",
"functionName": "温度",
"identifier": "CurrentTemperature",
"callType": null,
"accessMode": "r",
"eventType": null,
"functionJson": {
"dataType": {
"type": "INT",
"specs": {
"unit": "°C",
"unitName": "摄氏度 / °C",
"valueRange": {
"max": 32767,
"min": -32768
}
}
}
},
"extensionDesc": {
"bitMask": 7,
"scaling": 10,
"writeOnly": false,
"operationType": "holdingRegister_r_03",
"registerAddress": "01",
"originalDataType": "INT16_AB"
},
"status": 1,
"deviceProfileId": "01944550-5ddb-11ef-b746-1f75222e5f46",
"remark": null
},
{
"functionType": "properties",
"functionName": "测试",
"identifier": "test",
"callType": null,
"accessMode": "rw",
"eventType": null,
"functionJson": {
"dataType": {
"type": "INT",
"specs": {
"step": 1,
"unit": "m㎡",
"unitName": "平方毫米 / m㎡",
"valueRange": {
"max": 10,
"min": 0
}
}
}
},
"extensionDesc": null,
"status": 1,
"deviceProfileId": "01944550-5ddb-11ef-b746-1f75222e5f46",
"remark": null
},
{
"functionType": "properties",
"functionName": "湿度",
"identifier": "CurrentHumidity",
"callType": null,
"accessMode": "r",
"eventType": null,
"functionJson": {
"dataType": {
"type": "INT",
"specs": {
"unit": "%RH",
"unitName": "相对湿度 / %RH",
"valueRange": {
"max": 32767,
"min": -32768
}
},
"specsList": []
}
},
"extensionDesc": {
"bitMask": 7,
"scaling": 10,
"writeOnly": false,
"operationType": "holdingRegister_r_03",
"registerAddress": "00",
"originalDataType": "INT16_AB"
},
"status": 1,
"deviceProfileId": "01944550-5ddb-11ef-b746-1f75222e5f46",
"remark": null
}
]
},
"type": "DEFAULT",
"categoryName": "默认MQTT直连设备",
"default": false
},
"organizationDTO": {
"id": "f85dab7d-69e3-424d-89d3-8ed5f45ab396",
"creator": "80808080-8080-8080-8080-808080808080",
"createTime": "2024-08-19 11:28:18",
"updateTime": "2024-08-19 14:04:05",
"name": "默认",
"enabled": false,
"tenantId": "01482120-5ddb-11ef-b746-1f75222e5f46",
"sort": 0,
"children": []
},
"deviceType": "DIRECT_CONNECTION",
"alarmStatus": 0,
"enable": false,
"transportType": "DEFAULT",
"isCollect": 0,
"profileName": "默认MQTT直连设备",
"organizationName": "默认"
}
详情(通过客户(publicId)Token获取)
注:客户想要获取设备详情,此设备必须分配给该客户或者设为公开
接口地址:/api/yt/device/public/{id}
请求方式:GET
请求数据类型:application/x-www-form-urlencoded
响应数据类型:*/*
请求参数:
参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 |
id | id | path | true | string |
请求示例:
http://222.180.200.114:30427/api/yt/device/ffed9510-5f99-11ef-be16-5dff24403ae5
响应参数:与平台用户token一致
命令下发
接口地址:1.单向下发 :/api/yt/device/public/{deviceId}
2.双向下发: /api/yt/device/public/{deviceId}
请求方式:POST
请求数据类型:application/x-www-form-urlencoded
响应数据类型:*/*
请求参数:
参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 |
additionalInfo | body | true | json | |
additionalInfo.cmdType | 命令类型 0自定义1服务 | true | json | |
method | 方法:methodThingskit | json | ||
params | 命令 | json | ||
persistent | 是否持久化 :true,false | json |
请求示例:
{
"additionalInfo": {
"cmdType": 0
},
"method": "methodThingskit",
"persistent": true,
"params": {
"test": "32.1"
}
}
响应示例:
{
"rpcId": "ff035be7-6570-4abe-ab71-b1309fa8af18"
}