English
English
简体中文
Contact Us
Register
Log In
Language
English
English
简体中文
Contact Us
Log In
Register
Go to main website
App Develop

App Development

Tuya provides multiple mobile app development methods such as no-code or IoT App SDK development to maximize the monetization of IoT apps.
layoutIndex

Message Types

Last Updated on : 2021-12-06 08:51:03download

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 the device name.
20 Modify the name of a data point.
20 Bind the device with a user account.
20 Remove a device.
20 Update the status.
22 External automation action.
25 Execute a scene.
40 Outdoor alert message push.
43 Traffic center event.
45 Third-party voice assistant event.

Report device status data

  • data description

    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.
  • StatusItem description

    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-bit timestamp when the device status was reported.
    “{dpId}”:“{dpValue}” String:String “Data point (the data point code in product definition)”: “Value of data point”, (The product definition is optional)
  • Example

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

Go online

  • bizData description

    Code Data type Description
    time Long The timestamp.
  • Example

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

Go offline

  • bizData description

    Code Data type Description
    time Long The timestamp.
  • Example

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

Change the device name

  • bizData description

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

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

Change DP name

  • bizData description

    Code Data type Description
    devId String The device ID.
    name String The DP name.
    dpId String The DP ID.
  • Example

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

Bind a device

  • bizData description

    Code Data type Description
    devId String The device ID.
    uuid String The universally unique identifier (UUID).
    uid String The user account bound to the device.
    token String The device pairing token.
  • Example

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

Remove a device

  • bizData description

    Code Data type Description
    devId String The device ID.
    uid String The user account bound to the device.
  • Example

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

Update the status.

  • bizData description

    Code Data type Description
    devId String The device ID.
    moduleType Int The types of the modules. Valid values:
    • 0: Wi-Fi
    • 1: Bluetooth Low Energy (Bluetooth LE)
    • 2: GPRS
    upgradeStatus Int The update status. Valid values:
    • 1: Prepare to update
    • 2: Updating
    • 3: Update completed
    • 4: Failure
    description String The description of the 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
    	}
    

Outdoor geofence alert

  • bizData description

    Code Data type Description
    devId String The device ID.
    tag String The dimension tag.
    fenceId Long The ID of a specified geofence.
    fenceName String The name of a specified geofence.
    bindType Integer The binding type of the geofence. Valid values:
    • 1: private geofence.
    • 2: public geofence.
    lat Double The latitude reported by the current device.
    lon Double The longitude reported by the current device.
    triggerType String The type of alert. Valid values:
    • 1: Enter the geofence.
    • 2: Exit the geofence.
    reportTime Long The 13-bit timestamp of the reported time.
  • Example

    	{
    	"bizCode":"outdoorsFenceAlarm",
    	"bizData":{
    	        "devId":"ay1617****",
    	        "tag":"*******",
    	        "fenceId":1000,
    	        "fenceName":"MyFence",
    	        "bindType":1,
    	        "lat":121.234,
    	        "lon":34.3478,
    	        "triggerType":"1",
    	        "reportTime":1620896040128
    	},
    	"ts":1620896040128
    	}
    

Execute a scene

  • bizData description

    Code Data type Description
    name String The scene name.
    id String The scene ID.
    gid Long The home ID.
    uid String The user ID (UID) who made the request.
    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: failed
    • 1: succeeded
    • 2: to be executed
    • 3: no execution 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":"azmQ2w8kPSCdcrxxx",
        "actions":[
            {
                "entityId":"02167073ccxxxx",
                "execStatus":1,
                "executeTime":1625798044277,
                "id":"1jPxz3zaNdLxxxx"
            }
        ]
      },
     "gid":37081848,
     "uid":"ay1622715182388Nxxxx",
     "ts":1625798044298
    }
    

External automation action.

  • bizData description

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

    {
        "automationId":"Rc5XAKLSmwpxHxxx",//
        "bizCode":"automationExternalAction",
        "bizData":{
            "code":"mode",
            "value":2,
            "operator":"=="
        }
    }
    

Suspend the IoT SIM card

  • bizData description

    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 data is reported.
  • Example

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

Data usage alerts of the IoT SIM card

  • bizData description

    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 data is reported.
  • Example

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

Voice alert of the third-party voice assistant

  • bizData description

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

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

    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 voice assistant

  • Message description

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

  • bizData description

    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

  • bizData description

    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
    }