@blokcert/node-red-contrib-ocpp 1.2.2
Node-RED nodes for OCPP (Open Charge Point Protocol) message handling via Redis Streams
node-red-contrib-ocpp
Node-RED nodes for OCPP (Open Charge Point Protocol) message handling via Redis Streams.
Features
- OCPP 1.6 & 2.0.1 Support - Handle both protocol versions with unified message format
- Redis Streams Integration - Consumer groups for scalable message processing
- Automatic Normalization - Convert between OCPP versions transparently
- CSMS Commands - Send remote commands to charging stations
Installation
cd ~/.node-red
npm install /path/to/node-red-contrib-ocpp
Or from npm (when published):
npm install node-red-contrib-ocpp
Nodes
ocpp-config
Configuration node for Redis connection settings. Shared by other OCPP nodes.
ocpp in
Receives OCPP messages from charging stations via Redis Streams.
Features:
- Consumer group support for load balancing
- Optional payload normalization (OCPP 1.6/2.0.1 → unified format)
- Filter by action type or response type
- Auto-acknowledge messages
Filter Options:
- Empty: Receive all messages (CALL requests + responses)
- Action name (e.g.,
BootNotification): Only CALL requests with this action _CallResult: Only CALLRESULT responses_CallError: Only CALLERROR responses_Response: Both CALLRESULT and CALLERROR responses
Output:
{
payload: { /* OCPP message payload */ },
ocpp: {
messageId: "abc123",
action: "BootNotification", // or "_CallResult" / "_CallError" for responses
messageType: "call", // "call", "result", or "error"
ocppMessageType: 2, // 2=CALL, 3=CALLRESULT, 4=CALLERROR
version: "1.6",
tenant: "operator1",
deviceId: "charger001",
identity: "operator1:charger001",
timestamp: 1699999999999,
streamId: "1699999999999-0"
}
}
ocpp out
Sends OCPP responses back to charging stations.
Features:
- Automatic denormalization (unified → OCPP version)
- Error response support
- Auto-acknowledge inbound message
Input:
// Normal response
msg.payload = {
status: "Accepted",
currentTime: new Date().toISOString(),
interval: 300
};
// Error response
msg.ocpp.error = true;
msg.ocpp.errorCode = "NotImplemented";
msg.ocpp.errorDescription = "Action not supported";
ocpp command
Sends CSMS-initiated commands to charging stations and receives responses.
Supported Commands:
- Reset
- RemoteStartTransaction / RequestStartTransaction
- RemoteStopTransaction / RequestStopTransaction
- UnlockConnector
- TriggerMessage
- ChangeAvailability
- GetConfiguration / GetVariables
- SetVariables
- ClearCache
- And more...
Output: Single output that emits when the device responds (or when a timeout occurs).
Response Message:
{
payload: { /* device response payload */ },
ocpp: {
messageId: "abc123",
action: "GetConfiguration", // Original command
tenant: "operator1",
deviceId: "charger001",
identity: "operator1:charger001",
response: true,
error: false, // true for CALLERROR or timeout
errorCode: null, // Set for errors
errorDescription: null, // Set for errors
sentAt: 1699999999999,
receivedAt: 1699999999150,
latency: 150 // Round-trip time in ms
}
}
Example:
msg.ocpp = {
tenant: "operator1",
deviceId: "charger001",
command: "Reset"
};
msg.payload = {
type: "Soft"
};
return msg;
Example Flow
[ocpp in] → [switch] → [BootNotification handler] → [ocpp out]
└→ [Heartbeat handler] → [ocpp out]
└→ [StatusNotification handler] → [ocpp out]
Simple BootNotification Handler
// Function node
msg.payload = {
status: "Accepted",
currentTime: new Date().toISOString(),
interval: 300
};
return msg;
Remote Start Command
// Inject node → Function node → ocpp command
msg.ocpp = {
tenant: "operator1",
deviceId: "charger001",
command: "RemoteStartTransaction"
};
msg.payload = {
connectorId: 1,
idTag: "RFID12345"
};
return msg;
Message Normalization
The nodes automatically normalize OCPP messages to a unified format, allowing you to handle both OCPP 1.6 and 2.0.1 with the same logic.
BootNotification
| OCPP 1.6 | OCPP 2.0.1 | Unified |
|---|---|---|
| chargePointVendor | chargingStation.vendorName | vendor |
| chargePointModel | chargingStation.model | model |
| chargePointSerialNumber | chargingStation.serialNumber | serialNumber |
| firmwareVersion | chargingStation.firmwareVersion | firmwareVersion |
StatusNotification
| OCPP 1.6 | OCPP 2.0.1 | Unified |
|---|---|---|
| connectorId | evseId + connectorId | evseId, connectorId |
| status | connectorStatus | status |
| errorCode | (not in 2.0.1) | errorCode |
Redis Data Structures
| Key | Type | Description |
|---|---|---|
ws:inbound |
Stream | Messages from devices (consumer group: biz-workers) |
ws:out:{tenant}:{deviceId} |
Stream | Messages to specific device |
ws:conn:{tenant}:{deviceId} |
Hash | Connection registry |
ws:pending:{tenant}:{deviceId} |
Hash | Pending command tracking |
Requirements
- Node-RED >= 2.0.0
- Node.js >= 18.0.0
- Redis >= 6.0 (for Streams support)
License
MIT
Related
- OCPP WebSocket Server - The WebSocket server that works with these nodes