ThingsKit物联网平台API文档-设备管理(设备)

获取设备的属性

接口地址:/api/yt/device/attributes/{deviceProfileId}{?dataType}

请求方式:GET

请求数据类型:application/x-www-form-urlencoded

响应数据类型:*/*

请求参数:

参数名称参数说明请求类型是否必须数据类型
deviceProfileIddeviceProfileIdpathtruestring
dataTypedataType,可用值:BOOL,DOUBLE,INT,STRUCT,TEXTqueryfalsestring

请求示例:

http://${host}:${port}/api/yt/device/attributes/01944550-5ddb-11ef-b746-1f75222e5f46?dataType=INT

响应参数:

参数名称参数说明数据类型
name功能名称string
identifier功能标识string
accessMode读写模式:读r 写wstring
detail功能jsonJsonNode
extensionDescTCP/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设备名称模糊查询queryfalsestring
deviceState设备状态queryfalsestring
fromId主设备idqueryfalsestring
orderBy排序字段queryfalsestring
orderType排序queryfalsestring

请求示例:

http://222.180.200.114:30427/api/yt/device/relation?page=1&pageSize=10&fromId=ffed9510-5f99-11ef-be16-5dff24403ae5

响应参数:

参数名称参数说明类型
itemsarray
alias别名string
createdTime创建时间string(date-time)
deviceState设备状态,可用值:INACTIVE,OFFLINE,ONLINEstring
label标签string
lastOnlineTime最后在线时间integer(int64)
tbDeviceIdTB设备IDstring
tbDeviceNameTB设备名称string
totalinteger(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组织IDqueryfalsestring
transportType传输类型,可用值:COAP,DEFAULT,LWM2M,MQTT,SNMP,TCPqueryfalsestring

请求示例:

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

响应数据类型:*/*

请求参数:

参数名称参数说明请求类型是否必须数据类型
tbDeviceIdtb设备Idpathtruestring

请求示例:

http://222.180.200.114:30427/api/yt/device/gateway/08bbc360-5f9a-11ef-be16-5dff24403ae5

响应参数:

参数名称参数说明类型
id主键idString
name设备名称String
tenantId租户idString
deviceInfo设备信息JsonNode
alias别名String
profileIdTB设备配置IDString
deviceProfileId平台设备配置IDString
tbDeviceIdTB设备IDString
brand设备厂商String
sn设备SNString
organizationId设备组织idString
deviceType设备类型:GATEWAY,DIRECT_CONNECTION,SENSORDeviceTypeEnum
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

响应数据类型:*/*

请求参数:

参数名称参数说明请求类型是否必须数据类型
tbDeviceIdtb设备Idpathtruestring

请求示例:

http://222.180.200.114:30427/api/yt/device/get_subset/ffed9510-5f99-11ef-be16-5dff24403ae5

响应参数:

参数名称参数说明类型
id主键idString
name设备名称String
tenantId租户idString
deviceInfo设备信息JsonNode
alias别名String
profileIdTB设备配置IDString
deviceProfileId平台设备配置IDString
tbDeviceIdTB设备IDString
brand设备厂商String
sn设备SNString
organizationId设备组织idString
deviceType设备类型:GATEWAY,DIRECT_CONNECTION,SENSORDeviceTypeEnum
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模糊搜索字段queryfalsestring
sortProperty排序规则:名称(titile)、创建时间、(createdTime)、客户(customerTitle)、设备配置(deviceProfileName)、标签(label)、状态(active)queryfalsestring
sortOrder排序(ASC,DESC)queryfalseInteger

请求示例:

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产品名称queryfalsestring
textSearch模糊搜索字段queryfalsestring
sortProperty排序规则:名称(name)、创建时间、(createdTime)、客户(customerTitle)、设备配置(deviceProfileName)、标签(label)、状态(active)queryfalsestring
sortOrder排序(ASC,DESC)queryfalseInteger

请求示例:

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组织IDqueryfalsestring
name设备名称queryfalsestring
deviceProfileId设备配置IDqueryfalsestring
alarmStatus告警状态:0 否 1是queryfalseInteger
deviceState设备状态:在线(ONLINE)、待激活(INACTIVE)、离线(OFFLINE)queryfalseenum
deviceType设备类型:网关(GATEWAY)、直连设备(DIRECT_CONNECTION)、网关子设备(SENSOR)queryfalseenum
isCollect是否收藏:0否 1是queryfalseInteger

请求示例:

ThingsKit物联网平台API文档-设备管理(设备)

响应参数:

参数名称参数说明类型
id主键idstring
name设备名称
deviceInfo设备信息JsonNode
alias别名String
activeTime激活时间LocalDateTime
deviceState设备状态DeviceState
profileIdTB设备配置IDString
deviceProfileId平台设备配置IDString
gatewayId关联网关设备String
gatewayName网关名称String
gatewayAlias网关别名String
deviceToken设备凭证TkCredentialsDto
tbDeviceIdTB设备IDString
brand设备厂商String
sn设备SNString
code设备标识符,例如:地址码String
codeType标识符/地址码类型:产品协议为TCP/UDP使用,MODBUS/CUSTOMCodeTypeEnum
organizationId设备组织idString
label设备标签String
customerId分配客户idString
customerName客户名称String
deviceProfile设备配置/产品信息DeviceProfileDTO
organizationDTO组织信息OrganizationDTO
deviceType设备类型:GATEWAY,DIRECT_CONNECTION,SENSORDeviceTypeEnum
alarmStatus告警状态:0正常,1告警alarmStatus
lastOnlineTime最后在线时间Long
lastOfflineTime最后离线时间Long
description描述String
enable启用/禁用boolean
transportType协议类型String
isCollect是否收藏:0否1是Integer
firmwareIdOTA升级固件IDString
softwareIdOTA升级软件IDString
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实体类型:默认使用DEVICEpathturestring
entityId设备ID:使用设备列表分页返回的tbDeviceIdpathturestring
keys设备标识符:多个标识符使用”,”分割。例如:temperature,humidityqueryfalsestring
useStrictDataTypes启用/禁用遥测值到字符串的转换。默认情况下启用转换。将参数设置为“true”以禁用转换。queryfalseboolean

注意: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实体类型:默认使用DEVICEpathturestring
entityId设备ID:使用设备列表分页返回的tbDeviceIdpathturestring
keys设备标识符queryfalsestring
开始时间与结束时间由前端选择方式传输:
例如: 1.查询方式=最后,最后数据=1天 startTs传当前时间的时间戳,endTS传startTs+1天的时间戳
2.查询方式=时间段,则传入选择的时间段
startTs开始时间(时间戳)queryfalseLong
endTs结束时间(时间戳)queryfalseLong
聚合功能(agg)与分组间隔(interval):例如:1.最后数据=1天、数据聚合功能=最小值、分组间隔=10分
此时查询的数据展示为:从当前时间起一天内,每间隔10分钟统计一次,取每10分钟数据中的最小值进行展示2.最后数据=1天、数据聚合功能=平均值、分组间隔=1小时此时查询的数据展示为:从当前时间起一天内,每间隔1小时统计一次,取每1小时数据之和的平均值进行展示
agg聚合功能queryfalseString
interval分组间隔queryfalseint
orderBy数据排序queryfalseString
useStrictDataTypes启用/禁用遥测值到字符串的转换。默认情况下启用转换。将参数设置为“true”以禁用转换。queryfalseboolean

注意: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
valuestring

响应示例:

{
    "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

响应数据类型:*/*

请求参数:

参数名称参数说明请求类型是否必须数据类型
ididpathtruestring

请求示例:

http://222.180.200.114:30427/api/yt/device/ffed9510-5f99-11ef-be16-5dff24403ae5

响应参数:

参数名称参数说明类型
id主键idstring
name设备名称
deviceInfo设备信息JsonNode
alias别名String
activeTime激活时间LocalDateTime
deviceState设备状态DeviceState
profileIdTB设备配置IDString
deviceProfileId平台设备配置IDString
gatewayId关联网关设备String
gatewayName网关名称String
gatewayAlias网关别名String
deviceToken设备凭证TkCredentialsDto
tbDeviceIdTB设备IDString
brand设备厂商String
sn设备SNString
code设备标识符,例如:地址码String
codeType标识符/地址码类型:产品协议为TCP/UDP使用,MODBUS/CUSTOMCodeTypeEnum
organizationId设备组织idString
label设备标签String
customerId分配客户idString
customerName客户名称String
deviceProfile设备配置/产品信息DeviceProfileDTO
organizationDTO组织信息OrganizationDTO
deviceType设备类型:GATEWAY,DIRECT_CONNECTION,SENSORDeviceTypeEnum
alarmStatus告警状态:0正常,1告警alarmStatus
lastOnlineTime最后在线时间Long
lastOfflineTime最后离线时间Long
description描述String
enable启用/禁用boolean
transportType协议类型String
isCollect是否收藏:0否1是Integer
firmwareIdOTA升级固件IDString
softwareIdOTA升级软件IDString
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

响应数据类型:*/*

请求参数:

参数名称参数说明请求类型是否必须数据类型
ididpathtruestring

请求示例:

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

响应数据类型:*/*

请求参数:

参数名称参数说明请求类型是否必须数据类型
additionalInfobodytruejson
additionalInfo.cmdType命令类型 0自定义1服务truejson
method方法:methodThingskitjson
params命令json
persistent是否持久化 :true,falsejson

请求示例:

{
    "additionalInfo": {
        "cmdType": 0
    },
    "method": "methodThingskit",
    "persistent": true,
    "params": {
        "test": "32.1"
    }
}

响应示例:

{
  "rpcId": "ff035be7-6570-4abe-ab71-b1309fa8af18"
}