Skip to content

Message Format

All WebSocket text messages use JSON.

Message semantics are distinguished by type and topic:

typeDirectionDescription
requestClient to serverThe client sends one request
replyServer to clientThe server replies to one request
eventServer to clientThe server pushes an event

Request

json
{
  "type": "request",
  "requestId": "req_status_001",
  "topic": "device.status.get",
  "data": {
    "deviceId": "abc123456789"
  }
}

Field descriptions:

FieldTypeRequiredDescription
typestringYesFixed as request
requestIdstringYesClient-generated request ID. It should be unique within one connection
topicstringYesRequest topic
dataobjectYesRequest data

Success Reply

json
{
  "type": "reply",
  "requestId": "req_status_001",
  "topic": "device.status.get",
  "success": true,
  "data": {
    "deviceId": "abc123456789",
    "name": "YourDeviceName",
    "deviceType": "SM4_T_TH",
    "status": "ONLINE",
    "peripherals": {
      "relays": [
        {
          "index": 1,
          "on": false
        },
        {
          "index": 2,
          "on": false
        },
        {
          "index": 3,
          "on": true
        },
        {
          "index": 4,
          "on": false
        }
      ],
      "digitalInputs": [
        {
          "index": 1,
          "active": false
        },
        {
          "index": 2,
          "active": false
        },
        {
          "index": 3,
          "active": false
        },
        {
          "index": 4,
          "active": false
        }
      ],
      "sensors": [
        {
          "index": 1,
          "type": "TEMP",
          "value": 30.4,
          "unit": "C",
          "status": "ONLINE"
        },
        {
          "index": 2,
          "type": "TEMP",
          "value": 32.6,
          "unit": "C",
          "status": "ONLINE"
        },
        {
          "index": 2,
          "type": "HUMI",
          "value": 54,
          "unit": "%",
          "status": "ONLINE"
        }
      ]
    },
    "stateUpdatedAt": "2026-04-03T00:41:44Z"
  }
}

Error Reply

json
{
  "type": "reply",
  "requestId": "req_op_001",
  "topic": "device.operation.execute",
  "success": false,
  "error": {
    "code": "COMMAND_REJECTED",
    "message": "Command was rejected."
  }
}

Field descriptions:

FieldTypeRequiredDescription
typestringYesFixed as reply
requestIdstringYesThe requestId of the original request
topicstringYesThe topic of the original request
successbooleanYesWhether the request was processed successfully
dataobjectReturned on successResponse data
errorobjectReturned on failureError details
error.codestringReturned on failureError code
error.messagestringReturned on failureHuman-readable description for display, logs, and troubleshooting only

Event

json
{
  "type": "event",
  "topic": "device.state.changed",
  "data": {
    "deviceId": "abc123456789",
    "occurredAt": "2026-04-03T00:41:44Z",
    "reason": "remoteControl",
    "correlationId": "req_op_001",
    "peripherals": {
      "relays": [
        {
          "index": 1,
          "on": false
        },
        {
          "index": 2,
          "on": false
        },
        {
          "index": 3,
          "on": true
        },
        {
          "index": 4,
          "on": false
        }
      ],
      "digitalInputs": [
        {
          "index": 1,
          "active": false
        },
        {
          "index": 2,
          "active": false
        },
        {
          "index": 3,
          "active": false
        },
        {
          "index": 4,
          "active": false
        }
      ],
      "sensors": [
        {
          "index": 1,
          "type": "TEMP",
          "value": 30.4,
          "unit": "C",
          "status": "ONLINE"
        },
        {
          "index": 2,
          "type": "TEMP",
          "value": 32.6,
          "unit": "C",
          "status": "ONLINE"
        },
        {
          "index": 2,
          "type": "HUMI",
          "value": 54,
          "unit": "%",
          "status": "ONLINE"
        }
      ]
    },
    "stateUpdatedAt": "2026-04-03T00:41:44Z"
  }
}

Field descriptions:

FieldTypeRequiredDescription
typestringYesFixed as event
topicstringYesEvent topic
dataobjectYesEvent data

For detailed peripheral state field definitions, see Peripheral State Reference.

Naming Rules

  • type only uses request, reply, and event
  • topic uses lowercase English words separated by dots, for example device.status.get
  • requestId is generated by the client and may use a business ID, UUID, or a short prefixed ID
  • Time fields use RFC3339 UTC strings
  • JSON fields use camelCase
  • Clients should ignore newly added fields they do not recognize yet
Docs buildVersion v1.2.19-20260602-174859-60
Copyright © 2026 WLTE