SetVariables
Sent by the CSMS to update one or more configuration variable values on the Charging Station. Replaces ChangeConfiguration from OCPP 1.6J.
Quick Reference
Required Fields
setVariableData array[SetVariableDataType] List of variables to set, each with component, variable, and attributeValue
setVariableData[].attributeValue string(1000) The new value to set for the variable
setVariableData[].component ComponentType Component that owns the variable
setVariableData[].variable VariableType Variable to set
Optional Fields
setVariableData[].attributeType AttributeEnumType Attribute to set: Actual (default), Target, MinSet, MaxSet
Example Payload
{
"setVariableData": [
{
"component": {
"name": "HeartbeatCtrlr"
},
"variable": {
"name": "HeartbeatInterval"
},
"attributeValue": "60"
},
{
"component": {
"name": "SmartChargingCtrlr"
},
"variable": {
"name": "Enabled"
},
"attributeValue": "true"
}
]
} Example Full Frame
[
2,
"msg-001",
"SetVariables",
{
"setVariableData": [
{
"component": {
"name": "HeartbeatCtrlr"
},
"variable": {
"name": "HeartbeatInterval"
},
"attributeValue": "60"
},
{
"component": {
"name": "SmartChargingCtrlr"
},
"variable": {
"name": "Enabled"
},
"attributeValue": "true"
}
]
}
]
Format: [MessageType, MessageId, Action, Payload]
Overview
SetVariables updates configuration variables on the Charging Station using the Component/Variable model. It replaces ChangeConfiguration from OCPP 1.6J.
When to Send
- To update the heartbeat interval
- To enable or disable smart charging
- To configure meter value reporting intervals
- Any time a Charging Station configuration parameter needs to change
Expected Response
The Charging Station responds with:
setVariableResult: Array of results, one per variableattributeStatus:Accepted,Rejected,UnknownComponent,UnknownVariable,NotSupportedAttributeType, orRebootRequired
RebootRequired means the change will only take effect after a Charging Station restart.
Key Differences from OCPP 1.6J
| OCPP 1.6J | OCPP 2.0.1 |
|---|---|
ChangeConfiguration | SetVariables |
key: "HeartbeatInterval", value: "60" | component/variable/attributeValue structure |
| Single key-value pair | Multiple variables in one request |
Usage Notes
- All
attributeValuevalues are strings, even for numbers and booleans:"60","true" - A single
SetVariablesrequest can change multiple variables at once - Check each result individually — partial success is possible
Testing Tips
- Set
HeartbeatIntervaland verify the station starts heartbeating at the new interval - Test setting a read-only variable and verify
Rejectedresponse - Test
RebootRequiredscenario and verify the variable takes effect after Reset
Common Errors
TypeConstraintViolation
Cause: Sending key/value pairs instead of component/variable objects
Solution: OCPP 2.0.1 requires structured component and variable objects, not flat key strings
PropertyConstraintViolation
Cause: attributeValue exceeds 1000 characters
Solution: Keep attribute values under 1000 characters