Docs › OCPI-CPO

OCPI-CPO: Ihren eMSP testen

Ein virtueller Ladepunktbetreiber nach OCPI 2.2.1. Dahinter stehen echte simulierte Ladepunkte: Sessions verbrauchen Energie, Tarife ergeben Kosten, Kommandos laufen zweistufig wie bei echten Betreibern.

1. CPO anlegen

Unter OCPI-CPO Name, Ländercode (2 Buchstaben) und Party-ID (3 Zeichen) angeben. Mit Demo-Daten entstehen vier Standorte mit je einem internen Ladepunkt (AC und DC) und drei Tarife. Sie können Standorte, Tarife und Ladepunkte danach frei ändern oder eigene anlegen.

2. Handshake (Credentials)

Variante A – Ihr eMSP startet (üblich): Die Seite des CPO zeigt die Versions-URL (https://ocpp-sim.dev/ocpi/<key>/versions) und Token A. Ihr eMSP

  1. ruft die Versions-URL und die Versionsdetails mit Authorization: Token <Base64(Token A)> ab,
  2. sendet POST credentials mit seinem Token B und seiner Versions-URL,
  3. bekommt Token C zurück und nutzt ab dann nur noch dieses.

Während Schritt 2 ruft der CPO Ihre Versions-URL mit Token B ab und merkt sich Ihre Endpunkte (für Push und Autorisierung). Ist Ihre Seite dabei nicht erreichbar, scheitert der Handshake mit Status 3001 – wie bei echten Partnern.

Variante B – der CPO startet: unter „Oder: Handshake von hier aus starten“ Ihre Versions-URL und ein Token A von Ihrem eMSP eintragen.

„Neues Token A (trennt den eMSP)“ setzt die Verbindung zurück. PUT credentials (Token erneuern) und DELETE credentials (abmelden) werden unterstützt.

3. Module

ModulRolleWas Ihr eMSP tun kann
credentialsSENDER/RECEIVERHandshake, Token erneuern, abmelden
locationsSENDERListe, einzelner Standort / EVSE / Connector
tariffsSENDERListe
sessionsSENDERListe mit date_from/date_to
cdrsSENDERListe mit date_from/date_to
tokensRECEIVERIhre Ladekarten pushen (PUT/PATCH), abfragen (GET)
commandsRECEIVERSTART_SESSION, STOP_SESSION, RESERVE_NOW, CANCEL_RESERVATION, UNLOCK_CONNECTOR

Blättern: höchstens 50 Einträge je Seite. Die nächste Seite steht im Link-Header (rel="next"), dazu X-Total-Count und X-Limit. Folgen Sie dem Link, statt mit eigenem limit zu rechnen – der CPO bestimmt die Seitengröße.

Sessions per ID: OCPI 2.2.1 kennt kein GET sessions/{id}. Suchen Sie in der Liste (date_from) oder lassen Sie sich die Session pushen.

4. Kommandos

Ein Kommando wird sofort mit ACCEPTED (oder einem Fehler) beantwortet; das eigentliche Ergebnis kommt danach als CommandResult per POST an Ihre response_url. Das CommandResult enthält laut Spezifikation keine Session-ID. Geben Sie bei START_SESSION eine authorization_reference mit – sie steht danach in Session und CDR, so finden Sie Ihren Vorgang wieder.

5. Push an Ihren eMSP

Nennt Ihr eMSP im Handshake Empfänger-Endpunkte, schickt der CPO:

6. Tarife und Zeittarife

Ein Tarif besteht wie in OCPI aus Elementen mit Preiskomponenten (ENERGY, FLAT, TIME, PARKING_TIME) und optionalen Einschränkungen. Für einfache Tarife reichen Preis je kWh, Startgebühr und Preis je Stunde. Für Zeittarife tragen Sie die Elemente als JSON ein – oder klicken „Beispiel: Tag/Nacht + Wochenende“:

[
  {"price_components": [{"type": "ENERGY", "price": 0.29, "step_size": 1}],
   "restrictions": {"start_time": "22:00", "end_time": "06:00"}},
  {"price_components": [{"type": "ENERGY", "price": 0.45, "step_size": 1}],
   "restrictions": {"day_of_week": ["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY"]}},
  {"price_components": [{"type": "ENERGY", "price": 0.39, "step_size": 1},
                        {"type": "FLAT",   "price": 0.50, "step_size": 1}]}
]

Es gilt je Zeitabschnitt das erste passende Element (wie in der Spezifikation). Unterstützte Einschränkungen: start_time/end_time (auch über Mitternacht), start_date/end_date, day_of_week, min_kwh/max_kwh, min_power/max_power, min_duration/max_duration. Maßgeblich ist die Zeitzone des Standorts.

Sessions und CDRs enthalten dazu charging_periods (ein Abschnitt je Wechsel des gültigen Elements) und die Summen total_energy_cost, total_time_cost, total_fixed_cost, total_parking_cost. step_size wird auf die Gesamtmenge angewandt, FLAT gilt einmal je Vorgang nach dem beim Start gültigen Element.

7. Ladekarten und Echtzeit-Autorisierung

Hält jemand an einem Ladepunkt des CPO eine Karte vor (Knopf „Karte vorhalten“ oder per API), entscheidet der CPO so:

  1. Hat Ihr eMSP die Karte per PUT tokens gepusht und ist sie valid: false → abgelehnt (Blocked).
  2. Gepushte Karte mit whitelist: ALWAYS → sofort erlaubt, ohne Rückfrage.
  3. Sonst Echtzeit-Anfrage an Ihren eMSP (wenn er tokens als SENDER anbietet):
    POST {tokens-URL Ihres eMSP}/{uid}/authorize?type=RFID
    {"location_id": "LOC1", "evse_uids": ["BER1-1", "BER1-2"]}
    
    → {"allowed": "ALLOWED", "token": {…}, "authorization_reference": "ABC123"}
    Ihre Antwort (ALLOWED, BLOCKED, EXPIRED, NO_CREDIT, NOT_ALLOWED) wird an den Ladepunkt weitergegeben. Antworten Sie mit HTTP 404, gilt die Karte als unbekannt.
  4. Ist Ihr eMSP nicht erreichbar, gilt eine gepushte Karte mit ALLOWED/ALLOWED_OFFLINE als erlaubt.

Ohne verbundenen eMSP ist jede Karte erlaubt (Demo-Betrieb). Session und CDR tragen die Karte als cdr_token, dazu auth_method (WHITELIST, AUTH_REQUEST oder bei Fernstart COMMAND) und Ihre authorization_reference. Die gepushten Karten sehen Sie auf der Seite des CPO.

8. Strenger Modus und TLS

Strenger Modus (empfohlen): Anfragen ohne X-Request-ID/X-Correlation-ID oder mit Token ohne Base64 werden abgelehnt (Status 2001) – so verhalten sich strenge Partner. Ohne strengen Modus werden sie angenommen, aber im Protokoll als Hinweis markiert. Routing-Header (OCPI-from-…/OCPI-to-…) werden gesetzt und ausgewertet.

Selbstsignierte Zertifikate beim eMSP annehmen: für eMSP-Testsysteme mit selbstsigniertem Zertifikat.

9. Fehlerinjektion

Damit Sie testen können, was bei echten Partnern früher oder später passiert. Einstellbar auf der Seite des CPO oder per API (PATCH /api/cpos/{id} mit {"faults": {…}}):

KeyWerteWirkung
command_resultnormal · delay · none · timeout · failed · rejectedWas nach START_SESSION/STOP_SESSION an Ihre response_url geht. delay: erst nach „Verzögerung“ Sekunden. none: nie. timeout/failed/rejected: dieses Ergebnis, der Ladepunkt tut nichts.
command_delay_s1–600Verzögerung für delay.
cdrnormal · none · late · duplicatenone: kein CDR, weder per Push noch in GET cdrs. late: erst nach „CDR-Verzögerung“ – auch GET cdrs zeigt ihn vorher nicht. duplicate: derselbe CDR wird zweimal gepusht (prüft Ihre Duplikaterkennung).
cdr_delay_s5–3600Verzögerung für late.
session_pushnormal · nonenone: keine Session-Pushes; Ihr eMSP muss per GET sessions abfragen.
response_delay_ms0–60000Jede Antwort der Fachmodule (Locations, Tariffs, Sessions, CDRs, Tokens, Commands) kommt so viel später.
error_rate0–1Anteil der Anfragen an Fachmodule, die mit einem Fehler beantwortet werden.
error_code2000 · 2001 · 2003 · 3000 · 3001OCPI-Statuscode dieser Fehler. 2xxx kommt mit HTTP 400, 3xxx mit HTTP 500.
pagingnormal · no_link · wrong_total · ignore_limitno_link: kein Link-Header, obwohl es weitere Seiten gibt. wrong_total: X-Total-Count zu hoch. ignore_limit: liefert mehr als das angefragte limit.

Handshake (credentials) und Versionsabfragen sind von Fehlerinjektion ausgenommen, damit Sie die Verbindung nicht verlieren.

10. Protokoll

Jede OCPI-Anfrage in beide Richtungen steht im Protokoll des CPO: Methode, URL, Status, Inhalt und Hinweise auf Abweichungen von der Spezifikation (z. B. fehlende Header, Token ohne Base64, fehlende Pflichtfelder).

OCPI CPO: test your eMSP

A virtual charge point operator speaking OCPI 2.2.1. Real simulated charge points stand behind it: sessions consume energy, tariffs produce costs, commands are asynchronous like with real operators.

1. Create a CPO

Under OCPI CPO, enter a name, country code (2 letters) and party ID (3 characters). With demo data you get four locations with one internal charge point each (AC and DC) and three tariffs. You can change locations, tariffs and charge points freely or add your own.

2. Handshake (credentials)

Option A – your eMSP starts (common): the CPO page shows the versions URL (https://ocpp-sim.dev/ocpi/<key>/versions) and token A. Your eMSP

  1. fetches the versions URL and version details with Authorization: Token <Base64(token A)>,
  2. sends POST credentials with its token B and its own versions URL,
  3. receives token C and uses only that from then on.

During step 2 the CPO fetches your versions URL with token B and stores your endpoints (for push and authorization). If your side is unreachable then, the handshake fails with status 3001 – like with real partners.

Option B – the CPO starts: under “Or: start the handshake from here”, enter your versions URL and a token A from your eMSP.

“New token A” resets the connection. PUT credentials (renew token) and DELETE credentials (unregister) are supported.

3. Modules

ModuleRoleWhat your eMSP can do
credentialsSENDER/RECEIVERHandshake, renew token, unregister
locationsSENDERList, single location / EVSE / connector
tariffsSENDERList
sessionsSENDERList with date_from/date_to
cdrsSENDERList with date_from/date_to
tokensRECEIVERPush your charging cards (PUT/PATCH), read them (GET)
commandsRECEIVERSTART_SESSION, STOP_SESSION, RESERVE_NOW, CANCEL_RESERVATION, UNLOCK_CONNECTOR

Pagination: at most 50 items per page. The next page is in the Link header (rel="next"), together with X-Total-Count and X-Limit. Follow the link rather than computing with your own limit – the CPO decides the page size.

Sessions by ID: OCPI 2.2.1 has no GET sessions/{id}. Search the list (date_from) or have the session pushed to you.

4. Commands

A command is answered immediately with ACCEPTED (or an error); the actual result follows as a CommandResult POSTed to your response_url. Per specification the CommandResult contains no session ID. Send an authorization_reference with START_SESSION – it then appears in the session and CDR, which is how you find your transaction again.

5. Push to your eMSP

If your eMSP lists receiver endpoints in the handshake, the CPO sends:

6. Tariffs and time-of-use tariffs

As in OCPI, a tariff consists of elements with price components (ENERGY, FLAT, TIME, PARKING_TIME) and optional restrictions. Simple tariffs only need a price per kWh, a start fee and a price per hour. For time-of-use tariffs enter the elements as JSON – or click “Example: day/night + weekend”:

[
  {"price_components": [{"type": "ENERGY", "price": 0.29, "step_size": 1}],
   "restrictions": {"start_time": "22:00", "end_time": "06:00"}},
  {"price_components": [{"type": "ENERGY", "price": 0.45, "step_size": 1}],
   "restrictions": {"day_of_week": ["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY"]}},
  {"price_components": [{"type": "ENERGY", "price": 0.39, "step_size": 1},
                        {"type": "FLAT",   "price": 0.50, "step_size": 1}]}
]

For each period the first matching element applies (as in the specification). Supported restrictions: start_time/end_time (also across midnight), start_date/end_date, day_of_week, min_kwh/max_kwh, min_power/max_power, min_duration/max_duration. The location's time zone is used.

Sessions and CDRs contain charging_periods (one period per change of the applicable element) and the totals total_energy_cost, total_time_cost, total_fixed_cost, total_parking_cost. step_size is applied to the total amount; FLAT applies once per session, from the element valid at start.

7. Charging cards and real-time authorization

When someone presents a card at one of the CPO's charge points (button “Present card” or via API), the CPO decides:

  1. Your eMSP pushed the card via PUT tokens with valid: false → rejected (Blocked).
  2. Pushed card with whitelist: ALWAYS → allowed immediately, no request.
  3. Otherwise a real-time request to your eMSP (if it offers tokens as SENDER):
    POST {tokens-URL Ihres eMSP}/{uid}/authorize?type=RFID
    {"location_id": "LOC1", "evse_uids": ["BER1-1", "BER1-2"]}
    
    → {"allowed": "ALLOWED", "token": {…}, "authorization_reference": "ABC123"}
    Your answer (ALLOWED, BLOCKED, EXPIRED, NO_CREDIT, NOT_ALLOWED) is passed on to the charge point. Answer HTTP 404 and the card counts as unknown.
  4. If your eMSP is unreachable, a pushed card with ALLOWED/ALLOWED_OFFLINE is allowed.

Without a connected eMSP every card is allowed (demo mode). Session and CDR carry the card as cdr_token, plus auth_method (WHITELIST, AUTH_REQUEST or, for remote start, COMMAND) and your authorization_reference. Pushed cards are listed on the CPO page.

8. Strict mode and TLS

Strict mode (recommended): requests without X-Request-ID/X-Correlation-ID or with a non-Base64 token are rejected (status 2001) – that is how strict partners behave. Without strict mode they are accepted but flagged in the log. Routing headers (OCPI-from-…/OCPI-to-…) are set and checked.

Accept self-signed certificates from the eMSP: for eMSP test systems with a self-signed certificate.

9. Fault injection

So you can test what sooner or later happens with real partners. Set it on the CPO page or via API (PATCH /api/cpos/{id} with {"faults": {…}}):

KeyValuesEffect
command_resultnormal · delay · none · timeout · failed · rejectedWhat is sent to your response_url after START_SESSION/STOP_SESSION. delay: only after “delay” seconds. none: never. timeout/failed/rejected: that result, the charge point does nothing.
command_delay_s1–600Delay used by delay.
cdrnormal · none · late · duplicatenone: no CDR, neither pushed nor in GET cdrs. late: only after “CDR delay” – GET cdrs does not show it before either. duplicate: the same CDR is pushed twice (tests your duplicate detection).
cdr_delay_s5–3600Delay used by late.
session_pushnormal · nonenone: no session pushes; your eMSP has to poll GET sessions.
response_delay_ms0–60000Every response of the functional modules (locations, tariffs, sessions, CDRs, tokens, commands) arrives this much later.
error_rate0–1Share of requests to functional modules that are answered with an error.
error_code2000 · 2001 · 2003 · 3000 · 3001OCPI status code of those errors. 2xxx comes with HTTP 400, 3xxx with HTTP 500.
pagingnormal · no_link · wrong_total · ignore_limitno_link: no Link header although more pages exist. wrong_total: X-Total-Count too high. ignore_limit: returns more than the requested limit.

The handshake (credentials) and version requests are exempt from fault injection so you don't lose the connection.

10. Log

Every OCPI request in both directions is in the CPO's log: method, URL, status, body and hints on deviations from the specification (e.g. missing headers, non-Base64 tokens, missing required fields).

Fehlt etwas oder ist etwas unklar? Fragen Sie im Forum.