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-auto

v1.0.0

Published

小程序插件 自动化

Readme

自动化

自动化模块,提供自动化配置查询、创建、编辑、删除、启停、测试和日志管理等 API。

安装

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

plugin.use(auto)

API 列表

| 方法 | 说明 | | ----------------- | -------------------- | | autoPublish | 获取自动化物模型配置 | | autoSave | 创建自动化 | | autoEdit | 编辑自动化 | | autoDel | 删除自动化 | | autoDetail | 查询自动化详情 | | autoList | 查询自动化列表 | | autoStatus | 启停自动化 | | autoTest | 测试自动化 | | getTestAutomation | 查询自动化测试结果 | | autoLogList | 查询自动化日志列表 | | autoLogDetail | 查询自动化日志详情 | | autoClear | 清除自动化日志 |


API 详细说明

1) 获取自动化物模型配置

接口名称

autoPublish

功能描述

获取自动化联动配置(条件/动作物模型配置)。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | ---------- | -------- | ------ | ---- | ---------------------------------- | | productKey | string | - | 是 | 产品 ProductKey | | type | number | 0 | 否 | 查询类型(0 全部,1 条件,2 动作) | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应,res.data 为自动化物模型配置。

示例代码

plugin.auto.autoPublish({
  productKey: 'product_key',
  type: 0,
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

2) 创建自动化

接口名称

autoSave

功能描述

创建自动化规则。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | ------------- | -------- | ------ | ---- | ---------------------------------- | | fid | string | - | 否 | 家庭 ID,开启家居模式时传入 | | conditionType | number | - | 是 | 触发类型(1 满足任意,2 满足所有) | | icon | string | '' | 是 | 自动化图标 | | name | string | - | 是 | 自动化名称 | | nameType | number | - | 是 | 名称类型(1 默认生成,2 用户填写) | | conditions | array | - | 是 | 触发条件数组 | | actions | array | - | 是 | 执行动作数组 | | precondition | object | - | 否 | 生效时间条件 | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

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

示例代码

plugin.auto.autoSave({
  fid: 'family_id',
  conditionType: 1,
  icon: 'auto_icon',
  name: '自动化示例',
  nameType: 2,
  conditions: [
    {
      type: 1,
      timer: {
        type: 1,
        time: '08:00',
        timeZone: 'GMT+08:00'
      },
      sort: 1
    }
  ],
  actions: [
    {
      type: 2,
      productKey: 'product_key',
      deviceKey: 'device_key',
      sort: 1,
      property: {
        id: 1,
        code: 'switch',
        name: '开关',
        dataType: 'BOOL',
        value: true
      }
    }
  ],
  precondition: {
    effectDateType: 0,
    effectTimeType: 2,
    timeZone: 'GMT+08:00'
  },
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

3) 编辑自动化

接口名称

autoEdit

功能描述

编辑已有自动化规则。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | ------------- | -------- | ------ | ---- | ---------------------------------- | | fid | string | - | 否 | 家庭 ID,开启家居模式时传入 | | automationId | number | - | 是 | 自动化 ID | | conditionType | number | - | 是 | 触发类型(1 满足任意,2 满足所有) | | icon | string | - | 是 | 自动化图标 | | name | string | - | 是 | 自动化名称 | | nameType | number | - | 是 | 名称类型(1 默认生成,2 用户填写) | | conditions | array | - | 是 | 触发条件数组 | | actions | array | - | 是 | 执行动作数组 | | precondition | object | - | 否 | 生效时间条件 | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

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

示例代码

plugin.auto.autoEdit({
  fid: 'family_id',
  automationId: 1001,
  conditionType: 2,
  icon: 'auto_icon',
  name: '离家自动化',
  nameType: 2,
  conditions: [],
  actions: [],
  precondition: {},
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

4) 删除自动化

接口名称

autoDel

功能描述

根据 automationId 删除自动化。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | ------------ | -------- | ------ | ---- | --------------------------- | | fid | string | - | 否 | 家庭 ID,开启家居模式时传入 | | automationId | number | - | 是 | 自动化 ID | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

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

示例代码

plugin.auto.autoDel({
  fid: 'family_id',
  automationId: 1001,
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

5) 查询自动化详情

接口名称

autoDetail

功能描述

根据 automationId 查询自动化详情。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | ------------ | -------- | ------ | ---- | --------------------------- | | fid | string | - | 否 | 家庭 ID,开启家居模式时传入 | | automationId | number | - | 是 | 自动化 ID | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应,res.data 为自动化详情。

示例代码

plugin.auto.autoDetail({
  fid: 'family_id',
  automationId: 1001,
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

6) 查询自动化列表

接口名称

autoList

功能描述

分页查询自动化列表。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | -------- | ------ | ---- | --------------------------- | | fid | string | - | 否 | 家庭 ID,开启家居模式时传入 | | page | number | 1 | 是 | 页码 | | pageSize | number | 10 | 是 | 每页条数 | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

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

示例代码

plugin.auto.autoList({
  fid: 'family_id',
  page: 1,
  pageSize: 10,
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

7) 启停自动化

接口名称

autoStatus

功能描述

开启或关闭自动化。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | ------------ | -------- | ------ | ---- | --------------------------------- | | automationId | number | - | 是 | 自动化 ID | | status | boolean | - | 是 | 启停状态(true 启用,false 停用) | | fid | string | - | 否 | 家庭 ID,开启家居模式时传入 | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

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

示例代码

plugin.auto.autoStatus({
  automationId: 1001,
  status: true,
  fid: 'family_id',
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

8) 测试自动化

接口名称

autoTest

功能描述

测试自动化动作执行。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | -------- | ------ | ---- | --------------------------- | | fid | string | - | 否 | 家庭 ID,开启家居模式时传入 | | timeout | number | 120 | 否 | 测试超时时间(秒) | | actions | array | - | 是 | 执行动作数组 | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应,res.data 通常包含 testResultId。

示例代码

plugin.auto.autoTest({
  fid: 'family_id',
  timeout: 120,
  actions: [
    {
      type: 2,
      productKey: 'product_key',
      deviceKey: 'device_key',
      sort: 1,
      property: {
        id: 1,
        code: 'switch',
        name: '开关',
        dataType: 'BOOL',
        value: true
      }
    }
  ],
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

9) 查询自动化测试结果

接口名称

getTestAutomation

功能描述

根据 testResultId 轮询获取自动化测试结果。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | ------------ | -------- | ------ | ---- | ----------------- | | testResultId | string | - | 是 | 自动化测试结果 ID | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应,res.data 为测试结果状态。

示例代码

plugin.auto.getTestAutomation({
  testResultId: 'test_result_id',
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

10) 查询自动化日志列表

接口名称

autoLogList

功能描述

分页查询自动化日志列表。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | --------- | -------- | ------ | ---- | --------------------------- | | fid | string | - | 否 | 家庭 ID,开启家居模式时传入 | | lastLogId | string | - | 是 | 分页最后一条日志 ID | | limit | number | 10 | 是 | 每页条数 | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应,res.data 为日志列表。

示例代码

plugin.auto.autoLogList({
  fid: 'family_id',
  lastLogId: '1000',
  limit: 10,
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

11) 查询自动化日志详情

接口名称

autoLogDetail

功能描述

根据日志 ID 查询自动化日志详情。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | -------- | ------ | ---- | --------------------------- | | fid | string | - | 否 | 家庭 ID,开启家居模式时传入 | | logId | string | - | 是 | 日志 ID | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应,res.data 为日志详情。

示例代码

plugin.auto.autoLogDetail({
  fid: 'family_id',
  logId: '1001',
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

12) 清除自动化日志

接口名称

autoClear

功能描述

清除自动化日志。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | -------- | ------ | ---- | --------------------------- | | fid | string | - | 否 | 家庭 ID,开启家居模式时传入 | | success | function | - | 是 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

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

示例代码

plugin.auto.autoClear({
  fid: 'family_id',
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})