Skip to content

loafoe/go-occp-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go OCPP Server

OCPP 1.6-J (JSON over WebSocket) Central System for controlling EV chargers like the Wallbox 3.

Build

go build -o ocpp-server .

Run

./ocpp-server

Options:

  • -ocpp-port: WebSocket port for charger connections (default: 8080)
  • -api-port: HTTP API port (default: 8081)
  • -credentials-file: Path to JSON file with charge point credentials

Authentication

The server supports Basic Auth for charge point authentication. Credentials can be provided via:

Option 1: Credentials file

./ocpp-server --credentials-file /path/to/credentials.json

Format of credentials.json:

{
  "wallbox1": "secretpassword123",
  "wallbox2": "anotherpassword456"
}

Option 2: Environment variable

export OCPP_CREDENTIALS='{"wallbox1":"secretpassword123"}'
./ocpp-server

Wallbox Configuration

In your Wallbox OCPP settings:

  • URL: ws://YOUR_SERVER_IP:8080/ocpp/wallbox1
  • Username: wallbox1 (must match the charge point ID in the URL)
  • Password: secretpassword123

If no credentials are configured, the server runs in open mode (any charger can connect).

Configure Your Wallbox

In your Wallbox settings, configure OCPP with:

  • URL: ws://YOUR_SERVER_IP:8080/ocpp/CHARGER_ID
  • Replace CHARGER_ID with a unique identifier for your charger (e.g., wallbox1)

API Endpoints

List Charge Points

curl http://localhost:8081/api/chargepoints

Get Charge Point Details

curl http://localhost:8081/api/chargepoints/wallbox1

Get Status

curl http://localhost:8081/api/chargepoints/wallbox1/status

Get Meter Values

curl http://localhost:8081/api/chargepoints/wallbox1/meter

Unlock Connector

curl -X POST "http://localhost:8081/api/chargepoints/wallbox1/unlock?connector=1"

Lock Connector

curl -X POST "http://localhost:8081/api/chargepoints/wallbox1/lock?connector=1"

Start Charging Remotely

curl -X POST "http://localhost:8081/api/chargepoints/wallbox1/start?connector=1&tag=MYTAG"

Stop Charging

curl -X POST "http://localhost:8081/api/chargepoints/wallbox1/stop?transaction=1"

Get Configuration

curl http://localhost:8081/api/chargepoints/wallbox1/config

Kubernetes Deployment

A Helm chart is available at https://loafoe.github.io/helm-charts

helm repo add loafoe https://loafoe.github.io/helm-charts
helm install ocpp loafoe/go-ocpp-server \
  --set auth.enabled=true \
  --set auth.credentials.wallbox1=secretpassword123 \
  --set httpRoute.enabled=true \
  --set httpRoute.hostname=ocpp.example.com

Or use auto-provisioning to generate credentials:

helm install ocpp loafoe/go-ocpp-server \
  --set auth.enabled=true \
  --set provisioning.enabled=true \
  --set provisioning.count=1 \
  --set provisioning.idPrefix=wallbox

Then retrieve the generated credentials:

kubectl get secret ocpp-go-ocpp-server-credentials -o jsonpath='{.data.credentials\.json}' | base64 -d

Supported OCPP 1.6 Messages

Incoming (Charger → Server)

  • BootNotification
  • Heartbeat
  • StatusNotification
  • MeterValues
  • StartTransaction
  • StopTransaction
  • Authorize
  • DataTransfer

Outgoing (Server → Charger)

  • UnlockConnector
  • ChangeAvailability
  • RemoteStartTransaction
  • RemoteStopTransaction
  • GetConfiguration

About

Simple OCCP server

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages