Skip to main content

UDP

This guide will show you how to integrate UDP protocol devices into Aqara Studio by writing JS scripts, and how to map device function points according to the Aqara Data Model Specification, enabling device discovery, addition, and control of function points.

Learn and Write JavaScript Scripts

Please refer to the JavaScript script (for UDP and TCP) guide to write a JavaScript script that complies with the Aqara Data Model Specification. This script instructs Aqara Studio how to discover devices, and add and control function points.

Add UDP Devices

  1. In the left sidebar, click to enter the Devices page. In the left Protocols and Devices panel, click the ... button and select Add Protocol.

    Add Protocol
  2. In the popup, select UDP to add a UDP node.

    Add UDP
  3. Select the node to enter the management page. Click the Protocol Configuration button.

    Protocol Configuration
  4. In the popup, click the Script Configuration button.

    Script Configuration
  5. Paste the JavaScript script you wrote into the code editor, ensuring that the UDP device and its function points can be correctly recognized and managed by Aqara Studio.

    Paste the code into the script editor
  6. (Optional) If you want to use msgId to match sent messages with received messages, enable the Match by msgId switch. If it is not enabled, messages are processed in order.

    Message ID matching
  7. Return to the UDP management page and click the Add Device button.

    Click the Add Device button
  8. In the popup, select Auto Discovery as the integration method, then select Start Integrating Device to proceed to the next step.

    Select Auto Discovery as the integration method
  9. (Optional) Click the ⚙ icon.

    Click the gear icon
    tip

    If there is no UDP server, you can skip this configuration. In that case, it is recommended to directly specify the target UDP device's IP address and port number in the return value of parseDiscoveryResponse in the JS script to achieve precise device discovery and integration.

    Enter the UDP server IP address and port number in the popup. This information will be used by the buildDiscoveryRequest interface in the JS script to instruct Aqara Studio to automatically discover all UDP devices at the specified address.

    Configure server IP address and Port
  10. Click the Discover Devices button.

    Aqara Studio will automatically scan and identify UDP devices that can be integrated based on the JS script you wrote, and the discovered devices will be displayed in the Discovered Devices list.

    Discover Devices
  11. Select the devices to integrate and click the + button in the center.

    Newly added devices will appear in the Added Device List on the right. Click the Complete button to exit the add device process.

  12. You will then see the successfully added devices under the UDP node in the left Protocols and Devices panel, as well as in the device list on the UDP management page.

Add Points

  1. Under the UDP node, select a UDP device and click the Add Point button.

  2. Click the Discover Points button.

    tip
  3. In the Discovered Points list, check the required points and click the middle + button.

    Newly added points will appear in the Added Points list on the right. Click the Complete button to exit the add points process.

  4. You will then see the successfully added points on the management page of that UDP device.

Next Steps

Now, you can view details and control the device, or use the device in automation.