getMeshDeviceId
通过 nodeId 获取子设备的设备 Id
引入
import { device } from '@ray-js/ray';
const { getMeshDeviceId } = device;
需引入
DeviceKit
,且在>=2.4.0
版本才可使用
请求参数
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
nodeId | string | 是 | nodeId | |
deviceId | string | 是 | deviceId 网关 id | |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
success | function | 否 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 |
返回结果
- success
属性 | 类型 | 说明 |
---|---|---|
deviceId | string | 设备 id |
- fail
属性 | 类型 | 说明 |
---|---|---|
errorMsg | string | 插件错误信息 |
errorCode | string | 错误码 |
innerError | object | 插件外部依赖错误信息 {errorMsg: string, errorCode: string } |
请求示例
getMeshDeviceId({
nodeId: 'e922f00ac014e46b',
deviceId: '64710761ecfabcaaf553',
})
.then((res) => {
console.log(res);
})
.catch((error) => {
console.log(error);
});
返回示例
{
"deviceId": "6c87332fc414a65029ovfr"
}
👉 立即免费领取开发资源,体验涂鸦 MiniApp 小程序开发。
onDeviceInfoUpdated
设备 dp 名字和设备名字更新时触发
引入
import { device } from '@ray-js/ray';
const { onDeviceInfoUpdated } = device;
需引入
DeviceKit
,且在>=1.2.6
版本才可使用
请求参数
Function Callback
设备 dp 名字和设备名字更新时触发的回调函数
返回结果
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
deviceId | string | 是 | deviceId 设备 id 支持跨面板获取其他的设备信息,当前面板可以传当前设备的 id 来进行获取 | |
dps | Object | 否 | dps |
请求示例
onDeviceInfoUpdated((res) => {
console.log(res);
})
返回示例
{
"dps": {
"1": false,
"9": 0,
"38": "off",
"40": "relay",
"42": "",
"43": "",
"44": "invalid"
},
"deviceId": "vdevo167878067815995"
}
offDeviceInfoUpdated
取消监听:设备 dp 名字和设备名字更新时触发
引入
import { device } from '@ray-js/ray';
const { offDeviceInfoUpdated } = device;
需引入
DeviceKit
,且在>=2.1.6
版本才可使用
请求参数
Function Callback
取消监听:设备 dp 名字和设备名字更新时触发的回调函数
返回结果
无
请求示例
offDeviceInfoUpdated(() => {});
onDeviceOnlineStatusUpdate
设备上下线状态变更
引入
import { device } from '@ray-js/ray';
const { onDeviceOnlineStatusUpdate } = device;
需引入
DeviceKit
,且在>=1.2.6
版本才可使用
请求参数
Function Callback
设备上下线状态变更的回调函数
回调结果
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
online | boolean | 是 | 在线状态 | |
deviceId | string | 是 | 设备 id | |
online Type | number | 否 | 设备在线类型(预留,后期使用) Wi-Fi online 1 << 0 Local online 1 << 1 Bluetooth LE online 1 << 2 Bluetooth LE mesh online 1 << 3 |
请求示例
onDeviceOnlineStatusUpdate((res) => {
console.log(res);
})
返回示例
{
"online": true,
"deviceId": "vdevo167878067815995"
}
offDeviceOnlineStatusUpdate
取消监听:设备上下线状态变更
引入
import { offDeviceOnlineStatusUpdate } from '@ray-js/ray';
需引入
DeviceKit
,且在>=2.1.6
版本才可使用
参数
function callback
取消监听:设备上下线状态变更的回调函数
回调参数 Object res
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
online | boolean | 是 | 在线状态 | |
deviceId | string | 是 | 设备 id | |
online Type | number | 是 | 设备在线类型(预留,后期使用) Wi-Fi online 1 << 0 Local online 1 << 1 Bluetooth LE online 1 << 2 Bluetooth LE mesh online 1 << 3 |
👉 立即免费领取开发资源,体验涂鸦 MiniApp 小程序开发。