This project demonstrates a simple OCPP 1.6J (Open Charge Point Protocol) client implemented in Python. It simulates a charging station (Charge Point) communicating with a CSMS (Central System) using WebSocket connections.
-
Fully asynchronous architecture using
asyncioandwebsockets -
Implements OCPP 1.6J (JSON over WebSocket)
-
Uses
@onand@afterdecorators for event-based message handling -
Simulates realistic transaction workflow:
- BootNotification
- StatusNotification (Preparing → Charging → Finishing → Available)
- StartTransaction / StopTransaction
- Periodic MeterValues
- Supports DataTransfer, FirmwareUpdate, ReserveNow, and more
Python 3.10 or later is recommended.
pip install asyncio websockets ocpp nest_asyncio- Start an OCPP 1.6J CSMS server (e.g., mobilityhouse/ocpp).
- Run the client:
python ocpp_client.pyDefault WebSocket URL:
ws_url = "ws://localhost:8000/OCPP/1/CP2"You can change the URL inside the main() function.
When the CSMS sends a RemoteStartTransaction request, the client performs:
- CP →
StatusNotification (Preparing) - CP →
StartTransaction - CP →
DataTransfer - CP →
MeterValues(SoC, Voltage, Current, Energy) - CP →
StopTransaction - CP →
StatusNotification (Available)
- Designed for testing and demo purposes.
- Can be easily extended with additional OCPP actions or integrated with real hardware.
- Tested against both Python and .NET CSMS implementations.
MIT License — free to use, modify, and distribute.
Burak Duman Embedded & Backend Developer | OCPP · IoT · Python GitHub · LinkedIn- Added note about WebSocket URL configuration.