Skip to main content

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 system
  • project_uuid: Unique project identifier
  • entity: Resource identifier (NODE, DEVICE, ZONE etc.)
  • action_type: Operation identifier (CONTROL, STATUS, ACTION etc.)

Request-Response Pattern​

  • Response topics add /E after the entity component
  • Example:
    Request:  LYT/<project_uuid>/<entity>/<action_type>
    Response: LYT/<project_uuid>/<entity>/E/<action_type>

Message Format​

Common Requirements​

  1. All messages must be valid JSON
  2. Required fields must be present and correctly typed
  3. String values must match specified enums where applicable
  4. Numeric values must be within defined ranges

Standard Fields​

FieldTypeRequiredDescription
versionstringYesAPI version (e.g., "v1.0")
typestringYesMessage type identifier
messagestringYesStatus 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​

ParameterTypeDefaultRangeDescription
limitnumber501-100Records per request
offsetnumber0≥0Starting record index

Example pagination request:

{
"version": "v1.0",
"type": "list",
"limit": 10,
"offset": 0
}

Best Practices​

Request Guidelines​

  1. Always include API version ("v1.0")
  2. Validate JSON structure before sending
  3. Use appropriate error handling
  4. Follow topic naming conventions
  5. Include all required fields
  6. Respect field type constraints
  7. Use pagination for large datasets

Error Handling Guidelines​

  1. Check error codes and messages
  2. Implement appropriate retry logic
  3. Log error responses
  4. Handle timeout scenarios
  5. Validate input constraints
  6. Monitor response topics

Performance Guidelines​

  1. Use pagination for large data sets
  2. Implement request throttling
  3. Handle timeouts appropriately
  4. Monitor response latency
  5. Batch operations when possible