General Notes
MQTT API Guide
Communication Protocol
Broker Connection Details
To connect to the MQTT broker, use the following credentials:
URL: mqtt://192.168.0.111:1883
Username: admin
Password: admin@123
Note: Make sure to secure these credentials and never expose them in client-side code.
Topic Structure
All MQTT communication follows a standardized topic structure:
LYT/<project_uuid>/<entity>/<action_type>
Where:
LYT: Root namespace identifying our MQTT systemproject_uuid: Unique project identifierentity: Resource identifier (NODE, DEVICE, ZONE etc.)action_type: Operation identifier (CONTROL, STATUS, ACTION etc.)
Request-Response Pattern
- Response topics add
/Eafter the entity component - Example:
Request: LYT/<project_uuid>/<entity>/<action_type>
Response: LYT/<project_uuid>/<entity>/E/<action_type>
Message Format
Common Requirements
- All messages must be valid JSON
- Required fields must be present and correctly typed
- String values must match specified enums where applicable
- Numeric values must be within defined ranges
Standard Fields
| Field | Type | Required | Description |
|---|---|---|---|
| version | string | Yes | API version (e.g., "v1.0") |
| type | string | Yes | Message type identifier |
| message | string | Yes | Status indicator ("success" or "error") |
Success Response Format
{
"message": "success",
"version": "v1.0",
"type": "<operation_type>",
"data": {
// Operation-specific response data
}
}
Error Response Format
{
"message": "error",
"message_type": {
"code": number, // Error code
"message": string, // Human-readable description
"errorCode": string // Error identifier
}
}
Pagination Management
Pagination Parameters
| Parameter | Type | Default | Range | Description |
|---|---|---|---|---|
| limit | number | 50 | 1-100 | Records per request |
| offset | number | 0 | ≥0 | Starting record index |
Example pagination request:
{
"version": "v1.0",
"type": "list",
"limit": 10,
"offset": 0
}
Best Practices
Request Guidelines
- Always include API version ("v1.0")
- Validate JSON structure before sending
- Use appropriate error handling
- Follow topic naming conventions
- Include all required fields
- Respect field type constraints
- Use pagination for large datasets
Error Handling Guidelines
- Check error codes and messages
- Implement appropriate retry logic
- Log error responses
- Handle timeout scenarios
- Validate input constraints
- Monitor response topics
Performance Guidelines
- Use pagination for large data sets
- Implement request throttling
- Handle timeouts appropriately
- Monitor response latency
- Batch operations when possible