Last Updated on : 2024-06-20 04:37:30download
This topic describes how to perform data parsing for a TuyaLink-based product.
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.
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.
For more information, see Messaging With Custom Format.
Log in to the Tuya Developer Platform.
Click Create.
Choose a product and select TuyaLink.
Complete the required information. Select Custom as the Data Protocol.
For more information about the detailed processes of product creation, see Create Products.
On the page of Product Development, select a product, and click Develop.
Click the Data Parsing tab.
Click Create Now.
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.
Debug code with the data exchange simulation feature.
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.
Click Run. The Parsing Results are displayed on the right screen.
Click Save to save the results.
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.
Perform debugging online to verify the configured functions.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback