npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@quec-wx-mp/api-smart-home

v1.0.0

Published

智能家居模式

Readme

家居模式

智能家居模块,提供家居模式、家庭、房间、家庭成员和设备信息管理等 API。

安装

npm install @quec-wx-mp/api-smart-home
import smartHome from '@quec-wx-mp/api-smart-home'
const plugin = requirePlugin('quecPlugin')

plugin.use(smartHome)

API 列表

| API | 说明 | | ------------------------ | -------------------- | | enabledAutoSwitch | 启用停用自动切换 | | enabledFamilyMode | 启用停用家居模式 | | getFamilyModeConfig | 查询用户家居模式配置 | | getFamilyList | 查询家庭列表 | | addFamily | 创建家庭 | | deleteFamily | 删除家庭 | | getCurrentFamily | 查询当前家庭 | | getFamilyDeviceList | 查询家庭设备列表 | | setFamily | 修改家庭 | | getFamilyRoomList | 查询家庭房间列表 | | getFamilyRoomDeviceList | 查询房间设备列表 | | addFamilyRoom | 创建房间 | | setFamilyRoom | 修改房间 | | deleteFamilyRoom | 删除房间 | | setFamilyRoomSort | 设置房间排序 | | getCommonUsedDeviceList | 查询常用设备列表 | | addCommonUsedDevice | 添加常用设备 | | deleteCommonUsedDevice | 移除常用设备 | | deleteFamilyMember | 移除家庭成员 | | familyMemberInviteHandle | 处理家庭邀请 | | getFamilyInviteList | 查询被邀请列表 | | getFamilyMemberList | 查询家庭成员列表 | | inviteFamilyMember | 邀请家庭成员 | | leaveFamily | 离开家庭 | | setFamilyMemberName | 修改家庭成员名称 | | setFamilyMemberRole | 设置家庭成员角色 | | addDeviceInFamilyRoom | 移入设备到房间 | | setDeviceInfo | 设置设备信息 |


API 详细说明

1) 启用停用自动切换

接口名称

enabledAutoSwitch

功能描述

启用或停用家居模式自动切换。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | -------- | ------ | ---- | --------------------- | | enabled | boolean | - | 是 | true 启用,false 停用 | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应。

示例代码

plugin.smartHome.enabledAutoSwitch({
  enabled: true,
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

2) 启用停用家居模式

接口名称

enabledFamilyMode

功能描述

启用或停用家居模式。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | -------- | ------ | ---- | --------------------- | | enabled | boolean | - | 是 | true 启用,false 停用 | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应。

示例代码

plugin.smartHome.enabledFamilyMode({
  enabled: true,
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

3) 查询用户家居模式配置

接口名称

getFamilyModeConfig

功能描述

查询当前用户的家居模式配置。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | -------- | ------ | ---- | -------- | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应,res.data 为家居模式配置。

示例代码

plugin.smartHome.getFamilyModeConfig({
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

4) 查询家庭列表

接口名称

getFamilyList

功能描述

分页查询家庭列表。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | -------- | ------ | ---- | -------------------------------------------------------- | | page | number | - | 是 | 当前页 | | pageSize | number | - | 是 | 页大小 | | role | string | - | 是 | 成员角色,多个逗号分隔(1 创建者,2 管理员,3 普通成员) | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应,res.data 为家庭分页列表。

示例代码

plugin.smartHome.getFamilyList({
  page: 1,
  pageSize: 10,
  role: '1,2,3',
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

5) 创建家庭

接口名称

addFamily

功能描述

创建一个家庭。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | ----------------- | -------- | ------ | ---- | ---------- | | familyName | string | - | 是 | 家庭名称 | | familyCoordinates | string | - | 是 | 家庭经纬度 | | familyLocation | string | - | 是 | 家庭位置 | | familyRoomList | array | - | 是 | 房间列表 | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应,res.data 为创建结果。

示例代码

plugin.smartHome.addFamily({
  familyName: '我的家',
  familyCoordinates: '116.403,39.914',
  familyLocation: '北京',
  familyRoomList: [{ roomName: '客厅' }],
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

6) 删除家庭

接口名称

deleteFamily

功能描述

根据家庭 ID 删除家庭。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | -------- | ------ | ---- | -------- | | fid | string | - | 是 | 家庭 ID | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应。

示例代码

plugin.smartHome.deleteFamily({
  fid: 'fid_xxx',
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

7) 查询当前家庭

接口名称

getCurrentFamily

功能描述

根据可选的家庭 ID 或当前位置查询当前家庭。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | ------------------ | -------- | ------ | ---- | ---------- | | fid | string | - | 否 | 家庭 ID | | currentCoordinates | string | - | 否 | 当前经纬度 | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应,res.data 为当前家庭信息。

示例代码

plugin.smartHome.getCurrentFamily({
  currentCoordinates: '116.403,39.914',
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

8) 查询家庭设备列表

接口名称

getFamilyDeviceList

功能描述

分页查询家庭中的设备列表。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | ---------------- | -------- | ------ | ---- | ------------------------------ | | fid | string | - | 是 | 家庭 ID | | deviceName | string | - | 是 | 设备名称 | | isAddOwnerDevice | boolean | - | 是 | 是否附加返回用户自己的所有设备 | | page | number | - | 是 | 当前页 | | pageSize | number | - | 是 | 页大小 | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应,res.data 为设备分页列表。

示例代码

plugin.smartHome.getFamilyDeviceList({
  fid: 'fid_xxx',
  deviceName: '',
  isAddOwnerDevice: false,
  page: 1,
  pageSize: 10,
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

9) 修改家庭

接口名称

setFamily

功能描述

修改家庭基础信息。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | ----------------- | -------- | ------ | ---- | ---------- | | fid | string | - | 是 | 家庭 ID | | familyName | string | - | 是 | 家庭名称 | | familyLocation | string | - | 是 | 家庭地址 | | familyCoordinates | string | - | 是 | 家庭经纬度 | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应。

示例代码

plugin.smartHome.setFamily({
  fid: 'fid_xxx',
  familyName: '新家庭名称',
  familyLocation: '上海',
  familyCoordinates: '121.473,31.230',
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

10) 查询家庭房间列表

接口名称

getFamilyRoomList

功能描述

分页查询家庭中的房间列表。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | -------- | ------ | ---- | -------- | | fid | string | - | 是 | 家庭 ID | | page | number | - | 是 | 当前页 | | pageSize | number | - | 是 | 页大小 | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应,res.data 为房间分页列表。

示例代码

plugin.smartHome.getFamilyRoomList({
  fid: 'fid_xxx',
  page: 1,
  pageSize: 10,
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

11) 查询房间设备列表

接口名称

getFamilyRoomDeviceList

功能描述

分页查询房间中的设备列表。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | -------- | ------ | ---- | -------- | | frid | string | - | 是 | 房间 ID | | page | number | - | 是 | 当前页 | | pageSize | number | - | 是 | 页大小 | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应,res.data 为设备分页列表。

示例代码

plugin.smartHome.getFamilyRoomDeviceList({
  frid: 'frid_xxx',
  page: 1,
  pageSize: 10,
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

12) 查询常用设备列表

接口名称

getCommonUsedDeviceList

功能描述

分页查询家庭常用设备列表。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | -------- | ------ | ---- | -------- | | fid | string | - | 是 | 家庭 ID | | page | number | - | 是 | 当前页 | | pageSize | number | - | 是 | 页大小 | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应,res.data 为常用设备分页列表。

示例代码

plugin.smartHome.getCommonUsedDeviceList({
  fid: 'fid_xxx',
  page: 1,
  pageSize: 10,
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

13) 添加常用设备

接口名称

addCommonUsedDevice

功能描述

批量添加设备到家庭常用设备列表。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | ---------- | -------- | ------ | ---- | ------------------------------------ | | fid | string | - | 是 | 家庭 ID | | deviceList | array | - | 是 | 设备列表,元素结构:{ dk, pk, type } | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应。

示例代码

plugin.smartHome.addCommonUsedDevice({
  fid: 'fid_xxx',
  deviceList: [{ dk: 'device_key', pk: 'product_key', type: 1 }],
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

14) 移除常用设备

接口名称

deleteCommonUsedDevice

功能描述

批量移除家庭常用设备。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | ---------- | -------- | ------ | ---- | ------------------------------------ | | fid | string | - | 是 | 家庭 ID | | deviceList | array | - | 是 | 设备列表,元素结构:{ dk, pk, type } | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应。

示例代码

plugin.smartHome.deleteCommonUsedDevice({
  fid: 'fid_xxx',
  deviceList: [{ dk: 'device_key', pk: 'product_key', type: 1 }],
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

15) 创建房间

接口名称

addFamilyRoom

功能描述

在家庭下创建房间。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | -------- | ------ | ---- | -------- | | fid | string | - | 是 | 家庭 ID | | roomName | string | - | 是 | 房间名称 | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应。

示例代码

plugin.smartHome.addFamilyRoom({
  fid: 'fid_xxx',
  roomName: '主卧',
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

16) 修改房间

接口名称

setFamilyRoom

功能描述

修改房间名称。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | -------- | ------ | ---- | -------- | | frid | string | - | 是 | 房间 ID | | roomName | string | - | 是 | 房间名称 | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应。

示例代码

plugin.smartHome.setFamilyRoom({
  frid: 'frid_xxx',
  roomName: '次卧',
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

17) 删除房间

接口名称

deleteFamilyRoom

功能描述

按房间 ID 列表批量删除房间。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | -------- | ------ | ---- | ------------ | | fridList | string[] | - | 是 | 房间 ID 列表 | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应。

示例代码

plugin.smartHome.deleteFamilyRoom({
  fridList: ['frid_1', 'frid_2'],
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

18) 设置房间排序

接口名称

setFamilyRoomSort

功能描述

批量设置家庭房间排序。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | ------------ | -------- | ------ | ---- | ------------------------------------------ | | roomSortList | array | - | 是 | 房间排序列表,元素结构:{ frid, roomSort } | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应。

示例代码

plugin.smartHome.setFamilyRoomSort({
  roomSortList: [{ frid: 'frid_1', roomSort: 1 }],
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

19) 移除家庭成员

接口名称

deleteFamilyMember

功能描述

移除家庭中的指定成员。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | --------- | -------- | ------ | ---- | --------------- | | fid | string | - | 是 | 家庭 ID | | memberUid | string | - | 是 | 家庭成员用户 ID | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应。

示例代码

plugin.smartHome.deleteFamilyMember({
  fid: 'fid_xxx',
  memberUid: 'uid_xxx',
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

20) 处理家庭邀请

接口名称

familyMemberInviteHandle

功能描述

处理家庭邀请(同意或拒绝)。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | -------- | ------ | ---- | -------------------------- | | fid | string | - | 是 | 家庭 ID | | decide | number | - | 是 | 处理结果(0 拒绝,1 同意) | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应。

示例代码

plugin.smartHome.familyMemberInviteHandle({
  fid: 'fid_xxx',
  decide: 1,
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

21) 查询被邀请列表

接口名称

getFamilyInviteList

功能描述

分页查询用户收到的家庭邀请列表。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | -------- | ------ | ---- | -------- | | page | number | - | 是 | 当前页 | | pageSize | string | - | 是 | 页大小 | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应,res.data 为邀请分页列表。

示例代码

plugin.smartHome.getFamilyInviteList({
  page: 1,
  pageSize: '10',
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

22) 查询家庭成员列表

接口名称

getFamilyMemberList

功能描述

分页查询家庭中的成员列表。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | -------- | ------ | ---- | -------- | | fid | string | - | 是 | 家庭 ID | | page | number | - | 是 | 当前页 | | pageSize | string | - | 是 | 页大小 | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应,res.data 为成员分页列表。

示例代码

plugin.smartHome.getFamilyMemberList({
  fid: 'fid_xxx',
  page: 1,
  pageSize: '10',
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

23) 邀请家庭成员

接口名称

inviteFamilyMember

功能描述

邀请成员加入家庭,account 支持手机号或邮箱。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | ----------- | -------- | ------ | ---- | -------------------------- | | fid | string | - | 是 | 家庭 ID | | invalidTime | number | - | 是 | 邀请失效时间(毫秒时间戳) | | memberName | string | - | 是 | 成员名称 | | memberRole | number | - | 是 | 成员角色 | | account | string | - | 是 | 被邀请人手机号或邮箱 | | uid | string | - | 否 | 被邀请人 uid | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应。

示例代码

plugin.smartHome.inviteFamilyMember({
  fid: 'fid_xxx',
  invalidTime: Date.now() + 3600 * 1000,
  memberName: '张三',
  memberRole: 3,
  account: '13800000000',
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

24) 离开家庭

接口名称

leaveFamily

功能描述

当前成员主动离开家庭。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | -------- | ------ | ---- | -------- | | fid | string | - | 是 | 家庭 ID | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应。

示例代码

plugin.smartHome.leaveFamily({
  fid: 'fid_xxx',
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

25) 修改家庭成员名称

接口名称

setFamilyMemberName

功能描述

修改家庭成员显示名称。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | ---------- | -------- | ------ | ---- | --------------- | | fid | string | - | 是 | 家庭 ID | | memberName | string | - | 是 | 家庭成员名称 | | memberUid | string | - | 是 | 家庭成员用户 ID | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应。

示例代码

plugin.smartHome.setFamilyMemberName({
  fid: 'fid_xxx',
  memberName: '李四',
  memberUid: 'uid_xxx',
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

26) 设置家庭成员角色

接口名称

setFamilyMemberRole

功能描述

设置家庭成员角色。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | ---------- | -------- | ------ | ---- | --------------- | | fid | string | - | 是 | 家庭 ID | | memberRole | number | - | 是 | 角色值 | | memberUid | string | - | 是 | 家庭成员用户 ID | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应。

示例代码

plugin.smartHome.setFamilyMemberRole({
  fid: 'fid_xxx',
  memberRole: 2,
  memberUid: 'uid_xxx',
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

27) 移入设备到房间

接口名称

addDeviceInFamilyRoom

功能描述

批量将设备移入指定房间。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | ------------------------- | ------ | ---- | -------------------- | | arr | SmartHomeDeviceAddition[] | - | 是 | 设备房间迁移参数列表 | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

arr 元素字段说明:

| 字段 | 类型 | 必填 | 说明 | | ------- | ------ | ---- | ------------------------- | | pk | string | 是 | 产品 ProductKey | | dk | string | 是 | 设备 DeviceKey | | newFrid | string | 是 | 新房间 ID | | oldFrid | string | 是 | 原房间 ID(可为空字符串) |

返回数据

  • success(res):接口成功响应。

示例代码

plugin.smartHome.addDeviceInFamilyRoom({
  arr: [
    {
      pk: 'product_key',
      dk: 'device_key',
      newFrid: 'new_frid',
      oldFrid: 'old_frid'
    }
  ],
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

28) 设置设备信息

接口名称

setDeviceInfo

功能描述

批量设置设备信息(如名称、常用状态、房间归属等)。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | --------------------- | ------ | ---- | ---------------- | | param | SmartHomeDeviceInfo[] | - | 是 | 设备信息参数列表 | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

param 元素字段说明:

| 字段 | 类型 | 必填 | 说明 | | ------------ | ------- | ---- | ------------------------------------------------------ | | pk | string | 是 | 产品 ProductKey | | dk | string | 是 | 设备 DeviceKey | | deviceName | string | 是 | 设备名称 | | fid | string | 是 | 家庭 ID | | isCommonUsed | boolean | 是 | 是否常用 | | newFrid | string | 是 | 新房间 ID | | oldFrid | string | 是 | 原房间 ID(可为空字符串) | | shareCode | string | 是 | 分享码(修改接受分享设备名称时必填) | | type | number | 是 | 设备类型(1 单绑真绑,2 接收分享设备,3 多绑伪绑设备) |

返回数据

  • success(res):接口成功响应。

示例代码

plugin.smartHome.setDeviceInfo({
  param: [
    {
      pk: 'product_key',
      dk: 'device_key',
      deviceName: '客厅灯',
      fid: 'fid_xxx',
      isCommonUsed: true,
      newFrid: 'frid_xxx',
      oldFrid: '',
      shareCode: '',
      type: 1
    }
  ],
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})