智能小程序 Ray 开发设备信息 API —— getDeviceInfo API 详解

getDeviceInfo

获取设备的设备信息

引入

import { device } from '@ray-js/ray';
const { getDeviceInfo } = device;

需引入DeviceKit,且在>=1.2.6版本才可使用

请求参数

Object object

属性类型默认值必填说明
deviceIdstringdeviceId 设备 id 支持跨面板获取其他的设备信息,当前面板可以传当前设备的 id 来进行获取
dpsanydps
completefunction接口调用结束的回调函数(调用成功、失败都会执行)
successfunction接口调用成功的回调函数
failfunction接口调用失败的回调函数

返回结果

  • success
属性类型说明
schemaarray产品信息,schema,功能定义都在里面
dpsanydps 设备的功能点状态,可以根据对应的 dpid 拿到具体的状态值去做业务逻辑
attributenumberattribute 产品属性定义,在 backend-ng 平台上可查到对应配置,使用二进制位运算的方式进行管理
capabilitynumbercapability 产品能力值,在 backend-ng 平台上可以查询对应的勾选项,整体业务逻辑会根据该数据进行划分 区分设备类型也可以根据该属性进行调整,按二进制位运算的方式进行管理
dpNameanydpName 自定义 dp 的名字,通常在面板里会使用到
abilitynumberability 目前业务很少使用,用于区分特殊类型的设备
iconstringicon 设备的 icon url
devIdstringdevId 设备的唯一 id
verSwstringverSw 设备固件版本号
isSharebooleanisShare 是否为分享设备,true 则是分享设备
bvstringbv 设备的基线版本号
uuidstringuuid 设备的固件唯一标识
panelConfiganypanelConfig 产品面板里的配置项,通常在 涂鸦开发者平台上可以查看到对应的配置
activeTimenumberactiveTime 设备激活时间,时间戳
devAttributenumberdevAttribute 设备的业务能力拓展,二进制位的方式进行运算
pccstringpcc Thing 自研蓝牙 mesh 产品的分类标识
nodeIdstringnodeId 子设备的短地址
parentIdstringparentId 上级节点 id,子设备/或蓝牙 mesh 设备通常会有该字段,用于内部寻找相关的网关或上级模型来进行业务处理
categorystringcategory 产品的分类
standSchemaModelobjectstandSchemaModel 标准产品功能集定义模型
productIdstringproductId 设备对应的产品 id
bizAttributenumberbizAttribute 设备自主上报的能力位
meshIdstringmeshId Thing 自研的蓝牙 mesh id
sigmeshIdstringsigmeshId 当前设备所属行业属性对应的蓝牙 mesh id
metaanymeta 设备自定义配置元属性,用于存放业务数据
isLocalOnlinebooleanisLocalOnline 本地局域网是否在线
isCloudOnlineboolean设备云端在线情况
isOnlinebooleanisOnline 设备总的在线情况,只要一个情况在线,就是在线,复合在线情况
namestringname 设备名称
groupIdstringgroupId
dpCodesanydpCodes 标准功能集 code
devTimezoneIdstring时区信息
dpsTimeany设备的功能点执行的时间
latitudestring设备纬度
longitudestring设备经度
ipstring设备 ip 地址
isVirtualDeviceboolean是否为虚拟设备
isZigbeeInstallCodebooleanzigbeeInstallCode to the cloud to mark the gateway with installation code ability

👉 立即免费领取开发资源,体验涂鸦 MiniApp 小程序开发。  

  • fail
属性类型说明
errorMsgstring插件错误信息
errorCodestring错误码
innerErrorobject插件外部依赖错误信息 {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 小程序开发。  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IoT砖家涂拉拉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值