Stand with Ukraine flag
Try it now Pricing
IoT Gateway
Community Edition Professional Edition Cloud Edge PE Edge IoT Gateway License Server Trendz Analytics Mobile Application PE Mobile Application MQTT Broker
Documentation > Configuration guides > OCPP Connector
Getting Started
Installation
On this page

OCPP Connector Configuration

This guide will help you get familiar with OCPP Connector configuration for ThingsBoard IoT Gateway. Use general configuration to enable this Connector. The purpose of this connector is to communicate between Charge Point and Central System using OCPP protocol.

We will describe the connector configuration file below.

Connector configuration: ocpp.json

Connector configuration is a JSON file that contains information about how to connect to Charge Points, process the data, and other service features. Let’s review the format of the configuration file using the example below.

Example of OCPP Connector config file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{
  "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}"
        }
      ]
    }
  ]
}

Section “centralSystem”

This configuration section is used to configure Gateway as a Central System.

Parameter Default value Description
name Central System Central System name.
host 127.0.0.1 Central System hostname or ip address.
port 9000 Central System port.

Connection subsection

This configuration subsection is used for configuring connection type between Central System and Charge Point. You can choose the next connection type:

Insecure connection type is the simplest option. It is useful for testing purpose but not recommended in production solution.

Parameter Default value Description
type insecure Type of connection.

Connection subsection in configuration file will look like this:

1
2
3
    "connection": {
      "type": "insecure"
    }

The table below describes the parameters to configure TLS connection.

Parameter Default value Description
key /etc/thingsboard-gateway/privateKey.pem Path to private key file.
cert /etc/thingsboard-gateway/certificate.pem Path to certificate file.
password YOUR_PASSWORD OPTIONAL Password for TLS connection

Connection subsection in configuration file will look like this:

1
2
3
4
5
    "connection": {
      "type": "tls",
      "key": "/etc/thingsboard-gateway/privateKey.pem",
      "cert": "/etc/thingsboard-gateway/certificate.pem"
    }

Security subsection

Security subsection provides configuration for Charge Point authorization at Central System. You can choose the desired security type:

Anonymous connection type is the simplest option. It is useful for testing purposes but not recommended in a production solution.

Security subsection in configuration file will look like this:

1
    "security": []

One type of security configuration is basic. For authorization, a combination of username/password provided in this section of the config will be used.

Parameter Default value Description
type basic Type of authorization.
credentials   List of allowed credentials.
… username username Username for authorization.
… password password Password for authorization.

Security subsection in configuration file will look like this:

1
2
3
4
5
6
7
8
9
    "security": [
      "type": "basic",
      "credentials": [
        {
          "username": "admin",
          "password": "admin"
        }
      ]
    ]

One type of security configuration is token. For authorization, token provided in this section of the config will be used.

Parameter Default value Description
type token Type of authorization.
tokens [“Bearer ACCESS_TOKEN”] List of allowed tokens.

Security subsection in configuration file will look like this:

1
2
3
4
5
6
    "security": [
      "type": "token",
      "tokens": [
        "Bearer ACCESS_TOKEN"
      ]
    ]

Note You can combine basic and token security types. Security subsection in configuration file will look like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
    "security": [
      {
        "type": "token",
        "tokens": [
          "Bearer ACCESS_TOKEN"
        ]
      },
      {
        "type": "basic",
        "credentials": [
          {
            "username": "admin",
            "password": "admin"
          }
        ]
      }
    ]

Section “chargePoints”

This subsection contains general settings for the Charge Points and subsections for processing data.

Parameter Default value Description
idRegexpPattern charge_points/CP_1 Regular expression, is used for looking the Charge Point for a current device.
deviceNameExpression ${Vendor} ${Model} Simple JSON expression, is used for looking up device name in the incoming message (parameter “Vendor + Model” will be used as the device name).
deviceTypeExpression ${Model} Simple JSON expression, is used for looking up device type in the incoming message (parameter “Model” will be used as the device type).
attributes   Array of objects for processing device attributes.
timeseries   Array of objects for processing device telemetry.
attributeUpdates   Array of objects for processing attributeUpdate requests from ThingsBoard.
serverSideRpc   Array of objects for processing RPC requests from ThingsBoard.

This part of configuration will look like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  "chargePoints": [
    {
      "idRegexpPattern": "charge_points/CP_1",
      "deviceNameExpression": "${Vendor} ${Model}",
      "deviceTypeExpression": "${Model}",
      "attributes": [
        ...
      ],
      "timeseries": [
        ...
      ],
      "attributeUpdates": [
        ...
      ],
      "serverSideRpc": [
        ...
      ]
    }
  ]

Subsection attributes

This subsection contains general settings for processing data interpreted as attributes.

Parameter Default value Description
attributes   This subsection contains parameters of the incoming message, to be interpreted as attributes for the device.
… messageTypeFilter MeterValues, List of allowed message types divided by comma.
… key temp Attribute name, to be sent to ThingsBoard instance.
… value ${meter_value[:].sampled_value[:].value} Simple JSON expression, is used for looking up value in the incoming message, which will then be sent to ThingsBoard instance as the value of the key parameter.

This subsection in configuration file looks like:

1
2
3
4
5
6
7
8
9
10
11
12
      "attributes": [
        {
          "messageTypeFilter": "MeterValues,",
          "key": "temp",
          "value": "${meter_value[:].sampled_value[:].value}"
        },
        {
          "messageTypeFilter": "MeterValues,",
          "key": "vendorId",
          "value": "${connector_id}"
        }
      ]

Subsection time series

This subsection contains general settings for processing data interpreted as time series.

Parameter Default value Description
timeseries   This subsection contains parameters of the incoming message, to be interpreted as telemetry for the device.
… messageTypeFilter MeterValues, List of allowed message types divided by comma.
… key temp Telemetry name, to be sent to ThingsBoard instance.
… value ${meter_value[:].sampled_value[:].value} Simple JSON expression, is used for looking up value in the incoming message, which will then be sent to ThingsBoard instance as the value of the key parameter.

This subsection in configuration file looks like:

1
2
3
4
5
6
7
      "timeseries": [
        {
          "messageTypeFilter": "DataTransfer,",
          "key": "temp",
          "value": "${data.temp}"
        }
      ]

Attribute updates subsection

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.

Parameter Default value Description
attributeOnThingsBoard sharedName Shared attribute name.
valueExpression {"${attributeKey}":"${attributeValue}"} JSON-path expression is used for creating the message data that will be sent to Charge Point.

This section in configuration file looks like:

1
2
3
4
5
6
"attributeUpdates": [
  {
    "attributeOnThingsBoard": "shared",
    "valueExpression": "{\"${attributeKey}\":\"${attributeValue}\"}"
  }
]

Server side RPC subsection

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.

Parameter Default value Description
methodRPC rpcMethod1 RPC method name.
withResponse true Boolean value that determines whether to send response back to ThingsBoard.
valueExpression ${params} JSON-path expression uses for creating the message data that will send to Charge Point.

This subsection in configuration file looks like:

1
2
3
4
5
6
7
"serverSideRpc": [
  {
    "methodRPC": "rpc1",
    "withResponse": true,
    "valueExpression": "${params}"
  }
]

Next steps

Explore guides related to main ThingsBoard features: