Sync Status

Last Updated on : 2023-10-09 01:57:20download

Get parameters for MQTT connection

API endpoint

action: device.openHubConfig

Request parameter

Parameter name Type Description Required
uid String The user ID assigned by Tuya. Yes
link_id String The ID of the client that is connected over MQTT.
Clients are isolated from each other by link_id. If a user logs in with different clients, make sure each client is assigned a unique value of link_id.
link_type String The type of connection. Valid values: mqtt and websocket.
Default value: mqtt.

Sample request

    "action": "device.openHubConfig",
        "uid": "xxx",
        "link_id": "xxx", // A random unique ID.
    "link_type": "websocket"

Response parameter

Parameter name Type Description
code Integer The response code.
success Boolean Indicates whether the operation is successful. Valid values:
  • true: success.
  • false: failure.
  • msg String The error message that is returned if the API call fails. This parameter value is empty if the API call succeeds.
    result Object The parameters for the MQTT connection.

    Description of result

    Parameter name Type Description
    url String The URL through which MQTT connections are established. The URL indicates the protocol and the MQTT broker’s IP address and port.
    username String The username of the MQTT client. The username is unique to each user account.
    password String The password of MQTT connections. The password is unchanged within the validity of period. The digits 8 to 24 of the password are used as the key to decrypt MQTT messages with AES.
    client_id String The client_id of MQTT connections. The value is unique to each user account and unique_id. Each client_id can be used to publish and subscribe to messages.
    expire_time Long The time when the existing settings expire. After the settings expire, all respective MQTT connections are closed.
    source_topic String The topic to which a client subscribes. The MQTT messages about device events and status can be filtered based on the topic.
    sink_topic String The topic about which a client publishes messages. This feature is currently not supported. To send commands for device control, we recommend that you make HTTP API requests.

    Sample response

        "success": true,
        "t": 1566289523942,
        "result": {
            "url": "xxx://xxx:xx",
            "expire_time": 7200,
            "username": "xxx",
            "password": "xxx",
            "client_id": "xxx",
            "source_topic": "xxx",
            "sink_topic": "cloud/token/out/{dev_id}"