SolarUser OCPP API instructions - SolarNetwork/solarnetwork GitHub Wiki
The SolarUser OCPP API supports sending OCPP messages to connected chargers via the SolarUser /instr/add instruction API. All standard OCPP messages that can be initiated by an OCPP Central System are supported. This document has documentation on the most common messages for convenience.
Any OCPP response message sent by a charger back to SolarNetwork will be stored with the
SolarNetwork instruction itself in the resultParameters
property. You can use the SolarUser
/instr/view API to see the instruction status and result, when it
becomes available.
For OCPP 1.6, the instruction topic must be OCPP_v16
, e.g. the endpoint to use is
/instr/add/OCPP_v16
. The following request properties are common to all requests:
Property | Type | Description |
---|---|---|
topic |
string | Must be OCPP_v16 . |
nodeId |
number | The node ID the charger is associated with. |
params |
object | The message parameters object. Note that all values must be provided as strings. |
params.action |
string | The OCPP v1.6 message name. The supported values are outlined later in this document. |
params.chargePointId |
string | The id of the charger entity to send the message to. Either this or params.chargerIdentifier should be provided. |
params.chargerIdentifier |
string | The info.id charger identity value of the charger entity to send the message to. Either this or params.chargePointId should be provided. |
params.msg |
string | The OCPP 1.6 action message as JSON. If longer than 256 characters, will be split into multiple msg parameters automatically, each at most 256 characters long. If not provided, then other instruction parameter names will be used for OCPP message property values. |
Each supported OCPP v1.6 message requires a specific params.action
value and often additional
parameters. The additional parameters can be provided either via the params.msg
value, as a full
OCPP v1.6 JSON object string, or as additional instruction parameters that match the OCPP v1.6 JSON
message property names. When using params.msg
the JSON should not include the action
,
chargePointId
, or chargerIdentifier
properties in the JSON value; those must be specified as
normal instruction parameter values.
For example, you could send a ChangeAvailability
message to a charger using the params.msg
JSON
value like this (note now the params.msg
value is a JSON-escaped string value, not nested
JSON):
{
"nodeId": "1",
"params": {
"action": "ChangeAvailability",
"chargerIdentifier": "CP0001",
"msg": "{\"connectorId\":1,\"type\":\"Inoperative\"}"
}
}
Or you could send the same message using additional instruction parameters, like this:
{
"nodeId": "1",
"params": {
"action": "ChangeAvailability",
"chargerIdentifier": "CP0001",
"connectorId": "1",
"type": "Inoperative"
}
}
This latter approach can be useful for simple OCPP messages, while more complex messages are easier
to encode as JSON in the params.msg
parameter.
The following enumerations are used across different OCPP 1.6 messages.
The ChargingRateUnitType
enumeration contains the following values:
Value | Description |
---|---|
W |
Watts (power). This is the TOTAL allowed charging power. It is usually more convenient to use this for DC charging. Note that if numberPhases in a ChargingSchedulePeriod is absent, 3 SHALL be assumed. |
A |
Amperes (current). The amount of Ampere per phase, not the sum of all phases. It is usually more convenient to use this for AC charging. |
The RecurrencyKindType
enumeration contains the following values:
Value | Description |
---|---|
Daily |
The schedule restarts every 24 hours, at the same time as in the startSchedule. |
Weekly |
The schedule restarts every 7 days, at the same time and day-of-the-week as in the startSchedule. |
This section outlines the OCPP v1.6 messages most relevant to SolarNetwork.
Action | Description |
---|---|
ChangeAvailability |
Toggle a charge point connector on/off. |
RemoteStartTransaction |
Initiate a charging session remotely. |
RemoteStopTransaction |
Stop a charging session remotely. |
SetChargingProfile |
Set a charge point's charging profile. |
TriggerMessage |
Request a charge point to send a specific message back to SolarNetwork. |
The ChangeAvailabilty
action provides a way to toggle a charge point connector on/off. See section
5.2 of the OCPP 1.6 specification for more information.
The following additional params
values are defined for this action:
Property | Description |
---|---|
action |
ChangeAvailabilty |
connectorId |
The connector ID to change the availability of. |
type |
Either Operative to enable or Inoperative to disable. |
An example POST
to /solaruser/api/v1/sec/instr/add/OCPP_v16
looks like this:
{
"nodeId": "1",
"params": {
"action": "ChangeAvailability",
"chargerIdentifier": "CP0001",
"msg": "{\"connectorId\":1,\"type\":\"Inoperative\"}"
}
}
The RemoteStartTransaction
action provides a way to initiate a charging session remotely. See
section 5.11 of the OCPP 1.6 specification for more information.
The following additional params
values are defined for this action:
Property | Description |
---|---|
action |
RemoteStartTransaction |
connectorId |
The connector to which the charging profile applies. If 0 , the message contains an overall limit for the Charge Point. |
idTag |
The identifier that Charge Point must use to start a transaction. |
chargingProfile |
Optional. A ChargingProfile object to be used by the Charge Point for the requested transaction. The chargingProfilePurpose MUST be set to TxProfile . |
An example POST
to /solaruser/api/v1/sec/instr/add/OCPP_v16
looks like this:
{
"nodeId": "1",
"params": {
"action": "RemoteStartTransaction",
"chargerIdentifier": "CP0001",
"msg": "{\"connectorId\":1,\"idTag\":\"AF013D4AFD\"}"
}
}
The RemoteStopTransaction
action provides a way to stop a charging session remotely. See
section 5.12 of the OCPP 1.6 specification for more information.
The following additional params
values are defined for this action:
Property | Description |
---|---|
action |
RemoteStopTransaction |
transactionId |
The identifier of the transaction which Charge Point is requested to stop. |
An example POST
to /solaruser/api/v1/sec/instr/add/OCPP_v16
looks like this:
{
"nodeId": "1",
"params": {
"action": "RemoteStopTransaction",
"chargerIdentifier": "CP0001",
"msg": "{\"transactionId\":12345}"
}
}
The SetChargingProfile
action provides a way to set a charge point's charging profile. See
section 5.16 of the OCPP 1.6 specification for more information.
The following additional params
values are defined for this action:
Property | Description |
---|---|
action |
SetChargingProfile |
connectorId |
The connector to which the charging profile applies. If 0 , the message contains an overall limit for the Charge Point. |
csChargingProfiles |
A ChargingProfile object. |
An example POST
to /solaruser/api/v1/sec/instr/add/OCPP_v16
looks like this (note that
the msg
value is wrapped across multiple lines for legibility; a real request would not be
wrapped):
{
"nodeId": "1",
"params": {
"action": "SetChargingProfile",
"chargerIdentifier": "CP0001",
"msg": "{\"connectorId\":1,\"csChargingProfiles\":{\"chargingProfileId\":1,
\"stackLevel\":0,\"chargingProfilePurpose\":\"ChargePointMaxProfile\",
\"chargingProfileKind\":\"ChargePointMaxProfile\",
\"chargingSchedule\":{\"chargingRateUnit\":\"W\",\"chargingSchedulePeriod\":[
{\"startPeriod\":0,\"limit\":5000},{\"startPeriod\":43200,\"limit\":2000}]}}}"
}
}
A ChargingProfile
object contains the following propertyes:
Property | Type | Description |
---|---|---|
chargingProfileId |
integer | Unique identifier for this profile. |
transactionId |
integer |
Optional. Only valid if chargingProfilePurpose is set to TxProfile , the transactionId MAY be used to match the profile to a specific transaction. |
stackLevel |
integer | Value determining level in hierarchy stack of profiles. Higher values have precedence over lower values. Lowest level is 0 . |
chargingProfilePurpose |
string | A ChargingProfilePurposeType enumeration value. Defines the purpose of the schedule transferred by this message. |
chargingProfileKind |
string | A ChargingProfileKindType enumeration value. Indicates the kind of schedule. |
recurrencyKind |
string |
Optional. A RecurrencyKindType enumeration value. Indicates the start point of a recurrence. |
validFrom |
string | Optional. A timestamp. Point in time at which the profile starts to be valid. If absent, the profile is valid as soon as it is received by the Charge Point. |
chargingSchedule |
object | A ChargingSchedule object. Contains limits for the available power or current over time. |
The ChargingProfilePurposeType
enumeration contains the following values:
Value | Description |
---|---|
ChargePointMaxProfile |
Configuration for the maximum power or current available for an entire Charge Point. |
TxDefaultProfile |
Default profile that can be configured in the Charge Point. When a new transaction is started, this profile SHALL be used, unless it was a transaction that was started by a RemoteStartTransaction with a ChargeProfile that is accepted by the Charge Point. |
TxProfile |
Profile with constraints to be imposed by the Charge Point on the current transaction, or on a new transaction when this is started via a RemoteStartTransaction with a ChargeProfile. A profile with this purpose SHALL cease to be valid when the transaction terminates. |
The ChargingProfileKindType
enumeration contains the following values:
Value | Description |
---|---|
Absolute |
Schedule periods are relative to a fixed point in time defined in the schedule. |
Recurring |
The schedule restarts periodically at the first schedule period. |
Relative |
Schedule periods are relative to a situation-specific start point (such as the start of a Transaction) that is determined by the charge point. |
A ChargingSchedule
object contains the following properties:
Property | Type | Description |
---|---|---|
duration |
integer | Optional. Duration of the charging schedule in seconds. If the duration is left empty, the last period will continue indefinitely or until end of the transaction in case startSchedule is absent. |
startSchedule |
string | Optional. A timestamp. Starting point of an absolute schedule. If absent the schedule will be relative to start of charging. |
chargingRateUnit |
string | A ChargingRateUnitType enumeration value. The unit of measure Limit is expressed in. |
chargingSchedulePeriod |
array | Array of ChargingSchedulePeriod objects. List of elements defining maximum power or current usage over time. The startSchedule of the first ChargingSchedulePeriod SHALL always be 0. |
minChargingRate |
decimal |
Optional. Minimum charging rate supported by the electric vehicle. The unit of measure is defined by the chargingRateUnit . This parameter is intended to be used by a local smart charging algorithm to optimize the power allocation for in the case a charging process is inefficient at lower charging rates. Accepts at most one digit fraction (e.g. 8.1). |
The ChargingProfileKindType
enumeration contains the following values:
Value | Description |
---|---|
Absolute |
Schedule periods are relative to a fixed point in time defined in the schedule. |
Recurring |
The schedule restarts periodically at the first schedule period. |
Relative |
Schedule periods are relative to a situation-specific start point (such as the start of a Transaction) that is determined by the charge point. |
A ChargingSchedulePeriod
object contains the following properties:
Property | Type | Description |
---|---|---|
startPeriod |
integer | Start of the period, in seconds from the start of schedule. This value also defines the stop time of the previous period. |
limit |
decimal | Charging rate limit during the schedule period, in the applicable chargingRateUnit , for example in Amperes or Watts. Accepts at most one digit fraction (e.g. 8.1). |
numberPhases |
integer | Optional. The number of phases that can be used for charging. If a number of phases is needed, numberPhases=3 will be assumed unless another number is given. |
The TriggerMessage
action provides a way request a charge point to send a specific message back
to SolarNetwork. See section 5.17 of the OCPP 1.6 specification for more information.
The following additional params
values are defined for this action:
Property | Description |
---|---|
action |
TriggerMessage |
requestedMessage |
A MessageTrigger value. |
connectorId |
Optional. Only filled in when request applies to a specific connector. |
An example POST
to /solaruser/api/v1/sec/instr/add/OCPP_v16
looks like this:
{
"nodeId": "1",
"params": {
"action": "TriggerMessage",
"chargerIdentifier": "CP0001",
"msg": "{\"requestedMessage\":\"MeterValues\",\"connectorId\":1}"
}
}
The MessageTrigger
enumeration contains the following values:
Value | Description |
---|---|
BootNotification |
To trigger a BootNotification request. |
DiagnosticsStatusNotification |
To trigger a DiagnosticsStatusNotification request. |
FirmwareStatusNotification |
To trigger a FirmwareStatusNotification request. |
Heartbeat |
To trigger a Heartbeat request. |
MeterValues |
To trigger a MeterValues request. |
StatusNotification |
To trigger a StatusNotification request. |