Skip to main content

TCP

This guide will show you how to integrate TCP 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.

Tested TCP Devices​

The following TCP devices have been tested by Aqara and can be integrated with Aqara Studio:

BrandModel
HOPEMusic Player MP1
Note: Get the HOPE Access (HOPE speaker integration) plugin from Aqara Builder Lab - Marketplace. Use it with the TCP Protocol Access plugin described below to simplify integration. You can then add HOPE speakers and their function points directly in the Aqara Studio web UI, without writing a JavaScript script.
JBLHome Theater/Karaoke Integrated Amplifier LM610
KudiHA Video Box VP1
tip

If you would like Aqara to test more products, please send the brand, model, product information, and your contact details to eco-partnerships@aqara.com so that Aqara can follow up with you.

Learn and Write JavaScript Scripts​

For the shared script structure and configuration workflow, see the third-party device script integration guide.

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.

Install the Plugin​

Please refer to the Plugin Market instruction, and go to Aqara Builder Lab - Marketplace to install the TCP Protocol Access plugin.

Add TCP 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 TCP to add a TCP node.

    Add TCP
  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 TCP 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 TCP 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

    If your TCP device is discovered via the TCP protocol, select the TCP option; if your TCP device is discovered via the UDP protocol, select the UDP option.

    tip

    Supply a fixed target in describe().discovery or editable dialog settings. encode(discoverDevices) builds the request and decode returns actual device candidates/addresses. A static address list alone is not completed discovery; use published manual creation when no discovery protocol exists.

    • TCP:
      Enter the TCP target IP/port or use script discovery settings. encode(discoverDevices) builds/sends a request; decode parses the real response into candidates.

      Configure server IP address and Port
    • UDP:
      Set Discovery Type to UDP.

      Configure discovery type

      Configure the actual UDP broadcast/multicast target or describe().discovery. encode(discoverDevices) sends and decode obtains identity/TCP address from replies. Configure responseIp/responsePort separately when a fixed reply port is required.

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

    Aqara Studio will automatically scan and identify TCP 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.

    Add discovered devices

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

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

    Devices have been added

Add Points​

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

    Select a device and add points
  2. Click the Discover Points button.

    tip
    • Remote point lists: encode(discoverPoints) sends bytes; decode returns pointDefinitions from the actual response.
    • Static point lists: encode(discoverPoints) returns null; decode receives bytes=null and returns pointDefinitions without a request. Both require selecting/importing points. Runtime option changes use dynamic enums, not repeated point creation.
    Discover Points
  3. In the Discovered Points list, check the required points and click the middle + button.

    Add discovered points

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

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

    Added points

Next Steps​

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