Skip to main content

Python package implementing the JSON version of the Open Charge Point Protocol (OCPP).

Project description


Python package implementing the JSON version of the Open Charge Point Protocol (OCPP). Currently OCPP 1.6 (errata v4) and OCPP 2.0 are supported.

You can find the documentation on rtd.


You can either the project install from Pypi:

$ pip install ocpp

Or clone the project and install it manually using:

$ pip install .

Quick start

Below you can find examples on how to create a simple OCPP 2.0 central system as well as an OCPP 2.0 charge point.


To run these examples the dependency websockets is required! Install it by running:

$ pip install websockets

Central system

The code snippet below creates a simple OCPP 2.0 central system which is able to handle BootNotification calls. You can find a detailed explanation of the code in the Central System documentation_.

import asyncio
import websockets
from datetime import datetime

from ocpp.routing import on
from ocpp.v20 import ChargePoint as cp
from ocpp.v20 import call_result

class ChargePoint(cp):
    def on_boot_notitication(self, charging_station, reason, **kwargs):
        return call_result.BootNotificationPayload(

async def on_connect(websocket, path):
    """ For every new charge point that connects, create a ChargePoint instance
    and start listening for messages.

    charge_point_id = path.strip('/')
    cp = ChargePoint(charge_point_id, websocket)

    await cp.start()

async def main():
    server = await websockets.serve(

    await server.wait_closed()

if __name__ == '__main__':

Charge point

import asyncio
import websockets

from ocpp.v20 import call
from ocpp.v20 import ChargePoint as cp

class ChargePoint(cp):

    async def send_boot_notification(self):
        request = call.BootNotificationPayload(
                    'model': 'Wallbox XYZ',
                    'vendor_name': 'anewone'
        response = await

        if response.status == 'Accepted':
            print("Connected to central system.")

async def main():
    async with websockets.connect(
    ) as ws:

        cp = ChargePoint('CP_1', ws)

        await asyncio.gather(cp.start(), cp.send_boot_notification())

if __name__ == '__main__':


Except from the documents in docs/v16/specification/ everything is licensed under MIT. © The Mobility House

The documents in docs/v16/specification/ are licensed under Creative Commons Attribution-NoDerivatives 4.0 International Public License.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ocpp, version 0.5.1
Filename, size File type Python version Upload date Hashes
Filename, size ocpp-0.5.1-py3-none-any.whl (119.8 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size ocpp-0.5.1.tar.gz (43.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page