Skip to main content

Control Switch Group

Control switches by setting their power state.

Description

The switch control allows you to manage switch's power by setting:

  • power component (true/false)

Example

Request Topic

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

Request Payload

You can control the power state of the switch. The power parameter is required in the request.

Examples:

Turn switch on:

{      
"version": "v1.0",
"type": "switch",
"address": 50646,
"power": true
}

Turn switch off:

{      
"version": "v1.0",
"type": "switch",
"address": 50646,
"power": false
}

Field Descriptions

FieldTypeRangeDescription
versionstring"v1.0"API version identifier
typestring"switch"Message type for switch control
addressnumbergroup addressUnicast address of the target group
powerbooleantrue/falsePower state of the switch

Response topic

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

Response Payload

Success Response

{
"version": "v1.0",
"message": "success",
"type": "switch",
"address": 50646,
"switch" : {
"power": true
}
}

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. Power Constraint:

{
"message": "error",
"message_type": {
"code": 3005,
"message": "power must be a boolean value",
"errorCode": "CONSTRAINT_ERROR"
},
"type": "switch",
"address": 50646
}

b. Version Constraint:

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

c. 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": "switch",
"address": 50646
}

d. Address Constraint:

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

Constraint errors occur in the following cases:

  1. Power Constraints:

    • power value must be true or false
    • power field is missing
    • power field has incorrect type (must be boolean)
  2. Version Constraints:

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

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

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

Resolution:

  • Ensure power is a boolean value (true/false)
  • 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. Group Not Found (Code: 2028)

{
"message": "error",
"message_type": {
"code": 3006,
"message": "Group not found",
"errorCode": "GROUP_NOT_FOUND"
},
"type": "switch",
"address": 50646
}

Occurs when:

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

Resolution:

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

3. Project Not Found (Code: 2002)

{
"message": "error",
"message_type": {
"code": 2002,
"message": "Project not found",
"errorCode": "PROJECT_NOT_FOUND"
},
"type": "switch",
"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": "switch",
"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
3006GROUP_NOT_FOUNDGroup not availableVerify group status
2002PROJECT_NOT_FOUNDProject doesn't existCheck project_uuid
3002REQUEST_TIMEOUTRequest took too longCheck connectivity