物的模型服务
更新时间:2019-01-17 19:24:35
提供一组与物(设备)相关的服务接口,客户端应用通过本组服务接口可以实现物信息的查询和控制,查询的内容涉及物的基本信息,物的上报数据信息以及物的TSL定义。
获取物的基本信息
定义描述
path | 版本 | 描述 | 是否需要用户身份的鉴权 |
---|---|---|---|
/thing/info/get | 1.0.2 | 获取物的信息,例如设备名称、mac地址、设备激活时间等内容 | 是,客户端SDK需启用身份的鉴权 |
请求参数
参数 | 类型 | 必填 | 描述 |
---|---|---|---|
iotId | String | 是 | 物的唯一标识符 |
返回参数
参数
|
类型
|
必有
|
描述
|
gmtModified
|
Long
|
是
|
设备记录数据修改时间(系统内部使用字段,用户可不需关心)
|
activeTime
|
Long
|
否
|
设备首次激活时间
|
gmtCreate
|
Long
|
是
|
设备记录创建时间,对于智能生活平台来讲,就是量产时,生成设备三元组的时间
|
productKey
|
String
|
是
|
产品key
|
statusLast
|
Integer
|
是
|
上一次设备状态
|
mac
|
String
|
否
|
mac地址
|
deviceSecret
|
String
|
是
|
设备secret
|
iotId
|
String
|
是
|
设备唯一标识符
|
name
|
String
|
是
|
设备名称
|
sdkVersion
|
String
|
否
|
sdk版本
|
sn
|
String
|
否
|
设备sn
|
thingType
|
String
|
是
|
设备类型
VIRTUAL:虚拟设备
VIRTUAL_SHADOW:虚拟设备
DEVICE:真实设备
|
firmwareVersion
|
String
|
否
|
固件版本号
|
rbacTenantId
|
String
|
是
|
租户id
|
status
|
Integer
|
是
|
设备状态
0:未激活
1:在线
3:离线
8:禁用
|
netAddress
|
String
|
否
|
ip地址
|
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.2",
"iotToken": "token"
},
"params": {
"iotId": "D95D242941CE821ECCE4F31A2697"
}
}
正常返回示例
{
"code": 200,
"data": {
"gmtModified": 1517918765000,
"activeTime": null,
"gmtCreate": 1500017648000,
"productKey": "kQGJJuTl0qA",
"statusLast": null,
"mac": null,
"netAddress": null,
"deviceSecret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"iotId": "03iGXYVl03e23f667d90269c2ccwgzHG",
"name": "Kq7rgvE2cNGcwtDexwJh",
"nickname": null,
"sdkVersion": null,
"sn": null,
"thingType": "DEVICE",
"firmwareVersion": "1.0.0",
"rbacTenantId": "ADSBCUYAGDCUDD827918327917",
"status": 1
},
"message": "success",
"localizedMsg": null
}
错误码
请参考公共错误码
获取物的属性timeline数据
定义描述
path | 版本 | 描述 | 是否需要用户身份的鉴权 |
---|---|---|---|
/thing/property/timeline/get | 1.0.2 | 获取物的属性timeline数据 | 是,客户端SDK需启用身份的鉴权 |
目前历史数据限制为1年
请求参数
参数 | 类型 | 必填 | 描述 |
---|---|---|---|
iotId | String | 是 | 物的唯一标识符 |
identifier | String | 是 | 属性标识符 |
start | Long | 是 | timeline起始时间 |
end | Long | 是 | timeline终止时间 |
pageSize | Int | 是 | 分页查询条数(最大200) |
ordered | Boolean | 是 | 顺序(true)、逆序(false)查询 |
返回参数
参数 | 类型 | 必有 | 描述 |
---|---|---|---|
iotid | String | 是 | 设备标识符 |
data | Object | 是 | 设备timeline数据 |
modifytime | Long | 是 | 属性更新时间 |
property | String | 是 | 属性标识符 |
batchId | String | 是 | 批次id |
timestamp | Long | 是 | 属性采集时间戳 |
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.2",
"iotToken": "token"
},
"params": {
"iotId": "D95D242941CE821ECCE4F31A2697",
"identifier": "xxxx",
"start": 1517217645000,
"end": 1517217645000,
"pageSize": 10,
"ordered": true
}
}
正常返回示例
{
"code": 200,
"message": "success",
"localizedMsg": null,
"data": {
"items": [
{
"iotid": "xqxyZjSKzCwaGdlvbv0O0010851c00",
"data": 1.23,
"modifytime": 1511812747287,
"property": "LightVolt",
"batchId": "2fc766c5e7064554933ed1f3e4b61803",
"group": null,
"timestamp": 1511812747245
},
{
"iotid": "xqxyZjSKzCwaGdlvbv0O0010851c00",
"data": 1.24,
"modifytime": 1511812747288,
"property": "LightVolt",
"batchId": "2fc766c5e7064554933ed1f3e4b61803",
"group": null,
"timestamp": 1511812747245
}
],
"timestamp": 1511812747245
}
}
错误码
请参考公共错误码
获取物的事件timeline数据
定义描述
path | 版本 | 描述 | 是否需要用户身份的鉴权 |
---|---|---|---|
/thing/event/timeline/get | 1.0.2 | 获取物的事件timeline数据 | 是,客户端SDK需启用身份的鉴权 |
目前历史数据限制为1年
请求参数
参数 | 类型 | 必填 | 描述 |
---|---|---|---|
iotId | String | 是 | 物的唯一标识符 |
identifier | String | 是 | 属性标识符 |
eventType | String | 是 | 事件类型 |
start | Long | 是 | timeline起始时间 |
end | Long | 是 | timeline终止时间 |
pageSize | Int | 是 | 分页查询条数 |
ordered | Boolean | 是 | 顺序(true)、逆序(false)查询 |
返回参数
参数 | 类型 | 必有 | 描述 |
---|---|---|---|
eventCode | String | 是 | 事件标识符 |
iotId | String | 是 | 物的唯一标识符 |
eventName | String | 是 | 事件名称 |
eventType | String | 是 | 事件类型 |
eventBody | Object | 是 | 事件参数 |
batchId | String | 是 | 批次id |
timestamp | Long | 是 | 时间采集时间 |
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.2",
"iotToken": "token"
},
"params": {
"iotId": "D95D242941CE821ECCE4F31A2697",
"identifier": "xxxx",
"eventType": "xxxx",
"start": 1517217645000,
"end": 1517217645000,
"pageSize": 10,
"ordered": true
}
}
正常返回示例
{
"code": 200,
"message": "success",
"localizedMsg": "",
"data": {
"items": [
{
"eventCode": "Error",
"iotId": "YzqEnI5DY03rxLS2pjjo0010840500",
"eventName": "故障上报",
"eventType": "info",
"eventBody": {
"ErrorCode": 0
},
"batchId": "5ebc6a9c7d15459f823edde6d28c8fb3",
"timestamp": 1516342985261
},
{
"eventCode": "Error",
"iotId": "YzqEnI5DY03rxLS2pjjo0010840500",
"eventName": "故障上报",
"eventType": "info",
"eventBody": {
"ErrorCode": 0
},
"batchId": "4a0b5a7ac85e470684438d5ff77456f1",
"timestamp": 1516342995305
}
],
"timestamp": 1516343075699
}
}
错误码
请参考公共错误码
设置物的属性
定义描述
path | 版本 | 描述 | 是否需要用户身份的鉴权 |
---|---|---|---|
/thing/properties/set | 1.0.2 | 设置物的属性 | 是,客户端SDK需启用身份的鉴权 |
请求参数
参数 | 类型 | 必填 | 描述 |
---|---|---|---|
iotId | String | 是 | 物的唯一标识符 |
items | JSON | 是 | set参数 |
返回参数
参数 | 类型 | 必有 | 描述 |
---|---|---|---|
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.2",
"iotToken": "token"
},
"params": {
"iotId": "D95D242941CE821ECCE4F31A2697",
"items": {
"LightSwitch1": 0,
"LightSwitch2": 0
}
}
}
正常返回示例
{
"code": 200,
"data": null,
"message": "success",
"localizedMsg": ""
}
错误码
请参考公共错误码
获取物的事件
定义描述
path | 版本 | 描述 | 是否需要用户身份的鉴权 |
---|---|---|---|
/thing/events/get | 1.0.2 | 获取物的事件 | 是,客户端SDK需启用身份的鉴权 |
请求参数
参数 | 类型 | 必填 | 描述 |
---|---|---|---|
iotId | String | 是 | 物的唯一标识符 |
返回参数
参数 | 类型 | 必有 | 描述 |
---|---|---|---|
identifier | String | 是 | 事件标识符 |
time | Long | 是 | 时间采集时间 |
type | String | 是 | 事件类型 |
value | Object | 是 | 事件出参 |
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.2",
"iotToken": "token"
},
"params": {
"iotId": "D95D242941CE821ECCE4F31A2697"
}
}
正常返回示例
{
"code": 200,
"data": [
{
"identifier": "Error",
"time": 1517420842314,
"type": "info",
"value": {
"Shrink5": 12,
"Shrink20": {
"testKey2": "val2",
"testKey": "val"
}
}
}
],
"message": "success",
"localizedMsg": null
}
错误码
请参考公共错误码
根据设备id获取物的模板
定义描述
path | 版本 | 描述 | 是否需要用户身份的鉴权 |
---|---|---|---|
/thing/tsl/get | 1.0.2 | 获取物的tsl功能模板(包含属性、事件、服务的定义) | 是,客户端SDK需启用身份的鉴权 |
请求参数
参数 | 类型 | 必填 | 描述 |
---|---|---|---|
iotId | String | 是 | 物的唯一标识符 |
返回参数
参数 | 类型 | 必有 | 描述 |
---|---|---|---|
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.2",
"iotToken": "token"
},
"params": {
"iotId": "D95D242941CE821ECCE4F31A2697"
}
}
正常返回示例
{
"code": 200,
"data": {
"schema": "http://aliyun/iot/thing/desc/schema",
"profile": {
"productKey": "a1xqv8AGpck",
"deviceName": "YzqEnI5DY03rxLS2pjjo"
},
"link": "/sys/a1xqv8AGpck/YzqEnI5DY03rxLS2pjjo/thing/",
"services": [
{
"outputData": [
],
"identifier": "set",
"inputData": [
{
"identifier": "LightSwitch",
"dataType": {
"specs": {
"0": "关闭",
"1": "开启"
},
"type": "bool"
},
"name": "主灯开关"
},
{
"identifier": "ColorTemperature",
"dataType": {
"specs": {
"unit": "K",
"min": "2700",
"unitName": "开尔文",
"max": "6500"
},
"type": "int"
},
"name": "冷暖色温"
},
{
"identifier": "Brightness",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "明暗度"
},
{
"identifier": "HSVColor",
"dataType": {
"specs": [
{
"identifier": "Hue",
"dataType": {
"specs": {
"unit": "°",
"min": "0",
"unitName": "度",
"max": "360"
},
"type": "int"
},
"name": "色调"
},
{
"identifier": "Saturation",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "饱和度"
},
{
"identifier": "Value",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "明度"
}
],
"type": "struct"
},
"name": "HSV调色"
},
{
"identifier": "HSLColor",
"dataType": {
"specs": [
{
"identifier": "Hue",
"dataType": {
"specs": {
"unit": "°",
"min": "0",
"unitName": "度",
"max": "360"
},
"type": "int"
},
"name": "色调"
},
{
"identifier": "Saturation",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "饱和度"
},
{
"identifier": "Lightness",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "亮度"
}
],
"type": "struct"
},
"name": "HSL调色"
},
{
"identifier": "RGBColor",
"dataType": {
"specs": [
{
"identifier": "Red",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "红色"
},
{
"identifier": "Green",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "绿色"
},
{
"identifier": "Blue",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "蓝色"
}
],
"type": "struct"
},
"name": "RGB调色"
},
{
"identifier": "NightLightSwitch",
"dataType": {
"specs": {
"0": "关闭",
"1": "开启"
},
"type": "bool"
},
"name": "夜灯开关"
},
{
"identifier": "WorkMode",
"dataType": {
"specs": {
"0": "手动",
"1": "阅读",
"2": "影院",
"3": "夜灯",
"4": "生活",
"5": "柔和"
},
"type": "enum"
},
"name": "工作模式"
}
],
"method": "thing.service.property.set",
"name": "set",
"required": true,
"callType": "sync",
"desc": "属性设置"
},
{
"outputData": [
{
"identifier": "LightSwitch",
"dataType": {
"specs": {
"0": "关闭",
"1": "开启"
},
"type": "bool"
},
"name": "主灯开关"
},
{
"identifier": "ColorTemperature",
"dataType": {
"specs": {
"unit": "K",
"min": "2700",
"unitName": "开尔文",
"max": "6500"
},
"type": "int"
},
"name": "冷暖色温"
},
{
"identifier": "Brightness",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "明暗度"
},
{
"identifier": "HSVColor",
"dataType": {
"specs": [
{
"identifier": "Hue",
"dataType": {
"specs": {
"unit": "°",
"min": "0",
"unitName": "度",
"max": "360"
},
"type": "int"
},
"name": "色调"
},
{
"identifier": "Saturation",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "饱和度"
},
{
"identifier": "Value",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "明度"
}
],
"type": "struct"
},
"name": "HSV调色"
},
{
"identifier": "HSLColor",
"dataType": {
"specs": [
{
"identifier": "Hue",
"dataType": {
"specs": {
"unit": "°",
"min": "0",
"unitName": "度",
"max": "360"
},
"type": "int"
},
"name": "色调"
},
{
"identifier": "Saturation",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "饱和度"
},
{
"identifier": "Lightness",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "亮度"
}
],
"type": "struct"
},
"name": "HSL调色"
},
{
"identifier": "RGBColor",
"dataType": {
"specs": [
{
"identifier": "Red",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "红色"
},
{
"identifier": "Green",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "绿色"
},
{
"identifier": "Blue",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "蓝色"
}
],
"type": "struct"
},
"name": "RGB调色"
},
{
"identifier": "NightLightSwitch",
"dataType": {
"specs": {
"0": "关闭",
"1": "开启"
},
"type": "bool"
},
"name": "夜灯开关"
},
{
"identifier": "WorkMode",
"dataType": {
"specs": {
"0": "手动",
"1": "阅读",
"2": "影院",
"3": "夜灯",
"4": "生活",
"5": "柔和"
},
"type": "enum"
},
"name": "工作模式"
}
],
"identifier": "get",
"inputData": [
"LightSwitch",
"ColorTemperature",
"Brightness",
"HSVColor",
"HSLColor",
"RGBColor",
"NightLightSwitch",
"WorkMode"
],
"method": "thing.service.property.get",
"name": "get",
"required": true,
"callType": "sync",
"desc": "属性获取"
},
{
"outputData": [
],
"identifier": "ToggleLightSwitch",
"inputData": [
],
"method": "thing.service.ToggleLightSwitch",
"name": "翻转主灯开关",
"required": false,
"callType": "async"
}
],
"properties": [
{
"identifier": "LightSwitch",
"dataType": {
"specs": {
"0": "关闭",
"1": "开启"
},
"type": "bool"
},
"name": "主灯开关",
"accessMode": "rw",
"required": true
},
{
"identifier": "ColorTemperature",
"dataType": {
"specs": {
"unit": "K",
"min": "2700",
"unitName": "开尔文",
"max": "6500"
},
"type": "int"
},
"name": "冷暖色温",
"accessMode": "rw",
"required": false
},
{
"identifier": "Brightness",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "明暗度",
"accessMode": "rw",
"required": false
},
{
"identifier": "HSVColor",
"dataType": {
"specs": [
{
"identifier": "Hue",
"dataType": {
"specs": {
"unit": "°",
"min": "0",
"unitName": "度",
"max": "360"
},
"type": "int"
},
"name": "色调"
},
{
"identifier": "Saturation",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "饱和度"
},
{
"identifier": "Value",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "明度"
}
],
"type": "struct"
},
"name": "HSV调色",
"accessMode": "rw",
"required": false
},
{
"identifier": "HSLColor",
"dataType": {
"specs": [
{
"identifier": "Hue",
"dataType": {
"specs": {
"unit": "°",
"min": "0",
"unitName": "度",
"max": "360"
},
"type": "int"
},
"name": "色调"
},
{
"identifier": "Saturation",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "饱和度"
},
{
"identifier": "Lightness",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "亮度"
}
],
"type": "struct"
},
"name": "HSL调色",
"accessMode": "rw",
"required": false
},
{
"identifier": "RGBColor",
"dataType": {
"specs": [
{
"identifier": "Red",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "红色"
},
{
"identifier": "Green",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "绿色"
},
{
"identifier": "Blue",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "蓝色"
}
],
"type": "struct"
},
"name": "RGB调色",
"accessMode": "rw",
"required": false
},
{
"identifier": "NightLightSwitch",
"dataType": {
"specs": {
"0": "关闭",
"1": "开启"
},
"type": "bool"
},
"name": "夜灯开关",
"accessMode": "rw",
"required": false
},
{
"identifier": "WorkMode",
"dataType": {
"specs": {
"0": "手动",
"1": "阅读",
"2": "影院",
"3": "夜灯",
"4": "生活",
"5": "柔和"
},
"type": "enum"
},
"name": "工作模式",
"accessMode": "rw",
"required": false
}
],
"events": [
{
"outputData": [
{
"identifier": "LightSwitch",
"dataType": {
"specs": {
"0": "关闭",
"1": "开启"
},
"type": "bool"
},
"name": "主灯开关"
},
{
"identifier": "ColorTemperature",
"dataType": {
"specs": {
"unit": "K",
"min": "2700",
"unitName": "开尔文",
"max": "6500"
},
"type": "int"
},
"name": "冷暖色温"
},
{
"identifier": "Brightness",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "明暗度"
},
{
"identifier": "HSVColor",
"dataType": {
"specs": [
{
"identifier": "Hue",
"dataType": {
"specs": {
"unit": "°",
"min": "0",
"unitName": "度",
"max": "360"
},
"type": "int"
},
"name": "色调"
},
{
"identifier": "Saturation",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "饱和度"
},
{
"identifier": "Value",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "明度"
}
],
"type": "struct"
},
"name": "HSV调色"
},
{
"identifier": "HSLColor",
"dataType": {
"specs": [
{
"identifier": "Hue",
"dataType": {
"specs": {
"unit": "°",
"min": "0",
"unitName": "度",
"max": "360"
},
"type": "int"
},
"name": "色调"
},
{
"identifier": "Saturation",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "饱和度"
},
{
"identifier": "Lightness",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "亮度"
}
],
"type": "struct"
},
"name": "HSL调色"
},
{
"identifier": "RGBColor",
"dataType": {
"specs": [
{
"identifier": "Red",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "红色"
},
{
"identifier": "Green",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "绿色"
},
{
"identifier": "Blue",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "蓝色"
}
],
"type": "struct"
},
"name": "RGB调色"
},
{
"identifier": "NightLightSwitch",
"dataType": {
"specs": {
"0": "关闭",
"1": "开启"
},
"type": "bool"
},
"name": "夜灯开关"
},
{
"identifier": "WorkMode",
"dataType": {
"specs": {
"0": "手动",
"1": "阅读",
"2": "影院",
"3": "夜灯",
"4": "生活",
"5": "柔和"
},
"type": "enum"
},
"name": "工作模式"
}
],
"identifier": "post",
"method": "thing.event.property.post",
"name": "post",
"type": "info",
"required": true,
"desc": "属性上报"
},
{
"outputData": [
{
"identifier": "ErrorCode",
"dataType": {
"specs": {
"0": "正常"
},
"type": "enum"
},
"name": "故障代码"
}
],
"identifier": "Error",
"method": "thing.event.Error.post",
"name": "故障上报",
"type": "info",
"required": true
}
]
},
"message": "success",
"localizedMsg": null,
"class": "com.aliyun.iotx.common.base.service.IoTxResult"
}
错误码
请参考公共错误码
根据产品key获取物的模板
定义描述
path | 版本 | 描述 | 是否需要用户身份的鉴权 |
---|---|---|---|
/thing/tsl/getByProducyKey | 1.0.2 | 获取物的tsl功能模板(包含属性、事件、服务的定义) | 是,客户端SDK需启用身份的鉴权 |
请求参数
参数 | 类型 | 必填 | 描述 |
---|---|---|---|
productKey | String | 是 | 产品Key |
deviceName | String | 否 | deviceName |
返回参数
参数 | 类型 | 必有 | 描述 |
---|---|---|---|
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.2",
"iotToken": "token"
},
"params": {
"ProductKey": "xxxxxxxx",
"deviceName": "xxxxxxxx"
}
}
正常返回示例
{
"code": 200,
"data": {
"schema": "http://aliyun/iot/thing/desc/schema",
"profile": {
"productKey": "a1xqv8AGpck",
"deviceName": "YzqEnI5DY03rxLS2pjjo"
},
"link": "/sys/a1xqv8AGpck/YzqEnI5DY03rxLS2pjjo/thing/",
"services": [
{
"outputData": [
],
"identifier": "set",
"inputData": [
{
"identifier": "LightSwitch",
"dataType": {
"specs": {
"0": "关闭",
"1": "开启"
},
"type": "bool"
},
"name": "主灯开关"
},
{
"identifier": "ColorTemperature",
"dataType": {
"specs": {
"unit": "K",
"min": "2700",
"unitName": "开尔文",
"max": "6500"
},
"type": "int"
},
"name": "冷暖色温"
},
{
"identifier": "Brightness",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "明暗度"
},
{
"identifier": "HSVColor",
"dataType": {
"specs": [
{
"identifier": "Hue",
"dataType": {
"specs": {
"unit": "°",
"min": "0",
"unitName": "度",
"max": "360"
},
"type": "int"
},
"name": "色调"
},
{
"identifier": "Saturation",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "饱和度"
},
{
"identifier": "Value",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "明度"
}
],
"type": "struct"
},
"name": "HSV调色"
},
{
"identifier": "HSLColor",
"dataType": {
"specs": [
{
"identifier": "Hue",
"dataType": {
"specs": {
"unit": "°",
"min": "0",
"unitName": "度",
"max": "360"
},
"type": "int"
},
"name": "色调"
},
{
"identifier": "Saturation",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "饱和度"
},
{
"identifier": "Lightness",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "亮度"
}
],
"type": "struct"
},
"name": "HSL调色"
},
{
"identifier": "RGBColor",
"dataType": {
"specs": [
{
"identifier": "Red",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "红色"
},
{
"identifier": "Green",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "绿色"
},
{
"identifier": "Blue",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "蓝色"
}
],
"type": "struct"
},
"name": "RGB调色"
},
{
"identifier": "NightLightSwitch",
"dataType": {
"specs": {
"0": "关闭",
"1": "开启"
},
"type": "bool"
},
"name": "夜灯开关"
},
{
"identifier": "WorkMode",
"dataType": {
"specs": {
"0": "手动",
"1": "阅读",
"2": "影院",
"3": "夜灯",
"4": "生活",
"5": "柔和"
},
"type": "enum"
},
"name": "工作模式"
}
],
"method": "thing.service.property.set",
"name": "set",
"required": true,
"callType": "sync",
"desc": "属性设置"
},
{
"outputData": [
{
"identifier": "LightSwitch",
"dataType": {
"specs": {
"0": "关闭",
"1": "开启"
},
"type": "bool"
},
"name": "主灯开关"
},
{
"identifier": "ColorTemperature",
"dataType": {
"specs": {
"unit": "K",
"min": "2700",
"unitName": "开尔文",
"max": "6500"
},
"type": "int"
},
"name": "冷暖色温"
},
{
"identifier": "Brightness",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "明暗度"
},
{
"identifier": "HSVColor",
"dataType": {
"specs": [
{
"identifier": "Hue",
"dataType": {
"specs": {
"unit": "°",
"min": "0",
"unitName": "度",
"max": "360"
},
"type": "int"
},
"name": "色调"
},
{
"identifier": "Saturation",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "饱和度"
},
{
"identifier": "Value",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "明度"
}
],
"type": "struct"
},
"name": "HSV调色"
},
{
"identifier": "HSLColor",
"dataType": {
"specs": [
{
"identifier": "Hue",
"dataType": {
"specs": {
"unit": "°",
"min": "0",
"unitName": "度",
"max": "360"
},
"type": "int"
},
"name": "色调"
},
{
"identifier": "Saturation",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "饱和度"
},
{
"identifier": "Lightness",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "亮度"
}
],
"type": "struct"
},
"name": "HSL调色"
},
{
"identifier": "RGBColor",
"dataType": {
"specs": [
{
"identifier": "Red",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "红色"
},
{
"identifier": "Green",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "绿色"
},
{
"identifier": "Blue",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "蓝色"
}
],
"type": "struct"
},
"name": "RGB调色"
},
{
"identifier": "NightLightSwitch",
"dataType": {
"specs": {
"0": "关闭",
"1": "开启"
},
"type": "bool"
},
"name": "夜灯开关"
},
{
"identifier": "WorkMode",
"dataType": {
"specs": {
"0": "手动",
"1": "阅读",
"2": "影院",
"3": "夜灯",
"4": "生活",
"5": "柔和"
},
"type": "enum"
},
"name": "工作模式"
}
],
"identifier": "get",
"inputData": [
"LightSwitch",
"ColorTemperature",
"Brightness",
"HSVColor",
"HSLColor",
"RGBColor",
"NightLightSwitch",
"WorkMode"
],
"method": "thing.service.property.get",
"name": "get",
"required": true,
"callType": "sync",
"desc": "属性获取"
},
{
"outputData": [
],
"identifier": "ToggleLightSwitch",
"inputData": [
],
"method": "thing.service.ToggleLightSwitch",
"name": "翻转主灯开关",
"required": false,
"callType": "async"
}
],
"properties": [
{
"identifier": "LightSwitch",
"dataType": {
"specs": {
"0": "关闭",
"1": "开启"
},
"type": "bool"
},
"name": "主灯开关",
"accessMode": "rw",
"required": true
},
{
"identifier": "ColorTemperature",
"dataType": {
"specs": {
"unit": "K",
"min": "2700",
"unitName": "开尔文",
"max": "6500"
},
"type": "int"
},
"name": "冷暖色温",
"accessMode": "rw",
"required": false
},
{
"identifier": "Brightness",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "明暗度",
"accessMode": "rw",
"required": false
},
{
"identifier": "HSVColor",
"dataType": {
"specs": [
{
"identifier": "Hue",
"dataType": {
"specs": {
"unit": "°",
"min": "0",
"unitName": "度",
"max": "360"
},
"type": "int"
},
"name": "色调"
},
{
"identifier": "Saturation",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "饱和度"
},
{
"identifier": "Value",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "明度"
}
],
"type": "struct"
},
"name": "HSV调色",
"accessMode": "rw",
"required": false
},
{
"identifier": "HSLColor",
"dataType": {
"specs": [
{
"identifier": "Hue",
"dataType": {
"specs": {
"unit": "°",
"min": "0",
"unitName": "度",
"max": "360"
},
"type": "int"
},
"name": "色调"
},
{
"identifier": "Saturation",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "饱和度"
},
{
"identifier": "Lightness",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "亮度"
}
],
"type": "struct"
},
"name": "HSL调色",
"accessMode": "rw",
"required": false
},
{
"identifier": "RGBColor",
"dataType": {
"specs": [
{
"identifier": "Red",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "红色"
},
{
"identifier": "Green",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "绿色"
},
{
"identifier": "Blue",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "蓝色"
}
],
"type": "struct"
},
"name": "RGB调色",
"accessMode": "rw",
"required": false
},
{
"identifier": "NightLightSwitch",
"dataType": {
"specs": {
"0": "关闭",
"1": "开启"
},
"type": "bool"
},
"name": "夜灯开关",
"accessMode": "rw",
"required": false
},
{
"identifier": "WorkMode",
"dataType": {
"specs": {
"0": "手动",
"1": "阅读",
"2": "影院",
"3": "夜灯",
"4": "生活",
"5": "柔和"
},
"type": "enum"
},
"name": "工作模式",
"accessMode": "rw",
"required": false
}
],
"events": [
{
"outputData": [
{
"identifier": "LightSwitch",
"dataType": {
"specs": {
"0": "关闭",
"1": "开启"
},
"type": "bool"
},
"name": "主灯开关"
},
{
"identifier": "ColorTemperature",
"dataType": {
"specs": {
"unit": "K",
"min": "2700",
"unitName": "开尔文",
"max": "6500"
},
"type": "int"
},
"name": "冷暖色温"
},
{
"identifier": "Brightness",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "明暗度"
},
{
"identifier": "HSVColor",
"dataType": {
"specs": [
{
"identifier": "Hue",
"dataType": {
"specs": {
"unit": "°",
"min": "0",
"unitName": "度",
"max": "360"
},
"type": "int"
},
"name": "色调"
},
{
"identifier": "Saturation",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "饱和度"
},
{
"identifier": "Value",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "明度"
}
],
"type": "struct"
},
"name": "HSV调色"
},
{
"identifier": "HSLColor",
"dataType": {
"specs": [
{
"identifier": "Hue",
"dataType": {
"specs": {
"unit": "°",
"min": "0",
"unitName": "度",
"max": "360"
},
"type": "int"
},
"name": "色调"
},
{
"identifier": "Saturation",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "饱和度"
},
{
"identifier": "Lightness",
"dataType": {
"specs": {
"unit": "%",
"min": "0",
"unitName": "百分比",
"max": "100"
},
"type": "int"
},
"name": "亮度"
}
],
"type": "struct"
},
"name": "HSL调色"
},
{
"identifier": "RGBColor",
"dataType": {
"specs": [
{
"identifier": "Red",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "红色"
},
{
"identifier": "Green",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "绿色"
},
{
"identifier": "Blue",
"dataType": {
"specs": {
"min": "0",
"unitName": "无",
"max": "255"
},
"type": "int"
},
"name": "蓝色"
}
],
"type": "struct"
},
"name": "RGB调色"
},
{
"identifier": "NightLightSwitch",
"dataType": {
"specs": {
"0": "关闭",
"1": "开启"
},
"type": "bool"
},
"name": "夜灯开关"
},
{
"identifier": "WorkMode",
"dataType": {
"specs": {
"0": "手动",
"1": "阅读",
"2": "影院",
"3": "夜灯",
"4": "生活",
"5": "柔和"
},
"type": "enum"
},
"name": "工作模式"
}
],
"identifier": "post",
"method": "thing.event.property.post",
"name": "post",
"type": "info",
"required": true,
"desc": "属性上报"
},
{
"outputData": [
{
"identifier": "ErrorCode",
"dataType": {
"specs": {
"0": "正常"
},
"type": "enum"
},
"name": "故障代码"
}
],
"identifier": "Error",
"method": "thing.event.Error.post",
"name": "故障上报",
"type": "info",
"required": true
}
]
},
"message": "success",
"localizedMsg": null,
"class": "com.aliyun.iotx.common.base.service.IoTxResult"
}
错误码
请参考公共错误码
获取物的属性
定义描述
path | 版本 | 描述 | 是否需要用户身份的鉴权 |
---|---|---|---|
/thing/properties/get | 1.0.2 | 获取物的所有属性快照数据 | 是,客户端SDK需启用身份的鉴权 |
请求参数
参数 | 类型 | 必填 | 描述 |
---|---|---|---|
iotId | String | 是 | 物的标识符 |
返回参数
参数 | 类型 | 必有 | 描述 |
---|---|---|---|
value | Object | 是 | 属性对应的数据 |
time | Long | 是 | 属性采集时间 |
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.2",
"iotToken": "token"
},
"params": {
"iotId": "D95D242941CE821ECCE4F31A2697"
}
}
正常返回示例
{
"code": 200,
"data": {
"_sys_device_mid": {
"time": 1516356290173,
"value": "example.demo.module-id"
},
"WorkMode": {
"time": 1516347450295,
"value": 0
},
"_sys_device_pid": {
"time": 1516356290173,
"value": "example.demo.partner-id"
}
},
"message": "success",
"localizedMsg": null
}
错误码
请参考公共错误码
触发物的服务
定义描述
path | 版本 | 描述 | 是否需要用户身份的鉴权 |
---|---|---|---|
/thing/service/invoke | 1.0.2 | 触发物的服务 | 是,客户端SDK需启用身份的鉴权 |
请求参数
参数 | 类型 | 必填 | 描述 |
---|---|---|---|
iotId | String | 是 | 物的标识符 |
identifier | String | 是 | 服务标识符 |
args | JSON | 是 | 服务入参 |
返回参数
参数 | 类型 | 必有 | 描述 |
---|---|---|---|
data | Object | 是 | 该返回值类型及值取决于设备端实现逻辑 |
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.2",
"iotToken": "token"
},
"params": {
"iotId": "D95D242941CE821ECCE4F31A2697",
"identifier": "xxxx",
"args": {}
}
}
正常返回示例
{
"code": 200,
"data": null,
"message": "success",
"localizedMsg": ""
}
错误码
请参考公共错误码
获取物的连接状态
定义描述
path | 版本 | 描述 | 是否需要用户身份的鉴权 |
---|---|---|---|
/thing/status/get | 1.0.2 | 获取物的连接状态 | 是,客户端SDK需启用身份的鉴权 |
请求参数
参数 | 类型 | 必填 | 描述 |
---|---|---|---|
iotId | String | 是 | 物的唯一标识符 |
返回参数
参数 | 类型 | 必有 | 描述 |
---|---|---|---|
status | Integer | 是 | 设备状态 0 - 未激活,1-在线, 3 - 离线, 8 - 禁用 |
time | Long | 是 | 状态变更时间 |
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.2",
"iotToken": "token"
},
"params": {
"iotId": "D95D242941CE821ECCE4F31A2697"
}
}
正常返回示例
{
"code": 200,
"data": {
"time": 1517923297000,
"status": 3
},
"message": "success",
"localizedMsg": null,
}
错误码
请参考公共错误码
设置设备扩展信息
定义描述
path | 版本 | 描述 | 是否需要用户身份的鉴权 |
---|---|---|---|
/thing/extended/property/set | 1.0.2 | 设置物的扩展属性数据 | 是,客户端SDK需启用身份的鉴权 |
请求参数
参数 | 类型 | 必填 | 描述 |
---|---|---|---|
iotId | String | 是 | 物的唯一标识符 |
dataKey | String | 是 | 扩展属性标识符 |
dataValue | String | 是 | 扩展属性的值 |
返回参数
参数 | 类型 | 必有 | 描述 |
---|---|---|---|
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.2",
"iotToken": "token"
},
"params": {
"iotId": "D95D242941CE821ECCE4F31A2697",
"dataKey": "xxxx",
"dataValue": "xxxx"
}
}
正常返回示例
{
"code": 200,
"message": "success",
"localizedMsg": null,
"data": null
}
错误码
请参考公共错误码
获取设备扩展信息
定义描述
path | 版本 | 描述 | 是否需要用户身份的鉴权 |
---|---|---|---|
/thing/extended/property/get | 1.0.2 | 获取物的扩展属性的数据 | 是,客户端SDK需启用身份的鉴权 |
请求参数
参数 | 类型 | 必填 | 描述 |
---|---|---|---|
iotId | String | 是 | 物的唯一标识符 |
dataKey | String | 是 | 扩展属性标识符 |
返回参数
参数 | 类型 | 必有 | 描述 |
---|---|---|---|
data | String | 是 | 扩展属性的值 |
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.2",
"iotToken": "token"
},
"params": {
"iotId": "D95D242941CE821ECCE4F31A2697",
"dataKey": "xxxx"
}
}
正常返回示例
{
"code": 200,
"message": "success",
"localizedMsg": null,
"data": "xxxx"
}
错误码
请参考公共错误码