https://github.com/ocpp-balanz/ocppsim
OCPP Charge Point Simulator
https://github.com/ocpp-balanz/ocppsim
ev evcharging ocpp ocpp16j simulator
Last synced: about 1 month ago
JSON representation
OCPP Charge Point Simulator
- Host: GitHub
- URL: https://github.com/ocpp-balanz/ocppsim
- Owner: ocpp-balanz
- License: mit
- Created: 2025-02-04T16:47:48.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-03-09T06:02:06.000Z (7 months ago)
- Last Synced: 2025-03-17T11:19:30.872Z (7 months ago)
- Topics: ev, evcharging, ocpp, ocpp16j, simulator
- Language: Python
- Homepage:
- Size: 77.1 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ocpp-simulator
OCPP v1.6 Charge Point (CP) Simulator used to test OCPP Central Systems (CS).
## Build
Clone the repository:
```text
git clone https://github.com/ocpp-balanz/ocppsim.git
cd ocppsim
```Install dependencies:
```text
make install
```## Start
Run `python ocppsim.py -h` to retrieve the following help message:
```text
usage: ocppsim.py [-h] [--version] [--config CONFIG] [--port PORT] [--id ID]OCCPSIM - OCCP v1.6 Charge Point Simulator with Websocket Control Interface
options:
-h, --help show this help message and exit
--version show program's version number and exit
--config CONFIG Configuration file (INI format). Default ocpp.ini
--port PORT Command Interface Port. Default in config file.
--id ID Charger Id. Default in config file.
```The configuration file is intended to configure a _type_ of charger, with the actual charger id supplied at startup. Review the file in detail to understand how to configure occpsim.
Start simulating a charger.
python ocppsim.py --id TACW6243111G2672 --port 1234
Next, connect to the port using e.g. [websocat](https://github.com/vi/websocat) to interact with the simulator through the simplistic command interface.
websocat ws://localhost:1234
Alternatively, use the included test driver `ocppsim_test.py` in interactive mode as follows:
python ocppsim_test.py --url ws://localhost:321
`occpsim_test.py` may also be imported as a module and used in test scripts, possibly connecting to multiple simulators.
## Supported commands
The command interface is very simply. Enter a command and retrieve a one line response. The simulator will then execute the appropriate logic.
Commands | Description
------------------ | ----------------------------------------------------------------
`wait [sec]` | Wait some seconds. Default 5 sec
`status` | Get the internal status (does not send/receive anything)
`jsonstatus` | Receive JSON object with charger attributes. Useful for automation.
`full` | Emulate that EV is full/does not want to charge more
`fullafter [wh]` | Emulate that EV is full after having received at least [wh]
`delay` | Set delayed charing. EV will not start charging
`nodelay` | Charging no longer delayed
`delay_notrans` | Set delayed charging mode to NOT start a transaction until time is up
`delay_trans` | Restore to normal mode, i.e. DO start transaction if offer and delay
`plugin` | Cable is plugged into EV
`unplug` | Unplug cable/disconnect EV
`tag [id_tag]` | RFID tag is scanned. Default tag in config file
`clock [offset]` | Adjust timestamps send by offset seconds, e.g. clock -3600
`suspend` | EV suspends charging (for some reason)
`resume` | EV restarts charging (for some reason)
`max [Amps]` | Set maximum charging usage in Amps. Reset without argument.
`reset` | Reset the simulator (clear all state)
`exit` | Exit the command session
`shutdown` | Shutdown the simulator (process will stop)## Automating Tests
The simulator can be used to automate tests. For example, you could write a script that sends commands and checks the responses. See a `pytest` based example in the `test_ocppsim_example.py` file.
## Supported CP to CS messages
- BootNotification
- StatusNotification
- MeterValues
- Authorize
- StartTransaction
- StopTransaction
- TriggerMessage## Supported CS to Charger (CP) messages
- SetChargingProfile
- ClearChargingProfile
- Reset
- ChangeConfiguration (only actively uses AuthorizationKey during http authentication if set)
- RemoteStartTransaction
- RemoteStopTransaction
- GetConfiguration
- ChangeConfiguration## Limitations
- Charging profile evaluation assuming timing "forever"
- Currently only chargers with a single connector/outlet is supported.
- Some messages not supported