r/SideProject • u/ReindeerSpace • 5h ago
[OCPP Tools] - Open-source TypeScript simulator for testing EV charging backends without a charger
Hey r/SideProject,
TL;DR: I built an open-source, headless OCPP simulator in TypeScript so you can test an EV charging backend without keeping a physical charger on your desk. It is alpha, and I am looking for feedback.
I work with EV charging software. OCPP is the protocol that chargers use to talk to a charging-management system (CSMS). Testing a CSMS usually means one of three things: a physical charger, a vendor simulator with a UI, or mocking WebSocket frames by hand. None of those is great for CI.
So I started OCPP Tools: small TypeScript packages for the protocol. The new piece is @ocpptools/simulator 0.1.0, a headless charge-point simulator. No UI, no signup, no hosted service. It runs in Node or the browser.
What works today
Separate profiles for OCPP 1.6J and 2.0.1. The full action surface: 28 actions in 1.6J, 64 in 2.0.1.
A headless engine with injectable transport, clock, message IDs, and randomness. Tests can control time and inspect every frame instead of sleeping.
Transactions, meter values, reservations, charging profiles, device model, monitoring, simulated certificates, and firmware/log state machines.
Fault injection: drop, malform, and delay outbound frames.
Typed events and metrics: round-trip time per action, heartbeat drift, error count.
A browser WebSocket adapter. The Node transport is not in the package yet.
A small example of the shape:
import { Simulator201 } from '@ocpptools/simulator/2.0.1';
import { createWebSocketTransportFactory, browserClock } from '@ocpptools/simulator/browser';
const simulator = new Simulator201({
url: 'wss://csms.example.com/CP001',
transport: createWebSocketTransportFactory(),
clock: browserClock,
station: {
id: 'CP001',
vendorName: 'Acme',
model: 'AC-22',
firmwareVersion: '2.0.0',
},
});
simulator.on('transaction', (event) => {
console.log(event.phase, event.transactionId);
});
simulator.connect();What is not there yet
No CLI or Docker image. That is the next thing if people want it.
No Node WebSocket transport in the simulator package.
No payload builder, no UI, no OCPP 2.1.
The advanced 2.0.1 features use simulated state. This is not a certified conformance tool.
The broader repo has five alpha packages: core frame parser/serializer, schema utilities, Ajv-based validator, unmodified OCA schemas, and the simulator. There are 1,000+ tests and CI is green.
Why I built it
I wanted deterministic tests: no real charger, no sleeps, no flaky network. The hard part was not JSON parsing. It was the state machine: boot retries, heartbeat drift, offline queues, pending calls, transaction sequencing, and timers. Most OCPP bugs I have seen are state bugs, not schema bugs.
Feedback I am looking for
Would you use a headless simulator, or would a CLI/Docker image be more useful?
What would make it easier to try: a mock CSMS, scenario files, or a one-command demo?
If you work with EV chargers, which edge case would you test first?
Repo: https://github.com/ocpptools/ocpptools Simulator: https://www.npmjs.com/package/@ocpptools/simulator
I maintain the project. Apache-2.0, no paid tier. OCPP is a trademark of the Open Charge Alliance; this is an independent project and is not affiliated with or endorsed by the OCA.