Last Updated on : 2024-06-20 07:04:06download
This topic describes how to create a smart product on the Tuya Developer Platform and add a product and a sub-device to Tuya Edge Gateway (TEdge).
Log in to the Tuya Developer Platform.
In the left-side navigation pane, choose Product > Development and click Create. On the Standard Category tab, choose Electrical > Socket. You can also select another category.
Click the Custom Solution tab and select Plug.
Enter the product name, keep the default settings of Protocol and Power Type, and then click Create.
In the dialog box that appears, select the required data points (DPs). In this example, Switch 1 and Countdown 1 are selected.
After you create the product, the product ID (PID) appears in the product details section. Save the PID for later use.
Add the socket product to Tuya Edge Gateway: Visit the URL http://localhost:3000. In the left-side navigation pane of Tuya Edge Gateway, choose Devices > Products and click Add.
Enter the details of the product that is newly created on the platform.
Go back to the deployed edge gateway. In the left-side navigation pane, choose Devices > Products. Click DP for the newly added product and click Create. The created DPs must be the same as those specified on the platform.
The DPs on the platform can vary based on different types of products. You can specify the required DPs. The following figure shows the DPs that are specified on the platform. These DPs must be added to the same product on the edge gateway.
In this example, the following DPs are added:
Create a sub-device: In the left-side navigation pane of Tuya Edge Gateway, choose Devices > Sub-devices and click Add Sub-device.
In the dialog box that appears, to add a Modbus sub-device, perform the following steps:
Search the newly created socket by name in the Product Type field. Fuzzy matching is supported.
Select Modbus from the Driver Instance drop-down list that is automatically loaded after you select a product type.
Select the protocol type modbus-tcp.
In the IP Address field, enter the Docker IP address of the simulated Modbus device. This IP address is generated by the Modbus device simulator that is described in Manage Devices on Tuya Edge Gateway.
Set Port to 1502.
Set UnitID to the address of the simulated Modbus device.
After the sub-device is added, click Activate Online to activate the sub-device on the platform.
docker run --name "modbus-simulator" --restart=always \
-p 1502:1502 \
-d tuya/tedge-simulator-modbus:latest
# Get the IP address of the simulated device Docker.
docker inspect --format '{{ .NetworkSettings.IPAddress }}' The image ID.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback