English
English
简体中文
Contact Us
Register
Log In

Manage Devices on Tuya IoT Edge Gateway

Last Updated on : 2022-09-21 03:50:37download

This topic describes how to create a smart product on the Tuya IoT Development Platform and add a product and a sub-device to Tuya IoT Edge Gateway (TEdge).

Create a sub-device on the Tuya IoT Development Platform

  1. Log in to the Tuya IoT Development Platform.

  2. 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.

  3. Click the Custom Solution tab and select Plug.

  4. Enter the product name, keep the default settings of Protocol and Power Type, and then click Create.

    Manage Devices on Tuya IoT Edge Gateway

  5. In the dialog box that appears, select the required data points (DPs). In this example, Switch 1 and Countdown 1 are selected.

    Manage Devices on Tuya IoT Edge Gateway

  6. After you create the product, the product ID (PID) appears in the product details section. Save the PID for later use.

    Manage Devices on Tuya IoT Edge Gateway

Manage sub-devices on Tuya IoT Edge Gateway

Add a product

  1. Add the socket product to Tuya IoT Edge Gateway: Visit the URL http://localhost:3000. In the left-side navigation pane of Tuya IoT Edge Gateway, choose Devices > Products and click Add.

    Manage Devices on Tuya IoT Edge Gateway

  2. Enter the details of the product that is newly created on the Tuya IoT Development Platform:

    • PID: Copy the saved PID and paste it to this field.
    • Name: Enter a preferred product name such as My Socket.
    • Description: Enter the product description.
    • Driver Library: Select a driver library. Fuzzy matching is supported. For example, to support the Modbus protocol, enter the keyword modbus and select the driver that appears.

Add DPs to the product

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 Tuya IoT Development Platform.

Manage Devices on Tuya IoT Edge Gateway

The DPs on the Tuya IoT Development 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 Tuya IoT Development Platform. These DPs must be added to the same product on the edge gateway.

Manage Devices on Tuya IoT Edge Gateway

In this example, the following DPs are added:

  • Switch 1
    Manage Devices on Tuya IoT Edge Gateway
  • Countdown 1
    Manage Devices on Tuya IoT Edge Gateway

Add a sub-device

Create a sub-device: In the left-side navigation pane of Tuya IoT Edge Gateway, choose Devices > Sub-devices and click Add Sub-device.

Manage Devices on Tuya IoT Edge Gateway

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 IoT 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 Tuya IoT Platform.

Run a device simulator

Start the Modbus device simulator

  1. Pull and install the modbus-simulator image.
    docker run --name "modbus-simulator" --restart=always \
    -p 1502:1502 \
    -d tuya/tedge-simulator-modbus:latest
    
  2. Get the IP address of the simulated device Docker.
    # Get the IP address of the simulated device Docker.
    docker inspect --format '{{ .NetworkSettings.IPAddress }}' The image ID.