智能小程序 Ray 开发设备控制 API —— DP相关 API 合集(一)

updateDpName

更新设备 DP 名称。

引入

import { updateDpName } from '@ray-js/ray';

请求参数

参数数据类型说明是否必填
devIdString设备 ID
dpIdStringDP ID
nameStringDP 自定义名称

返回参数

  • success

Boolean boolean

  • fail
属性类型说明
errorMsgstring插件错误信息
errorCodestring错误码
innerErrorobject插件外部依赖错误信息 {errorMsg: string, errorCode: string }

请求示例

import { updateDpName } from '@ray-js/ray';
 
updateDpName({
  devId: 'vdevo169477319679442',
  dpId: '21',
  name: 'work_mode',
})
  .then((res) => {
    console.log(res);
  })
  .catch(error => {
    console.log(error);
  });

返回示例

true

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

getDpsInfos

获取设备所有 DP 信息。

引入

import { getDpsInfos } from '@ray-js/ray';

请求参数

参数数据类型说明是否必填
devIdString设备 ID
gwIdString网关 ID, 直连设备值同 devId,子设备则传网关的设备id

返回结果

  • success

Array<dpInfo>

dpInfo

参数数据类型说明
codeStringDP Code
dpIdNumberDP ID
valueStringDP 值
timeNumberDP 最近上报时间
typeStringDP 类型

fail

属性类型说明
errorMsgstring插件错误信息
errorCodestring错误码
innerErrorobject插件外部依赖错误信息 {errorMsg: string, errorCode: string }

请求示例

import { getDpsInfos } from '@ray-js/ray';
 
getDpsInfos({
  devId: 'vdevo169477319679442',
  gwId: 'vdevo169477319679442',
})
  .then(res => {
    console.log(res);
  })
  .catch(error => {
    console.log(error);
  });

返回示例

[{
  "dpId": 1,
  "value": "false",
  "code": "switch_led",
  "type": "bool",
  "time": 1695016796840
}, {
  "dpId": 2,
  "value": "white",
  "code": "work_mode",
  "type": "enum",
  "time": 1695016736328
}, {
  "dpId": 3,
  "value": "327",
  "code": "bright_value",
  "type": "value",
  "time": 1695005906565
}, {
  "dpId": 4,
  "value": "0",
  "code": "temp_value",
  "type": "value",
  "time": 1694773196845
}, {
  "dpId": 5,
  "value": "002600000000",
  "code": "colour_data",
  "type": "string",
  "time": 1695016233353
}, {
  "dpId": 6,
  "value": "",
  "code": "scene_data",
  "type": "string",
  "time": 1694773196845
}, {
  "dpId": 7,
  "value": "0",
  "code": "countdown",
  "type": "value",
  "time": 1694773196845
}, {
  "dpId": 8,
  "value": "",
  "code": "music_data",
  "type": "string",
  "time": 1694773196845
}, {
  "dpId": 30,
  "code": "rhythm_mode",
  "type": "raw",
  "time": 1694773196845
}, {
  "dpId": 31,
  "code": "sleep_mode",
  "type": "raw",
  "time": 1694773196845
}, {
  "dpId": 32,
  "code": "wakeup_mode",
  "type": "raw",
  "time": 1694773196845
}, {
  "dpId": 33,
  "code": "power_memory",
  "type": "raw",
  "time": 1694773196845
}, {
  "dpId": 34,
  "value": "false",
  "code": "do_not_disturb",
  "type": "bool",
  "time": 1694773196845
}, {
  "dpId": 35,
  "code": "switch_gradient",
  "type": "raw",
  "time": 1694773196845
}, {
  "dpId": 37,
  "code": "rtc_timer",
  "type": "raw",
  "time": 1694773196845
}, {
  "dpId": 38,
  "code": "timer_report",
  "type": "raw",
  "time": 1694773196845
}, {
  "dpId": 210,
  "code": "random_timing",
  "type": "raw",
  "time": 1694773196845
}]

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

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

IoT砖家涂拉拉

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

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

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

打赏作者

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

抵扣说明:

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

余额充值