Skip to content

A simple Node.JS script simulating a OCPP 1.6 compatible Charging Station

Notifications You must be signed in to change notification settings

wirelane/ocpp-client-simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OCPP Client Simulator

This project is very simple, yet helpful command-line based simulator of a charging station connecting to an OCPP Server using OCPP 1.6 (JSON/WS).

At Wirelane, we use it for simulating difference OCPP-related scenarios before performing actual E2E integration tests with actual charging stations.

Some use-cases often encountered are built in (Authorization using UIDs of a RFID card, RemoteStart/RemoteStop). But as the code is very straight-forward and doesn't try to be clever or sophisticated, it can be easily customized to test out other scenarios, too.

Docker Build

$ docker build . -t ocpp-client-simulator

Local Node.JS-based build

npm ci

Run

For each command, both the docker command and the local Node.JS-based variant is given.

$ docker run -it --init \
    -e WEBSOCKET_URL=wss://ocpp.mycompany.com/cpms/ocppj/DEWLNERTP1 \
    ocpp-client-simulator
$ WEBSOCKET_URL=wss://ocpp.mycompany.com/cpms/ocppj/DEWLNERTP1 \
    node index.js

This connects the simulator to the OCPP server. It waits for a RemoteStart and then explicitly ask whether to accept it or not. To auto-accept RemoteStarts and RemoteStops, use the AUTO_ACCEPT-parameter:

$ docker run -it --init \
    -e WEBSOCKET_URL=wss://ocpp.mycompany.com/cpms/ocppj/DEWLNERTP1 \
    -e AUTO_ACCEPT=true \
    ocpp-client-simulator
$ WEBSOCKET_URL=wss://ocpp.mycompany.com/cpms/ocppj/DEWLNERTP1 \
    AUTO_ACCEPT=true \
    node index.js

Add NFC_UID parameter to trigger an authorization request after 15 seconds, NFC_UID_CHARGING_SECONDS to stop it after another x seconds again, and SEND_SIGNED_METER_VALUES=1 to send a fake signed XML at StopTransaction:

$ docker run -it --init \
    -e WEBSOCKET_URL=wss://ocpp.mycompany.com/cpms/ocppj/DEWLNERTP1 \
    -e NFC_UID=042F3C7A3F3480 \
    -e NFC_UID_CHARGING_SECONDS=5 \
    -e SEND_SIGNED_METER_VALUES=1 \
    ocpp-client-simulator
$ WEBSOCKET_URL=wss://ocpp.mycompany.com/cpms/ocppj/DEWLNERTP1 \
    NFC_UID=042F3C7A3F3480 \
    NFC_UID_CHARGING_SECONDS=5 \
    SEND_SIGNED_METER_VALUES=1 \
    node index.js

Add number of connectors (CONNECTOR_COUNT) and the default connector to use for RFID charging or RemoteStartTransaction without connectorId (DEFAULT_CONNECTOR_ID) optionally. You can use following command for that

$ docker run -it --init \
    -e WEBSOCKET_URL=wss://ocpp.mycompany.com/cpms/ocppj/DEWLNERTP1 \
    -e CONNECTOR_COUNT=3 \
    -e DEFAULT_CONNECTOR_ID=2 \
    ocpp-client-simulator
$ WEBSOCKET_URL=wss://ocpp.mycompany.com/cpms/ocppj/DEWLNERTP1 \
    CONNECTOR_COUNT=3 \
    DEFAULT_CONNECTOR_ID=2 \
    SEND_SIGNED_METER_VALUES=1 \
    node index.js

About

A simple Node.JS script simulating a OCPP 1.6 compatible Charging Station

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published