getDeviceInfo
获取设备的设备信息
引入
import { device } from '@ray-js/ray';
const { getDeviceInfo } = device;
需引入
DeviceKit
,且在>=1.2.6
版本才可使用
请求参数
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
deviceId | string | 是 | deviceId 设备 id 支持跨面板获取其他的设备信息,当前面板可以传当前设备的 id 来进行获取 | |
dps | any | 否 | dps | |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
success | function | 否 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 |
返回结果
- success
属性 | 类型 | 说明 |
---|---|---|
schema | array | 产品信息,schema,功能定义都在里面 |
dps | any | dps 设备的功能点状态,可以根据对应的 dpid 拿到具体的状态值去做业务逻辑 |
attribute | number | attribute 产品属性定义,在 backend-ng 平台上可查到对应配置,使用二进制位运算的方式进行管理 |
capability | number | capability 产品能力值,在 backend-ng 平台上可以查询对应的勾选项,整体业务逻辑会根据该数据进行划分 区分设备类型也可以根据该属性进行调整,按二进制位运算的方式进行管理 |
dpName | any | dpName 自定义 dp 的名字,通常在面板里会使用到 |
ability | number | ability 目前业务很少使用,用于区分特殊类型的设备 |
icon | string | icon 设备的 icon url |
devId | string | devId 设备的唯一 id |
verSw | string | verSw 设备固件版本号 |
isShare | boolean | isShare 是否为分享设备,true 则是分享设备 |
bv | string | bv 设备的基线版本号 |
uuid | string | uuid 设备的固件唯一标识 |
panelConfig | any | panelConfig 产品面板里的配置项,通常在 涂鸦开发者平台上可以查看到对应的配置 |
activeTime | number | activeTime 设备激活时间,时间戳 |
devAttribute | number | devAttribute 设备的业务能力拓展,二进制位的方式进行运算 |
pcc | string | pcc Thing 自研蓝牙 mesh 产品的分类标识 |
nodeId | string | nodeId 子设备的短地址 |
parentId | string | parentId 上级节点 id,子设备/或蓝牙 mesh 设备通常会有该字段,用于内部寻找相关的网关或上级模型来进行业务处理 |
category | string | category 产品的分类 |
standSchemaModel | object | standSchemaModel 标准产品功能集定义模型 |
productId | string | productId 设备对应的产品 id |
bizAttribute | number | bizAttribute 设备自主上报的能力位 |
meshId | string | meshId Thing 自研的蓝牙 mesh id |
sigmeshId | string | sigmeshId 当前设备所属行业属性对应的蓝牙 mesh id |
meta | any | meta 设备自定义配置元属性,用于存放业务数据 |
isLocalOnline | boolean | isLocalOnline 本地局域网是否在线 |
isCloudOnline | boolean | 设备云端在线情况 |
isOnline | boolean | isOnline 设备总的在线情况,只要一个情况在线,就是在线,复合在线情况 |
name | string | name 设备名称 |
groupId | string | groupId |
dpCodes | any | dpCodes 标准功能集 code |
devTimezoneId | string | 时区信息 |
dpsTime | any | 设备的功能点执行的时间 |
latitude | string | 设备纬度 |
longitude | string | 设备经度 |
ip | string | 设备 ip 地址 |
isVirtualDevice | boolean | 是否为虚拟设备 |
isZigbeeInstallCode | boolean | zigbeeInstallCode to the cloud to mark the gateway with installation code ability |
👉 立即免费领取开发资源,体验涂鸦 MiniApp 小程序开发。
- fail
属性 | 类型 | 说明 |
---|---|---|
errorMsg | string | 插件错误信息 |
errorCode | string | 错误码 |
innerError | object | 插件外部依赖错误信息 {errorMsg: string, errorCode: string } |
请求示例
getDeviceInfo({
deviceId: '64710761ecfabcaaf553',
})
.then((res) => {
console.log(res);
})
.catch((error) => {
console.log(error);
});
返回示例
{
"latitude": "30.3029",
"dps": {
"101": false,
"102": 10,
"103": "121100",
"104": 1,
"105": false,
"106": 2,
"107": "0d01",
"109": true,
"116": 9,
"117": "4",
"121": false,
"122": false,
"123": false,
"124": false,
"125": false,
"126": false,
"127": "0103497f0f01010a010a0a000002d07f0f01010a010a0a000002d07f0f01010a010a0a000002d07f0f01010a010a0a00",
"128": "0001010a1e011e0f1e01",
"129": true,
"130": false
},
"protocolAttribute": 0,
"dpName": {
"101": "灯",
"105": "收音机",
"109": "闹钟1",
"121": "入睡",
"122": "闹钟2",
"123": "闹钟3",
"124": "闹钟4",
"130": "贪睡"
},
"schema": [{
"code": "led",
"id": 101,
"property": {
"type": "bool"
},
"name": "日常灯开关",
"mode": "rw",
"type": "obj"
}, {
"code": "led_light",
"id": 102,
"property": {
"unit": "",
"min": 1,
"scale": 0,
"step": 1,
"type": "value",
"max": 20
},
"name": "日常灯亮度",
"mode": "rw",
"type": "obj"
}, {
"code": "time_set",
"id": 103,
"property": {
"type": "string",
"maxlen": 255
},
"name": "设备时间",
"mode": "rw",
"type": "obj"
}, {
"code": "panel_light",
"id": 104,
"property": {
"unit": "",
"min": 0,
"scale": 0,
"step": 1,
"type": "value",
"max": 2
},
"name": "面板亮度",
"mode": "rw",
"type": "obj"
}, {
"code": "Radio",
"id": 105,
"property": {
"type": "bool"
},
"name": "Radio开关",
"mode": "rw",
"type": "obj"
}, {
"code": "volume",
"id": 106,
"property": {
"unit": "",
"min": 1,
"scale": 0,
"step": 1,
"type": "value",
"max": 16
},
"name": "Radio音量",
"mode": "rw",
"type": "obj"
}, {
"code": "Radiolist",
"id": 107,
"name": "Radio总台数及当前播放台号",
"mode": "rw",
"type": "raw"
}, {
"code": "clock1",
"id": 109,
"property": {
"type": "bool"
},
"name": "闹钟1开关",
"mode": "rw",
"type": "obj"
}, {
"code": "Delay_time",
"id": 116,
"property": {
"unit": "分钟",
"min": 8,
"scale": 0,
"step": 1,
"type": "value",
"max": 15
},
"name": "推迟启动时间",
"mode": "rw",
"type": "obj"
}, {
"code": "close_mode_set",
"id": 117,
"property": {
"range": ["1", "2", "3", "4"],
"type": "enum"
},
"name": "推迟关闭模式",
"mode": "rw",
"type": "obj"
}, {
"code": "sleep",
"id": 121,
"property": {
"type": "bool"
},
"name": "伴睡开关",
"mode": "rw",
"type": "obj"
}, {
"code": "clock2",
"id": 122,
"property": {
"type": "bool"
},
"name": "闹钟2开关",
"mode": "rw",
"type": "obj"
}, {
"code": "clock3",
"id": 123,
"property": {
"type": "bool"
},
"name": "闹钟3开关",
"mode": "rw",
"type": "obj"
}, {
"code": "clock4",
"id": 124,
"property": {
"type": "bool"
},
"name": "闹钟4开关",
"mode": "rw",
"type": "obj"
}, {
"code": "Internet_time",
"id": 125,
"property": {
"type": "bool"
},
"name": "网络校时",
"mode": "rw",
"type": "obj"
}, {
"code": "Radio_search",
"id": 126,
"property": {
"type": "bool"
},
"name": "Radio搜台开关",
"mode": "rw",
"type": "obj"
}, {
"code": "clock_set",
"id": 127,
"name": "闹钟设置",
"mode": "rw",
"type": "raw"
}, {
"code": "sleep_set",
"id": 128,
"name": "伴睡设置",
"mode": "rw",
"type": "raw"
}, {
"code": "colorLight",
"id": 129,
"property": {
"type": "bool"
},
"name": "彩灯开关",
"mode": "rw",
"type": "obj"
}, {
"code": "Delay",
"id": 130,
"property": {
"type": "bool"
},
"name": "推迟开关",
"mode": "rw",
"type": "obj"
}],
"isOnline": false,
"activeTime": 1644559537,
"bizAttribute": 0,
"category": "dj",
"dpsTime": {
"101": 1644559633434,
"102": 1644559632880,
"103": 1644559690125,
"104": 1644559540946,
"105": 1644559723564,
"106": 1644559675644,
"107": 1644559540785,
"109": 1644559540946,
"116": 1644559540946,
"117": 1644559540946,
"121": 1644559540946,
"122": 1644559540946,
"123": 1644559540946,
"124": 1644559540946,
"125": 1644559540946,
"126": 1644559723681,
"127": 1644559540828,
"128": 1644559540879,
"129": 1644559633434,
"130": 1644559540946
},
"capability": 1,
"hasWifi": true,
"isShare": false,
"baseAttribute": 1024,
"attribute": 274878695808,
"bluetoothCapability": "",
"roomName": "",
"devAttribute": 3,
"dpCodes": {
"switch_led": false,
"bright_value": 10
},
"isSupportOTA": true,
"switchDp": 0,
"icon": "https://images.tuyacn.com/smart/icon/ay1524204424146aiEgV/1d70743480aacffbc520f4fe1a8f73a9.png",
"uuid": "64710761ecfabcaaf553",
"isSupportGroup": false,
"mac": "ecfabcaaf553",
"connectionStatus": 0,
"isTripartiteMatter": false,
"pcc": "",
"wifiEnableState": 2,
"isLocalOnline": false,
"devId": "64710761ecfabcaaf553",
"isZigBeeSubDev": false,
"name": "唤醒灯",
"isSupportAppleHomeKit": true,
"longitude": "120.0636",
"isCloudOnline": false,
"isMatter": false,
"verSw": "3.1.1",
"switchDps": [],
"isZigbeeInstallCode": false,
"bv": "5.42",
"ability": 0,
"iconUrl": "https://images.tuyacn.com/smart/icon/ay1524204424146aiEgV/1d70743480aacffbc520f4fe1a8f73a9.png",
"attributeString": "100000000000000000011000000100110000000",
"isVirtualDevice": false,
"isSupportLink": true,
"isGW": false,
"ip": "124.90.34.114",
"cadv": "",
"devTimezoneId": "Asia/Shanghai",
"productId": "ORL6E2BCxSYVpfs4",
"configMetas": {}
}
👉 立即免费领取开发资源,体验涂鸦 MiniApp 小程序开发。