小程序开发——获取设备信息 API(一)

ty.device.getDeviceInfo

获取设备的设备信息

需引入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 产品面板里的配置项,通常在 IoT 平台上可以查看到对应的配置
activeTimenumberactiveTime 设备激活时间,时间戳
devAttributenumberdevAttribute 设备的业务能力拓展,二进制位的方式进行运算
pccstringpcc Thing 自研蓝牙 mesh 产品的分类标识
nodeIdstringnodeId 子设备的短地址
parentIdstringparentId 上级节点 id,子设备/或蓝牙 mesh 设备通常会有该字段,用于内部寻找相关的网关或上级模型来进行业务处理
categorystringcategory 产品的分类

standSchema

Model

objectstandSchemaModel 标准产品功能集定义模型
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是否为虚拟设备

isZigbeeInstall

Code

booleanzigbeeInstallCode to the cloud to mark the gateway with installation code ability
  • fail
属性类型说明
errorMsgstring插件错误信息
errorCodestring错误码
innerErrorobject插件外部依赖错误信息 {errorMsg: string, errorCode: string }

请求示例

ty.device.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": {}
}

👉 立即开发。 

ty.device.getDeviceListByDevIds

通过设备 id 队列获取设备的设备信息队列, 用于批量获取设备信息。

需引入DeviceKit,且在>=3.3.0 @ray-js/ray >= 0.9.0版本才可使用

请求参数

Object object

属性类型默认值必填说明
deviceIdsarraydeviceId 设备 ids
completefunction接口调用结束的回调函数(调用成功、失败都会执行)
successfunction接口调用成功的回调函数
failfunction接口调用失败的回调函数

返回结果

  • success
属性类型说明
deviceInfosArray<DeviceInfo>设备信息队列

DeviceInfo

属性类型说明
schemaarray产品信息,schema,功能定义都在里面
dpsanydps 设备的功能点状态,可以根据对应的 dpid 拿到具体的状态值去做业务逻辑
attributenumberattribute 产品属性定义,在 backend-ng 平台上可查到对应配置,使用二进制位运算的方式进行管理
capabilitynumbercapability 产品能力值,在 backend-ng 平台上可以查询对应的勾选项,整体业务逻辑会根据该数据进行划分 区分设备类型也可以根据该属性进行调整,按二进制位运算的方式进行管理
dpNameanydpName 自定义 dp 的名字,通常在面板里会使用到
abilitynumberability 目前业务很少使用,用于区分特殊类型的设备
iconstringicon 设备的 icon url
devIdstringdevId 设备的唯一 id
verSwstringverSw 设备固件版本号
isSharebooleanisShare 是否为分享设备,true 则是分享设备
bvstringbv 设备的基线版本号
uuidstringuuid 设备的固件唯一标识
panelConfiganypanelConfig 产品面板里的配置项,通常在 IoT 平台上可以查看到对应的配置
activeTimenumberactiveTime 设备激活时间,时间戳
devAttributenumberdevAttribute 设备的业务能力拓展,二进制位的方式进行运算
pccstringpcc Thing 自研蓝牙 mesh 产品的分类标识
nodeIdstringnodeId 子设备的短地址
parentIdstringparentId 上级节点 id,子设备/或蓝牙 mesh 设备通常会有该字段,用于内部寻找相关的网关或上级模型来进行业务处理
categorystringcategory 产品的分类

standSchema

Model

objectstandSchemaModel 标准产品功能集定义模型
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是否为虚拟设备

isZigbeeInstall

Code

booleanzigbeeInstallCode to the cloud to mark the gateway with installation code ability
  • fail
属性类型说明
errorMsgstring插件错误信息
errorCodestring错误码
innerErrorobject插件外部依赖错误信息 {errorMsg: string, errorCode: string }

请求示例

ty.device.getDeviceListByDevIds({
  deviceIds: ['64710761ecfabcaaf553', '6c87332fc414a65029ovfr'],
})
  .then((res) => {
    console.log(res);
  })
  .catch((error) => {
    console.log(error);
  });

返回示例

{
  "deviceInfos": [{
    "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": {}
  }, {
    "isGW": false,
    "latitude": "30.3028",
    "isVirtualDevice": false,
    "bluetoothCapability": "",
    "isSupportOTA": false,
    "dpsTime": {
      "1": 1603956864511,
      "2": 1603956864511,
      "3": 1603956864511,
      "4": 1603956864511,
      "5": 1603956864511,
      "6": 1603956864511,
      "7": 1603956864511,
      "8": 1603956864511,
      "9": 1603956864511,
      "10": 1603956864511,
      "11": 1603956864511,
      "12": 1603956864511,
      "13": 1603956864511,
      "101": 1684974921187,
      "102": 1684974921187,
      "103": 1684974921187,
      "104": 1684974921187,
      "105": 1603956864511
    },
    "baseAttribute": 0,
    "uuid": "6c87332fc414a65029ovfr",
    "configMetas": {},
    "ability": 0,
    "pcc": "",
    "iconUrl": "https://images.tuyacn.com/smart/icon/1538039048p03rjhzm8as_0.png",
    "longitude": "120.0632",
    "nodeId": "e922f00ac014e46b",
    "devTimezoneId": "Asia/Shanghai",
    "connectionStatus": 1,
    "capability": 8192,
    "dpName": {},
    "bizAttribute": 0,
    "isZigbeeInstallCode": false,
    "isLocalOnline": false,
    "attribute": 824634640768,
    "cadv": "",
    "devAttribute": 0,
    "isZigBeeSubDev": false,
    "switchDps": [],
    "dps": {
      "1": "send_ir",
      "3": "",
      "4": "",
      "5": "",
      "6": "",
      "10": 0,
      "11": "",
      "13": 0,
      "101": true,
      "102": "0",
      "103": 16,
      "104": "0",
      "105": false
    },
    "roomName": "",
    "devId": "6c87332fc414a65029ovfr",
    "dpCodes": {
      "windspeed": "0",
      "temp_set": 16,
      "switch": true,
      "mode": "0"
    },
    "name": "空调",
    "parentId": "vdevo160395678273817",
    "ip": "",
    "activeTime": 1603956864,
    "attributeString": "1100000000000000000011100000100110000000",
    "schema": [{
      "code": "control",
      "id": 1,
      "property": {
        "range": ["send_ir", "study", "study_exit", "study_key"],
        "type": "enum"
      },
      "name": "控制命令",
      "mode": "wr",
      "type": "obj"
    }, {
      "code": "study_code",
      "id": 2,
      "name": "学习编码",
      "mode": "ro",
      "type": "raw"
    }, {
      "code": "ir_code",
      "id": 3,
      "property": {
        "type": "string",
        "maxlen": 255
      },
      "name": "红外编码",
      "mode": "rw",
      "type": "obj"
    }, {
      "code": "key_code",
      "id": 4,
      "property": {
        "type": "string",
        "maxlen": 255
      },
      "name": "码库按键参数",
      "mode": "rw",
      "type": "obj"
    }, {
      "code": "key_code2",
      "id": 5,
      "property": {
        "type": "string",
        "maxlen": 255
      },
      "name": "码库按键参数2",
      "mode": "rw",
      "type": "obj"
    }, {
      "code": "key_code3",
      "id": 6,
      "property": {
        "type": "string",
        "maxlen": 255
      },
      "name": "码库按键参数3",
      "mode": "rw",
      "type": "obj"
    }, {
      "code": "key_study",
      "id": 7,
      "name": "来自学习参数下发",
      "mode": "rw",
      "type": "raw"
    }, {
      "code": "key_study2",
      "id": 8,
      "name": "来自学习参数下发2",
      "mode": "rw",
      "type": "raw"
    }, {
      "code": "key_study3",
      "id": 9,
      "name": "来自学习参数下发3",
      "mode": "rw",
      "type": "raw"
    }, {
      "code": "delay_time",
      "id": 10,
      "property": {
        "unit": "ms",
        "min": 0,
        "scale": 1,
        "step": 1,
        "type": "value",
        "max": 65535
      },
      "name": "红外码发送延时",
      "mode": "wr",
      "type": "obj"
    }, {
      "code": "key_code4",
      "id": 11,
      "property": {
        "type": "string",
        "maxlen": 255
      },
      "name": "新按键参数",
      "mode": "wr",
      "type": "obj"
    }, {
      "code": "key_study4",
      "id": 12,
      "name": "新学习参数",
      "mode": "wr",
      "type": "raw"
    }, {
      "code": "type",
      "id": 13,
      "property": {
        "unit": "",
        "min": 0,
        "scale": 1,
        "step": 1,
        "type": "value",
        "max": 255
      },
      "name": "码库标识",
      "mode": "rw",
      "type": "obj"
    }, {
      "code": "switch_power",
      "id": 101,
      "property": {
        "type": "bool"
      },
      "name": "开关",
      "mode": "wr",
      "type": "obj"
    }, {
      "code": "mode",
      "id": 102,
      "property": {
        "range": ["0", "1", "2", "3", "4"],
        "type": "enum"
      },
      "name": "工作模式",
      "mode": "rw",
      "type": "obj"
    }, {
      "code": "temperature",
      "id": 103,
      "property": {
        "unit": "",
        "min": 16,
        "scale": 0,
        "step": 1,
        "type": "value",
        "max": 30
      },
      "name": "温度",
      "mode": "wr",
      "type": "obj"
    }, {
      "code": "fan",
      "id": 104,
      "property": {
        "range": ["0", "1", "2", "3"],
        "type": "enum"
      },
      "name": "风量",
      "mode": "rw",
      "type": "obj"
    }, {
      "code": "swing",
      "id": 105,
      "property": {
        "type": "bool"
      },
      "name": "摆风",
      "mode": "wr",
      "type": "obj"
    }],
    "isMatter": false,
    "hasWifi": false,
    "category": "qt",
    "isOnline": true,
    "verSw": "1.0",
    "isSupportLink": true,
    "productId": "nr42aemawhabr9hu",
    "isShare": false,
    "switchDp": 0,
    "icon": "https://images.tuyacn.com/smart/icon/1538039048p03rjhzm8as_0.png",
    "isSupportAppleHomeKit": true,
    "isSupportGroup": true,
    "mac": "",
    "bv": "0",
    "isCloudOnline": true,
    "isTripartiteMatter": false,
    "wifiEnableState": 2,
    "protocolAttribute": 0
  }]
}

👉 立即开发。  

  • 58
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
好的,我会尽力回答你的问题。首先,获取用户位置需要在小程序中使用微信提供的API,具体步骤如下: 1. 引入API ``` // 在页面的JS文件中引入API const QQMapWX = require('../../utils/qqmap-wx-jssdk.min.js'); ``` 2. 初始化API ``` // 在页面的JS文件中初始化API const qqmapsdk = new QQMapWX({ key: '你的腾讯地图开发者密钥' }); ``` 3. 获取用户位置 ``` // 在页面的JS文件中获取用户位置 wx.getLocation({ type: 'gcj02', success(res) { const latitude = res.latitude; const longitude = res.longitude; qqmapsdk.reverseGeocoder({ location: { latitude, longitude }, success(res) { console.log(res); } }); }, fail(res) { console.log(res); } }); ``` 接下来是异常流处理的完整示例: ``` // 在页面的JS文件中引入API const QQMapWX = require('../../utils/qqmap-wx-jssdk.min.js'); // 在页面的JS文件中初始化API const qqmapsdk = new QQMapWX({ key: '你的腾讯地图开发者密钥' }); // 在页面的JS文件中获取用户位置 wx.getLocation({ type: 'gcj02', success(res) { const latitude = res.latitude; const longitude = res.longitude; qqmapsdk.reverseGeocoder({ location: { latitude, longitude }, success(res) { console.log(res); }, fail(res) { console.log(res); wx.showToast({ title: '获取位置失败', icon: 'none' }); } }); }, fail(res) { console.log(res); wx.showModal({ title: '提示', content: '获取位置失败,请检查是否开启定位权限', showCancel: false, confirmText: '知道了' }); } }); ``` 在这个示例中,我们通过`wx.getLocation`方法获取用户位置,并且使用`qqmapsdk.reverseGeocoder`方法将经纬度转换为详细地址信息。如果获取位置或转换地址信息失败,我们会使用`wx.showToast`或`wx.showModal`方法提醒用户。这就是异常流处理的完整示例。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

IoT砖家涂拉拉

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

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

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

打赏作者

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

抵扣说明:

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

余额充值