Scene Plugin

Last Updated on : 2024-06-21 08:47:48download

You can integrate Scene into your WeChat mini program as a plug-in without additional development. This plug-in provides the scene linkage feature for your WeChat mini program. You only need to pass in parameters to implement scene linkage between smart devices within Tuya’s ecosystem.

Linkage types

The Scene plug-in supports the linkage settings for basic automation features, such as device management, weather, timing, and delay.

Procedure

Step 1: Create WeChat mini program project

Follow the instructions in Plug-In to create a WeChat mini program and request permissions to use the Scene plug-in.

Step 2: Configure plug-in

Add plug-in settings to app.json of your project.

plugins: {
  'tuya-auto-plugin': {
    version: '1.2.1',
    provider: 'wx5dc916a9f79dc41f'
  }
}

Step 3: Access the plug-in

Add the JavaScript code block for navigation to the plug-in:

wx.navigateTo({
  url: `plugin://tuya-auto-plugin/autoHome?ticket=${ticket}&client_id=${client_id}`,
});

The navigation path includes the following parameters:

Parameter name Type Required Description
client_id string Yes The third-party unique identifier. It matches the value of AccessID for the WeChat Mini Program SDK on the Tuya Developer Platform.
ticket String Yes The pairing token. For more information about how to get the token, see User Management.
home_id String No The home ID. A device must be bound with a home. For more information about how to get the home ID, see Home Management.

Step 4: Get plug-in and home_id

  const autoPlugin = requirePlugin('tuya-auto-plugin')
  const currentAutoHomeId = autoPlugin.getHomeId()

Demo

You can download the demo and get started quickly with the Scene plug-in.