Skip to main content

Control RGB Light

Control RGB lights by adjusting their r, g, and b components.

Description

`The RGB control allows you to manage RGB LED lights by setting:

  • R component (0-255)
  • G component (0-255)
  • B component (0-255)

Example

Request Topic

LYT/41e0d6b2-37de-43d8-a348-4ba94853b6cd/NODE/CONTROL

Request Payload

You can adjust any combination of r, g, and b components. Parameters not included in the request will maintain their current values.

Examples:

Adjust all components:

{      
"version": "v1.0",
"type": "rgb",
"address": 50646,
"r": 255,
"g": 127,
"b": 189
}

Field Descriptions

FieldTypeRangeDescription
versionstring"v1.0"API version identifier
typestring"rgb"Message type for RGB control
addressnumbernode addressUnicast address of the target node
rnumber0-255Hue value (0-255) - Represents the color position
gnumber0-255Saturation value (0-255) - Represents color intensity
bnumber0-255Lightness value (0-255) - Represents brightness level

Response topic

LYT/41e0d6b2-37de-43d8-a348-4ba94853b6cd/NODE/E/STATUS

Response Payload

Success Response

{
"version": "v1.0",
"message": "success",
"type": "rgb",
"address": 50646,
"rgb": {
"r": 255,
"g": 127,
"b": 189
}
}

Error Handling

The API may return various error responses based on different scenarios. Here are the possible errors and their resolutions:

1. Constraint Errors (Code: 3005)

a. Red Component Constraint:

{
"message": "error",
"message_type": {
"code": 3005,
"message": "r must be between 0 and 255",
"errorCode": "CONSTRAINT_ERROR"
},
"type": "rgb",
"address": 50646
}

b. Green Component Constraint:

{
"message": "error",
"message_type": {
"code": 3005,
"message": "g must be between 0 and 255",
"errorCode": "CONSTRAINT_ERROR"
},
"type": "rgb",
"address": 50646
}

c. Blue Component Constraint:

{
"message": "error",
"message_type": {
"code": 3005,
"message": "b must be between 0 and 255",
"errorCode": "CONSTRAINT_ERROR"
},
"type": "rgb",
"address": 50646
}

d. Version Constraint:

{
"message": "error",
"message_type": {
"code": 3005,
"message": "version must be equal to v1.0",
"errorCode": "CONSTRAINT_ERROR"
},
"type": "rgb",
"address": 50646
}

e. Type Constraint:

{
"message": "error",
"message_type": {
"code": 3005,
"message": "type must be one of the following values: cct, dimmer, switch, fan, curtain, rgb",
"errorCode": "CONSTRAINT_ERROR"
},
"type": "rgb",
"address": 50646
}

f. Address Constraint:

{
"message": "error",
"message_type": {
"code": 3005,
"message": "address must be a number conforming to the specified constraints",
"errorCode": "CONSTRAINT_ERROR"
},
"type": "rgb",
"address": 50646
}

Constraint errors occur in the following cases:

  1. Red Component Constraints:

    • r value exceeds 255
    • r field is missing when required
    • r value is less than 0
  2. Green Component Constraints:

    • g value exceeds 255
    • g field is missing when required
    • g value is less than 0
  3. Blue Component Constraints:

    • b value exceeds 255
    • b field is missing when required
    • b value is less than 0
  4. Version Constraints:

    • Version is not exactly "v1.0"
    • Version field is missing
    • Version field has incorrect format
  5. Type Constraints:

    • Type must be one of: "cct", "dimmer", "switch", "fan", "curtain", "rgb"
    • Type field is missing
    • Type field has incorrect value
  6. Address Constraints:

    • Address must be a number
    • Address field is missing
    • Address field has incorrect type (must be number)

Resolution:

  • Ensure red is between 0-255
  • Ensure green is between 0-255
  • Ensure blue is between 0-255
  • Always use "v1.0" as the version value
  • Use correct type value from allowed list: "cct", "dimmer", "switch", "fan", "curtain", "rgb"
  • Ensure address is a number
  • Validate all parameters before sending

2. Node Not Found (Code: 2028)

{
"message": "error",
"message_type": {
"code": 2028,
"message": "Node not found",
"errorCode": "NODE_NOT_FOUND"
},
"type": "rgb",
"address": 50646
}

Occurs when:

  • The specified node address doesn't exist
  • Node is offline or unreachable
  • Node has been removed from the network

Resolution:

  • Verify node address is correct
  • Check if node is powered and connected
  • Confirm node is properly provisioned

3. Project Not Found (Code: 2002)

{
"message": "error",
"message_type": {
"code": 2002,
"message": "Project not found",
"errorCode": "PROJECT_NOT_FOUND"
},
"type": "rgb",
"address": 50646
}

Occurs when:

  • project_uuid in MQTT topic is invalid
  • Project has been deleted
  • User doesn't have access to the project

Resolution:

  • Verify project_uuid
  • Ensure project exists
  • Check access permissions

4. Request Timeout (Code: 3002)

{
"message": "error",
"message_type": {
"code": 3002,
"message": "Request Timeout",
"errorCode": "REQUEST_TIMEOUT"
},
"type": "rgb",
"address": 50646
}

Occurs when:

  • Node doesn't respond within timeout period
  • Network connectivity issues
  • Node is busy processing other commands

Resolution:

  • Check network connectivity
  • Verify node is responsive
  • Retry the request
  • Check for network congestion

Error Code Summary

CodeError CodeDescriptionSolution
3005CONSTRAINT_ERRORParameter validation failedCheck input values
2028NODE_NOT_FOUNDNode not availableVerify node status
2002PROJECT_NOT_FOUNDProject doesn't existCheck project_uuid
3002REQUEST_TIMEOUTRequest took too longCheck connectivity