WebSocket API
The WebSocket API receives device events, refreshes one device state, and executes device operations over a long-lived connection.
When to Use WebSocket
- Continuously observe online, offline, power-loss, and peripheral-state changes
- Refresh one device in response to a user action
- Control relays or perform RS485 operations over an existing connection
- Avoid high-frequency HTTP state polling
Use REST for device lists, pagination, device configuration reads, and command-result queries. See REST API vs WebSocket for selection guidance.
Connection Flow
- Call
POST /wlte/v1/ws/ticketwith an access token. - Connect to
GET /wlte/v1/ws?ticket={ticket}with the one-time ticket. - Start Ping/Pong and
session.ping. - Listen for device events.
- Use
device.state.getfor one-device state queries. - Use
device.operation.executefor device operations.
Core Rules
- Correlate
requestandreplywithrequestId. - Select device write operations with
operation.name. - Replies use
code,message, and optionaldata, matching REST semantics. - Events have no history replay. Query critical device state after reconnecting.
- Configuration changes are not broadcast. Read relay jog duration and RS485 baud rate through the REST device-configuration endpoint.
See WebSocket Scope for the current topics and operations.
