English
English
简体中文
Contact Us
Register
Log In
layoutIndex

RF Remote Control Template

Last Updated on : 2022-03-01 07:55:03download

This topic describes the specific features of the radio frequency (RF) remote control template and how to use this template. For more resources, see the GitHub repository.

Overview

This RF remote control template project applies to Powered by Tuya (PBT) RF remote control panels and supports the following features:

  • Control RF devices
  • Pair RF sub-devices
  • Customize learning of RF sub-devices
  • Delete and rename sub-devices

Directories

rfRemote
├─ src
│  ├─ api
│  │  └─ index.ts // Includes multiple types of cloud API operations that are used to run the project.
│  ├─ components
│  │  ├─ BrandItem.tsx // The component of category items.
│  │  ├─ CopyGuide.tsx  // The component that prompts users to restart learning by tapping a button.
│  │  ├─ DeviceItem.tsx // The component of a device list.
│  │  ├─ LearnTip.tsx // The component of the custom learning prompt.
│  │  ├─ LetterSearch.tsx // The component to search brands by letters.
│  │  ├─ MaskView.tsx // The mask component.
│  │  ├─ MoreKeys.tsx // The More button component.
│  │  ├─ MorePress.tsx // The component of tapping the More button.
│  │  ├─ PercentageToast.tsx // The progress percentage component.
│  │  ├─ SearchInput.tsx // The brand search box component.
│  │  ├─ SectionTitle.tsx // The component of the brand name list.
│  │  ├─ TopBar.tsx // The component of the top status bar.
│  │  ├─ connect.tsx
│  │  ├─ index.ts // Provides access to common components.
│  │  ├─ modal // The business modal component
│  │  │  ├─ Inversion.tsx // The reverse button modal.
│  │  │  ├─ SwitchType.tsx // The switch modal.
│  │  │  ├─ index.tsx // Provides access to modals.
│  │  │  └─ interface.ts // The file of modal ts types.
│  │  └─ ripple-animate // The component of the water ripple animation shown during pairing.
│  │     ├─ CircleRipple.tsx
│  │     └─ WaterRipple.tsx
│  ├─ composeLayout.tsx // Encapsulates `device events` and `device information` that are required on the panel.
│  ├─ config
│  │  ├─ controlView.ts // The category configuration file.
│  │  ├─ dpCodes.ts // The data point (DP) configuration file.
│  │  ├─ index.ts
│  │  ├─ keyConfig.ts // The button configuration file.
│  │  ├─ orderKeys.ts // The button configuration file.
│  │  ├─ panelTheme.tsx // The theme configuration file (custom component).
│  │  ├─ subDevInfo.ts // The sub-device configuration file.
│  │  └─ theme.ts // The theme color configuration file (global).
│  ├─ elements.tsx
│  ├─ i18n // Includes multilingual configuration files.
│  │  ├─ index.ts
│  │  └─ strings.ts
│  ├─ main.tsx // The file that provides main access.
│  ├─ models // redux
│  │  ├─ combine.ts
│  │  ├─ configureStore.ts
│  │  ├─ index.ts
│  │  ├─ modules
│  │  │  ├─ common.ts
│  │  │  └─ deviceStore
│  │  │     ├─ asyncActions // The actions to be performed in API calls.
│  │  │     │  ├─ api
│  │  │     │  │  ├─ index.ts
│  │  │     │  │  └─ reduxAPI.ts
│  │  │     │  ├─ deleteLearnKey.ts // Deletes a learned button.
│  │  │     │  ├─ deviceBind.ts // Binds a sub-device.
│  │  │     │  ├─ getDeviceDps.ts // Returns a device DP.
│  │  │     │  ├─ getDeviceKeys.ts // Returns buttons from the code library.
│  │  │     │  ├─ getDeviceType.ts // Returns the categories supported by the device.
│  │  │     │  ├─ getLearnKeyData.ts // Returns the custom learned buttons of sub-devices.
│  │  │     │  ├─ getSubDevInfo.ts // Returns information about sub-devices.
│  │  │     │  ├─ getSubDevList.ts // Returns a list of sub-devices.
│  │  │     │  ├─ index.ts // The file that provides access to components.
│  │  │     │  ├─ renameLearnKey.ts // The renaming button.
│  │  │     │  └─ rfPair.ts // Pairs an RF remote control sub-device.
│  │  │     ├─ reducers.ts
│  │  │     └─ syncActions.ts // The actions to be performed without API calls.
│  │  └─ useFetch
│  │     ├─ api
│  │     │  ├─ dataFetchReducer.ts
│  │     │  └─ index.ts
│  │     └─ index.ts
│  ├─ pages
│  │  ├─ DiyTypeList.tsx // The custom learning list.
│  │  ├─ EditControl.tsx // Edits a sub-device.
│  │  ├─ EditLearnKeys.tsx // Edits a learned button.
│  │  ├─ Empty.tsx // No devices are found.
│  │  ├─ RfPair.tsx // Pairs an RF remote control device.
│  │  ├─ SelectBrand.tsx // Selects a brand.
│  │  ├─ SelectModel.tsx // Selects a model.
│  │  ├─ SelectTypes.tsx // Selects a category.
│  │  ├─ SetLimit.tsx // The limits on the curtain run length.
│  │  ├─ SubHome.tsx // Accesses a panel from a sub-device displayed on the homepage.
│  │  ├─ Topbar.tsx
│  │  ├─ control // The RF UI design.
│  │  │  ├─ ControlView.tsx // Processes UI interaction.
│  │  │  ├─ Curtains.tsx // The curtains.
│  │  │  ├─ DIY.tsx // Implements the custom learning.
│  │  │  ├─ FanLight.tsx // The fan light.
│  │  │  ├─ Garage.tsx // The garage door.
│  │  │  ├─ Hanger.tsx // The drying rack.
│  │  │  ├─ Irrigator.tsx // The irrigator.
│  │  │  ├─ Light.tsx // The light control.
│  │  │  ├─ ProScreen.tsx // The projection screen.
│  │  │  ├─ RetractDoor.tsx // The retractable door.
│  │  │  ├─ RollerShutters.tsx // The roller shutters.
│  │  │  ├─ Shutters.tsx // The shutters.
│  │  │  ├─ Socket.tsx // The socket.
│  │  │  ├─ Switch.tsx // The switch.
│  │  │  ├─ WindowPusher.tsx // The window pusher.
│  │  │  └─ index.tsx // The logic processor.
│  │  └─ index.tsx // The file that provides main access.
│  ├─ res
│  └─ utils
│     ├─ asyncStorageAPI.ts // The local cache.
│     ├─ index.ts // The common methods.
│     ├─ interface.ts // The common ts API.
│     └─ useControl.ts // The processor of all logic.

UI interaction

Pair a device

  1. Tap Add to start the device pairing process.

    RF Remote Control Template
  2. Select a category.

    RF Remote Control Template
  3. Select a brand.

    RF Remote Control Template
  4. Select a model.

    RF Remote Control Template
  5. Start pairing the device.

    RF Remote Control Template
  6. The device is paired.

    RF Remote Control Template

Start custom learning

  1. Access custom learning on the page of category selection.

    RF Remote Control Template
  2. Tap and hold the button for branded custom learning to start learning.

    RF Remote Control Template
  3. Tap and hold the button for unbranded custom learning to start learning.

    RF Remote Control Template

Edit a sub-device

Tap Edit in the top right corner of the sub-device page to edit the learned button.

RF Remote Control Template

For the curtain brands that support limits on the run length, the upper and lower limits of the run length can be set.

RF Remote Control Template

Set the limits on the run length.

RF Remote Control Template

Native APIs

Rename a sub-device

API name

TYSdk.native.renameSubDeviceName()

Request parameters

Parameter Data type Description Required
renameInfo { devId: string, name: string } The target device ID and the new name. Yes
successCallback () => void The success callback. Yes
failCallback () => void The failure callback. Yes

Sample request

/**
 * @desc Renames a sub-device.
 */
TYSdk.native.renameSubDeviceName(renameInfo, successCallback, failCallback)

Delete a sub-device

API name

TYSdk.native.removeSubDevice()

Request parameters

Parameter Data type Description Required
renameInfo { devId: string } The target sub-device ID. Yes
successCallback () => void The success callback. Yes
failCallback () => void The failure callback. Yes

Sample request

/**
 * @desc Deletes a sub-device.
 */
TYSdk.native.removeSubDevice(renameInfo, successCallback, failCallback)

Cloud APIs

Query a list of sub-devices

API name

tuya.m.infrared.gateway.get

Request parameters

Parameter Data type Description Required
gwId string The device ID specified by TYSdk.devInfo.devId. Yes
vendor string The vendor ID. By default, the value is 20 for RF remote control. Yes

Query sub-device types

API name

tuya.m.infrared.sub.product.category.rel

Request parameters

Parameter Data type Description Required
productId string The product ID (PID) specified by TYSdk.devInfo.productId. Yes

Query a list of brands

API name

tuya.m.infrared.brand.get

Request parameters

Parameter Data type Description Required
countryCode string The country or region code. For example, CN means mainland China and UN means the United Nations. Yes
pid string The PID specified by TYSdk.devInfo.productId. Yes
vendor string 20 Yes
brandType number
  • 1: all brands
  • 2: top brands
Yes
devTypeId number The category ID. Yes

Query a list of models

API name

tuya.m.infrared.remoteid.get

Request parameters

Parameter Data type Description Required
countryCode string The country or region code. For example, CN means mainland China and UN means the United Nations. Yes
devTypeId number The category ID. Yes
vendor string 20 Yes
brandId number The brand ID. Yes

Query learning code for current sub-device

API name

tuya.m.infrared.learn.get

Request parameters

Parameter Data type Description Required
subDevId string The device ID. Yes
vendor string 20 Yes

Delete a learned button

API name

tuya.m.infrared.learn.delete

Request parameters

Parameter Data type Description Required
learningId number The target button ID. Yes
vendor string 20 Yes

Rename a learned button

API name

tuya.m.infrared.learn.save

Request parameters

Parameter Data type Description Required
subDevId number The target sub-device ID. Yes
vendor string 20 Yes
learningKeyJSON string Query information about learned button Yes
gwId string The remote control ID specified by TYSdk.devInfo.devId. Yes

Query buttons from RF remote control code library

API name

tuya.m.infrared.rfdata.get

Request parameters

Parameter Data type Description Required
devId string The device ID. Yes
vendor string 20 Yes
countryCode string The country or region code. For example, CN means mainland China and UN means the United Nations. Yes
remoteId number The remote control code ID. Yes

Save a sub-device

API name

tuya.m.infrared.data.bind

Request parameters

Parameter Data type Description Required
productId string The product ID. Yes
vendor string 20 Yes
gwId string The device ID specified by TYSdk.devInfo.devId. Yes
irDataJSON string The information about the device. Yes

Pair an RF remote control sub-device

API name

tuya.m.infrared.rf.pair

Request parameters

Parameter Data type Description Required
brandId string The brand ID. Yes
vendor string 20 Yes
gwId string The device ID specified by TYSdk.devInfo.devId. Yes
devTypeId number The category ID. Yes
remoteId number The remote control code ID. Yes
countryCode string The country or region code. For example, CN means mainland China and UN means the United Nations. Yes

Query sub-device information

API name

tuya.m.infrared.record.get

Request parameters

Parameter Data type Description Required
subDevId string The sub-device ID. Yes
vendor string 20 Yes