Skip to content
Stand with Ukraine flag

OCPP

The OCPP Connector acts as a Central System, letting the gateway communicate with OCPP-compliant Charge Points and forward their data to ThingsBoard.

To enable this connector, add it to the connectors list in tb_gateway.json — see the General Configuration reference.

The connector reads its settings from a JSON file. Below is a full example:

{
"centralSystem": {
"name": "Central System",
"host": "127.0.0.1",
"port": 9000,
"connection": {
"type": "insecure"
},
"security": [
{
"type": "token",
"tokens": [
"Bearer ACCESS_TOKEN"
]
},
{
"type": "basic",
"credentials": [
{
"username": "admin",
"password": "admin"
}
]
}
]
},
"chargePoints": [
{
"idRegexpPattern": "bidon/hello/CP_1",
"deviceNameExpression": "${Vendor} ${Model}",
"deviceTypeExpression": "default",
"attributes": [
{
"messageTypeFilter": "MeterValues,",
"key": "temp1",
"value": "${meter_value[:].sampled_value[:].value}"
},
{
"messageTypeFilter": "MeterValues,",
"key": "vendorId",
"value": "${connector_id}"
}
],
"timeseries": [
{
"messageTypeFilter": "DataTransfer,",
"key": "temp",
"value": "${data.temp}"
}
],
"attributeUpdates": [
{
"attributeOnThingsBoard": "shared",
"valueExpression": "{\"${attributeKey}\":\"${attributeValue}\"}"
}
],
"serverSideRpc": [
{
"methodRPC": "rpc1",
"withResponse": true,
"valueExpression": "${params}"
}
]
}
]
}

Configures the gateway as an OCPP Central System — it listens for incoming Charge Point connections on the specified host and port.

ParameterDefaultDescription
nameCentral SystemDisplay name for the Central System
host127.0.0.1Hostname or IP address the Central System binds to
port9000Port the Central System listens on

Configures the transport security between the Central System and Charge Points.

Plain WebSocket connection with no transport security. Suitable for testing, not recommended for production.

ParameterDefaultDescription
typeinsecureConnection type
"connection": {
"type": "insecure"
}

Configures how Charge Points authenticate themselves when connecting to the Central System. An empty array disables authentication.

No authentication. Suitable for testing, not recommended for production.

"security": []

An array of Charge Point configurations. Each entry matches incoming connections by idRegexpPattern and defines how to name the corresponding ThingsBoard device and map its data.

ParameterDefaultDescription
idRegexpPatternRegular expression matched against the Charge Point identifier
deviceNameExpressionExpression to extract the device name from the BootNotification message
deviceTypeExpressionExpression to extract the device type from the BootNotification message
attributesMappings from OCPP messages to ThingsBoard device attributes
timeseriesMappings from OCPP messages to ThingsBoard time-series telemetry
attributeUpdatesConfiguration for pushing shared attribute updates to the Charge Point
serverSideRpcConfiguration for forwarding ThingsBoard RPC calls to the Charge Point
"chargePoints": [
{
"idRegexpPattern": "charge_points/CP_1",
"deviceNameExpression": "${Vendor} ${Model}",
"deviceTypeExpression": "${Model}",
"attributes": [ ... ],
"timeseries": [ ... ],
"attributeUpdates": [ ... ],
"serverSideRpc": [ ... ]
}
]

Subsections “attributes” and “timeseries”

Section titled “Subsections “attributes” and “timeseries””

Both sections use the same field structure. attributes values are stored as device attributes in ThingsBoard; timeseries values are stored as time-series telemetry.

ParameterDescription
messageTypeFilterComma-separated list of OCPP message types this mapping applies to
keyThingsBoard attribute or telemetry key name
valueJSON-path expression to extract the value from the incoming message
"attributes": [
{
"messageTypeFilter": "MeterValues,",
"key": "temp1",
"value": "${meter_value[:].sampled_value[:].value}"
},
{
"messageTypeFilter": "MeterValues,",
"key": "vendorId",
"value": "${connector_id}"
}
],
"timeseries": [
{
"messageTypeFilter": "DataTransfer,",
"key": "temp",
"value": "${data.temp}"
}
]

This configuration section is optional. ThingsBoard allows the provisioning of device attributes and fetches some of them from the device application. You can treat this as a remote configuration for devices, enabling them to request shared attributes from ThingsBoard. See user guide for more details.

The “attributeUpdates” configuration allows you to configure the format of the corresponding attribute data that will be sent to the Charge Point.

ParameterDescription
attributeOnThingsBoardShared attribute name to subscribe to
valueExpressionJSON-path expression used to build the message payload sent to the Charge Point
"attributeUpdates": [
{
"attributeOnThingsBoard": "shared",
"valueExpression": "{\"${attributeKey}\":\"${attributeValue}\"}"
}
]

ThingsBoard allows sending RPC commands to the device connected to ThingsBoard directly or via Gateway.

Configuration, provided in this section is used for sending RPC requests from ThingsBoard to Charge Point.

ParameterDefaultDescription
methodRPCRPC method name to bind
withResponsetrueSend the Charge Point’s response back to ThingsBoard
valueExpressionJSON-path expression used to build the message payload sent to the Charge Point
"serverSideRpc": [
{
"methodRPC": "rpc1",
"withResponse": true,
"valueExpression": "${params}"
}
]