Change Control Instruction Mode

Last Updated on : 2024-06-18 06:04:06download

This topic describes how to change the control instruction mode of a device on the Tuya Developer Platform.

Control modes

You can choose from the following two control instruction modes during cloud development.

Mode
Description Scenario
Standard instruction set A standard instruction set is a set of instructions that are sent to control devices. It provides a suite of standard descriptions of device functions. After you send standard instructions in JSON format, Tuya converts them into device data points (DPs) in the cloud for the purpose of device control. During cloud development, devices are controlled in standard instruction mode by default. However, the standard instruction set cannot cover all the functions of Tuya-enabled devices. For more information about product categories that can be controlled with standard instruction sets, see Standard Instruction Set.
DP instruction Control devices with original DP instructions. You can access the original DP information of your products. This mode is suitable for some products that contain non-standard instruction sets. If you cannot control a smart product by using the standard instruction set, you can change to the DP instruction mode and control the product using originally defined DPs. Some non-standard DPs are protocols customized by manufacturers. After DP transmission, Tuya only transmits data without parsing. In this case, you can consult the manufacturers for data parsing.

If you modify the functional DP of a product, configurations of the DP instruction mode will be automatically updated in about four hours.

Prerequisites

  • You have linked a device with the cloud project. For more information, see Link Devices.
  • The main IoT account, rather than the authorized account, is used to manage the cloud project.

Step 1: View products of a project

  1. Log in to the Tuya Developer Platform.

  2. Visit My Cloud Projects.

  3. Select the target project and click Open Project in the Operation column.

  4. In the top navigation bar, choose Devices > All Devices.

  5. In the section of View Devices by Product, click the ellipsis () button to view a list of products.

    Change Control Instruction Mode

    The PIDs in the product list represent the products of all devices bound with the app or app account in the linked cloud project.

Step 2: Change control instruction mode

  1. Hover over the target device card, and click the view (Instruction Details) button to view instruction details. Alternatively, you can click the edit (Change Control Instruction Mode) button to go to the page of Configure Control Instruction Mode.

    Change Control Instruction Mode

    The list of products on this page is not exhaustive. If you do not find the desired product, search by product name or product ID.

  2. On the page of the control instruction mode, you can:

    1. Query the details of standard instruction sets of the specified product. Also, you can click Change Instruction Mode at the bottom to configure the mode.

    2. Change the control instruction mode to DP Instruction.

      Change Control Instruction Mode
    3. Click Save Configuration.

    4. On the page of View Details, click Refresh Configuration to refresh and view the details.

      Changes to the control instruction mode will take effect immediately in the China Data Center. The changes are automatically synced to other data centers in about four hours. If you want the changes to take effect immediately, you can click Refresh Configuration to refresh manually on the page of the specific data center.
      Change Control Instruction Mode

During subsequent cloud development, you need to use the specified instruction mode to control the devices.

Step 3: Adjust the mode of sending instructions

Take the lighting color DP colour_data of smart lights as an example.

  • Standard instruction mode: Send instructions in JSON format.

    {
        "code": "colour_data",
        "value":
        {
            "h": 37,
            "s": 255,
            "v": 188
        }
    }
    
  • DP instruction mode: Send instructions based on the DP protocol of the specified product category. After transparent transmission, the value parameter in the standard instruction is sent in String format. You need to concatenate the parameters yourself.

    Data type Value range Instruction example
    String 000011112222, among which:
    • 0000: the hue. Valid values: 0 to 360, corresponding to 0X0000 to 0X0168.
    • 1111: the saturation. Valid values: 0 to 1000, corresponding to 0X0000 to 0X03E8.
    • 2222: the value. Valid values: 0 to 1000, corresponding to 0X0000 to 0X03E8.
    {"code": "colour_data", "value": "00DC004B004E"}

    The HSV value is 00DC 004B 004E in hexadecimal format. After converting the value to the decimal format, you will get the HSV color 220°, 75%, and 78%.