Skip to main content

Control Fan

Control fans by setting their speed level.

Description

The fan control allows you to manage fan by setting:

  • fan_speed component (levels 1-5)

Example

Request Topic

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

Request Payload

You can control the fan speed level. The fan_speed parameter is required in the request.

Examples:

Set fan_speed :

{      
"version": "v1.0",
"type": "fan",
"address": 50646,
"fan_speed": 3
}

Field Descriptions

FieldTypeRangeDescription
versionstring"v1.0"API version identifier
typestring"fan"Message type for fan control
addressnumbernode addressUnicast address of the target node
fan_speednumber1-5Fan speed level

Response topic

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

Response Payload

Success Response

{
"version": "v1.0",
"message": "success",
"type": "fan",
"address": 50646,
"fan": {
"fan_speed": 3
}
}

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

{
"message": "error",
"message_type": {
"code": 3005,
"message": "fan_speed must be an integer between 0 to 4",
"errorCode": "CONSTRAINT_ERROR"
},
"type": "fan",
"address": 50646
}

b. Version Constraint:

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

c. Type Constraint:

{
"message": "error",
"message_type": {
"code": 3005,
"message": "type must be one of the following values: cct, dimmer, switch, fan_speed, curtain-level, rgb",
"errorCode": "CONSTRAINT_ERROR"
},
"type": "fan",
"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": "fan",
"address": 50646
}

Constraint errors occur in the following cases:

  1. fan_speed Constraints:

    • fan_speed value must be between 0 to 4
    • fan_speed field is missing
    • fan_speed field must be number
  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 fan_speed is an number between 0 to 4
  • 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 Error (Code: 4004)

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

3. Project Not Found Error (Code: 4003)

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

4. Request Timeout Error (Code: 5001)

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

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