English
English
简体中文
Contact Us
Register
Log In

Message Types

Last Updated on : 2022-09-22 06:41:48download

Data format

Message Types

Business data

Protocol number

Different protocol numbers stand for different features.

Protocol number Description
4 Report device status data
20 Go online
20 Go offline
20 Modify a device name
20 Modify the name of a data point
20 Bind a device with a user account
20 Remove a device
20 Update the device status.
25 Execute a scene
40 Send an outdoor alert message
43 Suspend the IoT SIM card
43 Send data usage alerts of the IoT SIM card
45 Send voice prompts
45 Reset a third-party speaker
45 Change data of custom FAQs
46 Send check-in events
46 Send check-out events

Report device status data

  • Description of data

    code Data type Description
    dataId String The unique ID of the reported data, which has no business meaning.
    devId String The device ID.
    productKey String The product ID.
    status List<StatusItem> The list of the reported device status data this time.
    • Description of StatusItem

      code Data type Description
      code String The code of a specified device status.
      value Object The status value of the code of a specified device status.
      t Long The 13-digit timestamp when the device status is reported.
      “{dpId}”:“{dpValue}” String:String “Data point ID (the data point ID in product definition)”: “Value of data point”, You can refer to the product definition.
  • Example

    {
    "dataId":"AAXI3c1i6xxx***",
    "devId":"6c95a93fd9xxx***",
    "productKey":"awgmk9pixxx***",
    "status":[
        {
            "code":"switch_1",
            "value":false,
            "t":1628229842692,
            "1":"false"
        }
    ]
    }
    

Go online

  • Description of bizData

    code Data type Description
    time Long The timestamp.
  • Example

    {
      "devId": "002dj00118fe34d9****",
      "productKey": "The product key defined on the Tuya IoT Development Platform",
      "bizCode": "online",
      "bizData": {
        "time": 146052438362
      }
    }
    

Go offline

  • Description of bizData

    code Data type Description
    time Long The timestamp.
  • Example

      {
        "devId": "002dj00118fe34d9****",
        "productKey": "The product key defined on the Tuya IoT Development Platform",
        "bizCode": "offline",
        "bizData": {
          "time": 146052438362
        }
      }
    

Modify a device name

  • Description of bizData

    code Data type Description
    devId String The device ID.
    name String The device name.
  • Example

    {
      "devId": "002dj00118fe34d9****",
      "productKey": "The product key defined on the Tuya IoT Development Platform",
      "bizCode": "nameUpdate",
      "bizData": {
        "devId": "002dj00118fe34d9****",
        "name": "new name"
      }
    }
    

Modify the name of a data point

  • Description of bizData

    code Data type Description
    devId String The device ID.
    name String The name of a specified data point.
    dpId String The ID of a specified data point.
  • Example

    {
      "devId": "002dj00118fe34d9****",
      "productKey": "The product key defined on the Tuya IoT Development Platform",
      "bizCode": "dpNameUpdate",
      "bizData": {
        "devId": "002dj00118fe34d9****",
        "name": "new name",
        "dpId": "dpId"
      }
    }
    

Bind a device with a user account

  • Description of bizData

    code Data type Description
    devId String The device ID.
    uuid String The universally unique identifier (UUID) of a specified device.
    uid String The user ID bound with the device.
    token String The device pairing token.
  • Example

    {
         "devId": "002dj00118fe34d9****",
         "productKey": "The product key defined on the Tuya IoT Development Platform",
         "bizCode": "bindUser",
         "bizData": {
           "devId": "002dj00118fe34d9****",
           "uuid": "06200043b4e618c1****",
           "uid":"ay1529485403390****",
           "token": "IIpQ****"
         }
     }
    

Remove a device

  • Description of bizData

    code Data type Description
    devId String The device ID.
    uid String The user ID bound with the device.
  • Example

    {
       "devId": "002dj00118fe34d9****",
       "productKey": "The product key defined on the Tuya IoT Development Platform",
       "bizCode": "delete",
       "bizData": {
         "devId": "002dj00118fe34d9****",
         "uid":"ay1529485403390S****"
       }
     }
    

Update the device status

  • Description of bizData

    code Data type Description
    devId String The device ID.
    moduleType Int The types of the modules. Valid values:
    • 0: Wi-Fi
    • 1: Bluetooth LE
    • 2: GPRS
    upgradeStatus Int The update status. Valid values:
    • 1: Prepare to update.
    • 2: Updating.
    • 3: Update is completed.
    • 4: An exception occurs during an update process.
    • 7: Timeout.
    description String The description of an update.
    oldVersion String The earlier firmware.
    newVersion String The later firmware.
  • Example

    {
        "bizCode":"upgradeStatus",
        "bizData": {
            "devId":"6ca8756d*****1b4ewsdn",  
            "moduleType":0,
            "upgradeStatus":2,
            "description":"Update test",
            "oldVersion": "1.0.1",
            "newVersion": "1.0.2"         
        },
        "devId":"6ca8756d*****1b4ewsdn",
        "productKey":"vFHpaEFwu8UD****",
        "ts":1562232522192
    }
    

Execute a scene

  • Description of bizData

    code Data type Description
    name String The name of a specified scene.
    id String The ID of a specified scene.
    gid Long The ID of a specified home.
    uid String The user ID (UID) who adds a scene.
    ts Long The timestamp of message delivery.
    actions.entityId String The entity ID.
    actions.execStatus Integer The status of the action. Valid values:
    • -1: default
    • 0: failure
    • 1: success
    • 2: to be executed
    • 3: no execution is required
    actions.executeTime Long The timestamp of execution.
    actions.id String The action ID.
    actions.errorMsg String The error message.
  • Example

    {
       "bizData":{
        "name":"Switch-On",
        "id":"azmQ2w8kPSCdcr***",
        "actions":[
            {
                "entityId":"02167073cc****",
                "execStatus":1,
                "executeTime":1625798044277,
                "id":"1jPxz3zaNdL****"
            }
        ]
      },
     "gid":37081***,
     "uid":"ay1622715182388N****",
     "ts":1625798044298
    }
    

Send an outdoor alert message

  • Description of bizData

    code Data type Description
    automationId String The ID of a specified automation scene.
    bizData JSON The custom data, to be used with POST/v1.0/homes/{home_id}/automations/{automation_id}/conditions/trigger.
  • Example

    {
        "automationId":"Rc5XAKLSmwpxH***",
        "bizCode":"automationExternalAction",
        "bizData":{
            "code":"mode",
            "value":2,
            "operator":"=="
        }
    }
    

Suspend the IoT SIM card

  • Description of bizData

    code Data type Description
    iccid String The ID of a specified IoT SIM card.
    deviceId String The device ID.
    uid String The user ID.
    pid String The product ID.
    stopReason String Reasons for suspending the IoT SIM card. Valid values:
    • PACKAGE_EXHAUSTED: The data is used up.
    • EXPIRE_PACKAGE: The package has expired.
    • INVOKE:****: It is called by the requesting party.
    • UNBIND_PACKAGE: The package has been unbound.
    • UNSUBSCRIBE_PACKAGE: The package has been unsubscribed.
    reportTime Long The timestamp when the data is reported.
  • Example

    {
       "bizCode":"simStop",
       "bizData":{
        "iccid": "****",
        "deviceId": "****",
        "uid": "****",
        "pid": "****",
        "stopReason": "FLOW_OUT",
        "reportTime": 1620896040128
      },
     "ts":1625798044298
    }
    

Send data usage alerts of the IoT SIM card

  • Description of bizData

    code Data type Description
    iccid String The ID of a specified IoT SIM card.
    deviceId String The device ID.
    uid String The user ID.
    pid String The product ID.
    totalFlowAmount String The total available data amount.
    usedFlowAmount String The amount of used data.
    reportTime Long The timestamp when the data is reported.
  • Example

    {
       "bizCode":"simLimitAlarm",
       "bizData":{
        "iccid": "xxxx",
        "deviceId": "xxxx",
        "uid": "xxxx",
        "pid": "xxxx",
        "totalFlowAmount": 10240,
        "usedFlowAmount": 1024,
        "reportTime": 1620896040128
      },
     "ts":1625798044298
    }
    

Send voice prompts

  • Description of bizData

    code Data type Description
    brandCode String The brand code of the speaker.
    voiceId String The device ID of the speaker.
    command Array The command.
  • Description of command

    code Data type Description
    intent String The intention. For example, welcome can be used for showing welcome.
    content Object The conent of a command.
  • Description of content

    code Data type Description
    value String The content for voice alert.
  • Example

    {
        "bizCode":"textToSpeech",
        "bizData":{
            "brandCode":"abc*******",
            "voiceId":"def*******",
            "command": [{ 
                "intent": "welcome",
                "content":{
                    "value": "Welcome to our hotel"
                }
            }]
        },
        "ts":1636682568127
    }
    

Reset a third-party speaker

  • Message description

    When a third-party speaker is unbound or a guest checks out, the voice platform will clear the usage history or the cache.

  • Description of bizData

    code Data type Description
    brandCode String The brand code of the speaker.
    voiceId String The device ID of the speaker.
  • Example

    {
        "bizCode":"reset",
        "bizData":{
            "brandCode":"abc*******",
            "voiceId":"def*******"
        },
        "ts":1636682568127
    }
    

Change data of custom FAQs

  • Description of bizData

    code Data type Description
    spaceId String The ID of a specified space.
    brandCodeList List The code list of the speaker brand.
  • Example

    {
        "bizCode":"customQAChange",
        "bizData":{
            "spaceId":"123*********",
            "brandCodeList":["abc*******","def*******"]
        },
        "ts":1636682568127
    }
    

Send check-in events

  • Description of bizData

    code Data type Description
    hotel_code String The unique code of a specified hotel in the property management system (PMS).
    customer_id String The user ID.
    start_time Long The timestamp when a stay in the hotel starts.
    end_time Long The timestamp when a stay in the hotel ends.
    current_room_path String[] The multi-level path associated with the current room.
  • Example

    {
    "bizCode":"hotelPmsCustomerCheckin",
    "bizData":{
        "hotel_code":"xxxx",
        "customer_id":"xxxx",
        "start_time":1655287277055,
        "end_time":1663236077000,
        "current_room_path":[
            "Building 1",
            "Unit 1",
            "Floor 6",
            "603"
        ]
    },
    "ts":1638943452529
    }
    

Send check-out events

  • Description of bizData

    code Data type Description
    hotel_code String The unique code of a specified hotel in the property management system (PMS).
    customer_id String The user ID.
    start_time Long The timestamp when a stay in the hotel starts.
    end_time Long The timestamp when a stay in the hotel ends.
    current_room_path String[] The multi-level path associated with the current room.
  • Example

    {
    "bizCode":"hotelPmsCustomerCheckout",
    "bizData":{
        "hotel_code":"****",
        "customer_id":"****",
        "start_time":1655287277055,
        "end_time":1663236077000,
        "current_room_path":[
            "Building 1",
            "Unit 1",
            "Floor 6",
            "603"
        ]
    },
    "ts":1638943452529
    }