Data Parsing

Last Updated on : 2024-06-20 04:37:30download

This topic describes how to perform data parsing for a TuyaLink-based product.

Concepts

Data parsing

If your hardware cannot structure data in JSON format, you can send the raw data to the cloud and submit the script file to the platform for data conversion.

Data protocol

In the product creation stage, the platform provides two options for data protocol, namely Tuya Standard Protocol and Custom.

  • Tuya Standard Protocol

    The standard data format used for data exchange between devices and the cloud is Tylink JSON. If your device can structure data in JSON, you can opt for Tuya Standard Protocol.

  • Custom

    If your device cannot structure data in JSON, you can opt for Custom to send the raw data to the cloud and the cloud will take care of data conversion.

The platform supports parsing topic-based data for two-way communication between devices and the cloud. The raw data delivered to the cloud is parsed into Tylink JSON data. The Tylink JSON data is parsed into custom format data to send to devices.

Data Parsing

Device-side development

For more information, see Messaging With Custom Format.

Procedure

Step 1: Create product

  1. Log in to the Tuya Developer Platform.

  2. Click Create.

    Data Parsing
  3. Choose a product and select TuyaLink.

    Data Parsing
  4. Complete the required information. Select Custom as the Data Protocol.

    Data Parsing

    For more information about the detailed processes of product creation, see Create Products.

Step 2: Parse data

  1. On the page of Product Development, select a product, and click Develop.

  2. Click the Data Parsing tab.

  3. Click Create Now.

    Data Parsing Data Parsing

    The script debugger provides two functions:

    For upstream communications: rawDataToTyLink
    For downstream communications: tyLinkToRawData

You can write a JavaScript script based on the raw data sent from the device to make a standardized conversion.

Step 3: Simulate data parsing

Debug code with the data exchange simulation feature.

  1. On the script debugging page, select Device Reports Data or Cloud Sends Data as the Simulation Type to simulate the device-to-cloud or cloud-to-device communication respectively.

  2. Click Run. The Parsing Results are displayed on the right screen.

  3. Click Save to save the results.

    Data Parsing

Step 4: Release script

After your script is fully verified, you can click Release as Official Version. The cloud will use this release to parse data.

In the real data exchange process, the data will first flow to the script for parsing and then be sent to the target destination.

Data Parsing

Next step

Perform debugging online to verify the configured functions.