setDeviceProperty疑问

小程序开发相关产品技术讨论,包括面板、智能小程序、React Native、Ray跨端框架、Panel SDK、微信小程序、小程序开发工具(IDE)及其他开发技术相关等话题


Post Reply
silverlight
Posts: 99

setDeviceProperty 这个api在开发文档说是设置设备属性,并且如果成功,会返回设备id和一个true。但实际使用时,只会返回一个“true”。并且不能修改实际设备的属性。但使用getDeviceProperty,可以得到{ "temp_current": "35"}。

想知道setDeviceProperty,是用于修改设备功能点的属性吗?其中“code()”是填设备的功能点吗?

Code: Select all

   setDeviceProperty({
      deviceId: `${devInfo.devId}`,
     code: 'temp_current',//设备的功能点
     value: '35', })
     .then((res) => {
       console.log(res);
     })
     .catch((error) => {
       console.log(error);
     });//设置设备属性

    getDeviceProperty({
      deviceId: `${devInfo.devId}`,
    })
      .then((res) => {
        console.log(res);
      })
      .catch((error) => {
        console.log(error);
      });//获取设备属性
Last edited by silverlight on 2024年 May 31日 17:01, edited 2 times in total.

Tags:
lshinylee
Posts: 253

Re: setDeviceProperty疑问

setDeviceProperty 和 getDeviceProperty 的作用是存储和获取自定义的设备属性,和设备的功能点是无关的,一些具体的场景比如说在照明的业务中,你可以存储当前照明设备当前的收藏颜色id之类的,但是一定要注意,设备存储的数据量是有限的,切勿超过256个字符。

:D :D :D

silverlight
Posts: 99

Re: setDeviceProperty疑问

lshinylee 2024年 May 31日 16:54

setDeviceProperty 和 getDeviceProperty 的作用是存储和获取自定义的设备属性,和设备的功能点是无关的,一些具体的场景比如说在照明的业务中,你可以存储当前照明设备当前的收藏颜色id之类的,但是一定要注意,设备存储的数据量是有限的,切勿超过256个字符。

谢谢,那开发文档中设备属性还有“saveDevProperty”以及{getDevProperty}。这一对有明确说明是自定义属性的设置与读取,功能有区别吗?

lshinylee
Posts: 253

Re: setDeviceProperty疑问

功能是一致的,只是入参可能不一样

:D :D :D

Post Reply